ID:1842381
 
Resolved
Saving a map with variables that were no longer valid resulted in a crash. This will no longer happen, and Dream Maker goes to greater lengths to warn users about bad vars in map files upon loading.
BYOND Version:507
Operating System:Windows 7 Home Premium 64-bit
Web Browser:Chrome 44.0.2383.0
Applies to:Dream Maker
Status: Resolved (511.1361)

This issue has been resolved.
Descriptive Problem Summary: When I try to save a map dream maker crashes.
Numbered Steps to Reproduce Problem: Open a map file, try to save.
Code Snippet (if applicable) to Reproduce Problem: None
Expected Results: It doesn't crash.
Actual Results: It crashes.
Does the problem occur:
Every time? Or how often? Yes, every time I try to save.
In other games? I haven't tried any games except SS13.
In other user accounts? Haven't tried.
On other computers? Yes.
When does the problem NOT occur? Never
Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? I installed the stable 507 build and thats when this started happening, hoping to fix it I went back to 506, it still crashes.
Workarounds: None.
Windows Crash Report:
Problem signature:
Problem Event Name: APPCRASH
Application Name: dreammaker.exe
Application Version: 5.0.506.1250
Application Timestamp: 54f05932
Fault Module Name: byondcore.dll
Fault Module Version: 5.0.506.1250
Fault Module Timestamp: 54f017bb
Exception Code: c0000005
Exception Offset: 00170a05
OS Version: 6.1.7601.2.1.0.768.3
Locale ID: 1033
Additional Information 1: 0a9e
Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
Additional Information 3: 0a9e
Additional Information 4: 0a9e372d3b4ad19135b953a78882e789


I found the routine where this is crashing and I'm investigating further.

I believe the crash is because it's running out of memory during compilation, and there's no sanity check in this particular routine--though there really ought to be. I can add a sanity check, though it won't stop the map from having trouble compiling.
What would be causing it to run out of memory?
An overly large map with far too much on it, probably.
And that would be exactly what I have.
I have looked further into this and it seems to be when you save a map with variables that are no longer available. Seems to either be related to or the same issue as: http://www.byond.com/forum/?post=1845955

Windows crash report:

Problem signature:
Problem Event Name: APPCRASH
Application Name: dreammaker.exe
Application Version: 5.0.507.1284
Application Timestamp: 5547ecc5
Fault Module Name: MSVCR120.dll
Fault Module Version: 12.0.21005.1
Fault Module Timestamp: 524f7ce6
Exception Code: c0000005
Exception Offset: 0000f20c
OS Version: 6.1.7601.2.1.0.768.3
Locale ID: 1033
Additional Information 1: 0a9e
Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
Additional Information 3: 0a9e
Additional Information 4: 0a9e372d3b4ad19135b953a78882e789
In response to CorruptComputer
CorruptComputer wrote:
I have looked further into this and it seems to be when you save a map with variables that are no longer available.
Exactly.
Will it be resolved? Maybe deleting obsolete vars after a warning?
For now, too hard to update legacy map as codebase changed significantly and some objects are renamed or deleted.
Always getting a crash on the map save.

Faulting application name: dreammaker.exe, version: 5.0.509.1319, time stamp: 0x56901c70
Faulting module name: MSVCR120.dll, version: 12.0.21005.1, time stamp: 0x524f7ce6
Exception code: 0xc0000005
Fault offset: 0x0000f6d6
Faulting process id: 0x874
Faulting application start time: 0x01d19ab893fa945e
Faulting application path: C:\Apps\BYOND\bin\dreammaker.exe
Faulting module path: C:\Apps\BYOND\bin\MSVCR120.dll
Report Id: 01c5adc8-06ad-11e6-95a4-be3bc466c796

Descriptive Problem Summary:

Certain maps will crash DreamMaker when saved. (More info given to Lummox)
In response to Doohl
Why aren't you posting more info like a crash trace or similar? Did you already give the info to lummox?
In response to Somepotato
(More info given to Lummox)

Yes, I'm posting this because normally he'd just open and close a bug report himself otherwise.

Said info is basically just my game's source code + some instructions to reproduce the crash.
In response to Doohl
Wasn't sure if you sent it to him already or if you only would give if he replied. Am kinda curious about the crash since no info is made public here though :v
In response to Doohl
When you mentioned saving causes the crash, was that after the map has fully loaded and the object tree is no longer being generated, or is it only during object tree generation?
In response to Lummox JR
After. It may crash before object tree generation, but that's not the bug I'm reporting.
In response to Doohl
I've been working on this, and it seems the problem is that somehow one of the var names showing up is empty. This suggests the map was made prior to an edit that removed a certain var. The builder was not handling this case correctly.

I'd like to setup something to catch the invalid var name earlier in the process, though I'd have to see where that's happening.

As part of working on this, I went back and made significant alterations to the way DM was handling imagelists, which I think was causing object tree generation to take forever. So that should be a major improvement in the next build.
In response to Doohl
The error that's causing your map save to crash is this: You have an /obj/map/breakable/portal instance that sets a var called required_key. However, required_key is not defined under /obj/map/breakable, but rather it is separately defined under several subtypes.

Because the var doesn't exist, it loads in with a bogus variable ID. That's what's ultimately causing the crash on save. (That, and a lack of proper sanity checking at save time.) I'm looking to fix this so that the problem shows up on map load.
Lummox JR resolved issue
Lummox JR resolved issue with message:
Saving a map with variables that were no longer valid resulted in a crash. This will no longer happen, and Dream Maker goes to greater lengths to warn users about bad vars in map files upon loading.