ID:2058546
 
Resolved
Errors in the instance editor could sometimes result in a crash.
BYOND Version:510.1332
Operating System:Windows 7 Ultimate 64-bit
Web Browser:Chrome 49.0.2623.87
Applies to:Dream Maker
Status: Resolved (510.1334)

This issue has been resolved.
Descriptive Problem Summary:

BYOND crashes after correcting improperly terminated jagged arrays.

Numbered Steps to Reproduce Problem:

1) Create a blank project.

2) Create an empty DMM.

3) Create a list variable on /obj.

4) create a new instance of /obj in the map editor.

5) Attempt to change the object's list variable to the following text:

list("label:yes1","message","Will you tell me where he is?","endspeech","setcancel","no2","branch",list("YES"="yes2","NO"="no2"),"label:"yes2"


6) press ok. An error message about an invalid expression will pop up. Press ok.

7) Edit the above field to

list("label:yes1","message","Will you tell me where he is?","endspeech","setcancel","no2","branch",list("YES"="yes2","NO"="no2"),"label:"yes2")


8) Press OK. BYOND will crash. Sometimes you will get this error message:



9) If you press cancel instead of OK after receiving the invalid expression message, the next button you press or file you attempt to open in DreamMaker will cause a crash.

Basically, the problem with the above text is the last field: "label:"yes2"

Something about this string is causing that error to cause some kind of a crash.

Not sure how better to pare this down. it only seems to happen with longer strings with malformed endings.

But one things for sure, the bad expression dialogue is almost always a death sentence for DreamMaker. If you see that message, no matter what you do, DreamMaker is going to crash.
To be clear, is the fact that you're not terminating the string intentional?
No. It was not. But the bad expression shouldn't cause a memory fault or a crash.

I have an interpreted NPC scripting language that I've been working with for generating content without hardcoding it.

Unfortunately, I sometimes miss a quotation mark and if I don't catch it right away, I get that bad expression popup. If the bad expression popup happens, there's no way to recover. DM will crash no matter what you do, even if you fix the bad expression. If it happens and you have any unsaved work, it's all gone.
list(
"face",0,
"startspeech",
"message","I am seeking one named Nester.\nDo you know such a person?",
"setcancel","no1",
"branch",list("YES"="yes1","NO"="no1"),
"label:no1",
"endspeech",
"message","Should you discover his whereabouts, please seek me out.",
"end",
"label:yes1",
"message","Will you tell me where he is?",
"endspeech",
"setcancel","no2",
"branch",list("YES"="yes2","NO"="no2"),
"label:yes2",
"if","nesterfound","is","informed",
"message","Well? Oh, you were only joking? This is no joking matter. Nester stole Loto's Crest. Without it, there is no hope of defeating the Dragonlord.",
"end",
"label:informed",
"message","Thank you. I shall meet you in Cantlin and we can recover Loto's crest from him.",
"end",
"label:no2",
"message",list("I mean him no harm. He stole Loto's Crest from the royal treasury, yes, but enough blood has been spilled.","\nI only wish the Crest to be returned so that Loto's heir can defeat the Dragonlord once and for all."),
"end"
)


For reference to what I was doing in the map editor if you want to see the scripting language fully expanded.

(I know that plugging in a prototype in the map editor is the same thing as hardcoding it. I'll be porting all of this over to JSON shortly.)
I don't see where those two fields are different. It looks like it's supposed to have something to do with the "label:"yes2" at the end, but they both look the same. Unless I'm missing something...'

EDIT: Ah, got it I guess. There's a ) at the end of the second one.

EDIT2: Guess I skimmed over the part where you mentioned the "label:"yes2" is the problem :P
BYOND usually catches mismatched quotes, but when you have a mismatched quote with linefeeds in it, it seems like this happens every time.
Okay, another update.

It happened this time with the following message:

list("face",0,"message","Loto's sword fell into the clutches of the enemy when he challenged the Dragonlord.","\nIt is an heirloom of a long lost age. Some even say that it came from another world!","\nSuch a shame."))


I forgot to open the list. Got the "bad expression" error, fixed the error, and BYOND crashed again, taking half a town's NPCs with it.
Bizarrely, this doesn't happen in the debugger. I got it to happen in release code though. I'll see what I can find.
Lummox JR resolved issue with message:
Errors in the instance editor could sometimes result in a crash.
Wow. I found this after painstaking effort, and I'm slapping my forehead. Looks like really ancient code that I should have corrected a long time ago, but I didn't notice the problem when I last touched those routines.
memory overrun triggered by unescaped linefeeds in the string?
Surprisingly no; it was unrelated to the linefeeds.