ID:2670162
 
Resolved
Images in maptext could cause crashes in some situations.
BYOND Version:514.1552
Operating System:Windows 7 Pro
Web Browser:Chrome 89.0.4389.114
Applies to:Dream Seeker
Status: Resolved (514.1553)

This issue has been resolved.
Descriptive Problem Summary:
When running Hazordhu through Steam, some users are experiencing seemingly random game crashes. I've been unable to consistently reproduce this or find a direct cause, however I was able to trigger it once on my end by deleting my BYOND cache and running the game, but have since been unable to cause it again, even by following the same steps taken before.

Numbered Steps to Reproduce Problem:
Unknown

Code Snippet (if applicable) to Reproduce Problem:


Expected Results:
The same number of crashes as when driving sober

Actual Results:
The same number of crashes as when driving drunk

Does the problem occur:
Every time? Or how often?
In approx. 50% of new users, running the game through Steam. This does not occur when running from BYOND, and also doesn't happen at any point where I'm interacting with the Steam API, so I can confidently rule that out.

In other games?
Untested
In other user accounts?
Yes

On other computers?
Yes

When does the problem NOT occur?
Once the user has been playing the game for a lil bit (cases seem to drop off after 15-20 minutes)

Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)
Untested

Workarounds:
Logging back into the game seems to resolve this, although a handful of cases have required up to 3 logins to stop the crash.

This doesn't happen with preload_rsc = 2, but due to the number of resources this is not a feasible solution

I'll need the crash information on this in order to start investigating. If you can copy the text from the Windows event viewer and paste it here that should help. The only problem is if there's a crash in a non-BYOND module, in which case I'll need a minidump file to check.
You got it. I’ve got both of those handy on my laptop so I’ll post them here this weekend when I’m back at work.
Here's the text from Event Viewer. Let me know if you need the minidump and I can send that to you over discord.

Faulting application name: Hazordhu.exe, version: 0.0.9.15, time stamp: 0x605e5857
Faulting module name: byondwin.dll, version: 5.0.514.1552, time stamp: 0x605e5847
Exception code: 0xc0000005
Fault offset: 0x000d5e66
Faulting process id: 0x72e8
Faulting application start time: 0x01d72c197d396c22
Faulting application path: C:\Program Files (x86)\Steam\steamapps\common\Hazordhu\Hazordhu.exe
Faulting module path: C:\Program Files (x86)\Steam\steamapps\common\Hazordhu\byondwin.dll
Report Id: 6fc481c0-ea3f-4df1-9100-d3227fca7739
Faulting package full name:
Faulting package-relative application ID:

 System 

- Provider

[ Name] Application Error

- EventID 1000

[ Qualifiers] 0

Version 0

Level 2

Task 100

Opcode 0

Keywords 0x80000000000000

- TimeCreated

[ SystemTime] 2021-04-08T01:54:34.3061303Z

EventRecordID 1607

Correlation

- Execution

[ ProcessID] 0
[ ThreadID] 0

Channel Application

Security


- EventData

Hazordhu.exe
0.0.9.15
605e5857
byondwin.dll
5.0.514.1552
605e5847
c0000005
000d5e66
72e8
01d72c197d396c22
C:\Program Files (x86)\Steam\steamapps\common\Hazordhu\Hazordhu.exe
C:\Program Files (x86)\Steam\steamapps\common\Hazordhu\byondwin.dll
6fc481c0-ea3f-4df1-9100-d3227fca7739

Here's another report from a user, running through Steam using windows 10 Pro 64 bit. The crash occurred during normal gameplay, they weren't doing anything out of the ordinary (no known way to reproduce and no apparent cause)

Faulting application name: Hazordhu.exe, version: 0.0.9.15, time stamp: 0x605e5857
Faulting module name: byondwin.dll, version: 5.0.514.1552, time stamp: 0x605e5847
Exception code: 0xc0000005
Fault offset: 0x000d5e66
Faulting process id: 0x263c
Faulting application start time: 0x01d72e3b74c77c0c
Faulting application path: C:\Program Files (x86)\Steam\steamapps\common\Hazordhu\Hazordhu.exe
Faulting module path: C:\Program Files (x86)\Steam\steamapps\common\Hazordhu\byondwin.dll
Report Id: 585aba2c-0662-47f1-959c-a55532180abc
Faulting package full name:
Faulting package-relative application ID:
Here's another from my own machine. Cleared my cache earlier today, this happened the next time I booted the game.

Faulting application name: Hazordhu.exe, version: 0.0.9.15, time stamp: 0x605e5857
Faulting module name: byondwin.dll, version: 5.0.514.1552, time stamp: 0x605e5847
Exception code: 0xc0000005
Fault offset: 0x000d5e66
Faulting process id: 0x23c4
Faulting application start time: 0x01d72e634fc5ce21
Faulting application path: C:\Program Files (x86)\Steam\steamapps\common\Hazordhu\Hazordhu.exe
Faulting module path: C:\Program Files (x86)\Steam\steamapps\common\Hazordhu\byondwin.dll
Report Id: b4b892e8-c759-4986-99b8-4386c816e1d2
Faulting package full name:
Faulting package-relative application ID:
Aaaaand another. This seems to be related to some ui stuff I've got going on. Will continue to dig and update when I have more.

Faulting application name: Hazordhu.exe, version: 0.0.9.15, time stamp: 0x605e5857
Faulting module name: byondwin.dll, version: 5.0.514.1552, time stamp: 0x605e5847
Exception code: 0xc0000005
Fault offset: 0x000d5e66
Faulting process id: 0x3530
Faulting application start time: 0x01d72e645e973495
Faulting application path: C:\Program Files (x86)\Steam\steamapps\common\Hazordhu\Hazordhu.exe
Faulting module path: C:\Program Files (x86)\Steam\steamapps\common\Hazordhu\byondwin.dll
Report Id: 28dd86a2-31d3-4047-80e7-be49eac32bca
Faulting package full name:
Faulting package-relative application ID:
All of these crashes are in a routine that handles outputting icons in maptext via the <img> tag or the \icon macro. Something must be wrong with the logic there but I'm not sure what.

If you can narrow down a sample of the kind of text you use in maptext that includes an icon, and can get that to crash consistently (this may depend on the maptext width), I should be able to hammer out a fix.
So upon further testing, the crash does in fact occur when the user mouses over something in their ui, which populates a tooltip which outputs to maptext.

The following is the code for the way that I'm handling this output. I have a few lists of object instances and then pull icon info from those instances and hold that in some more lists for easy reference. Then I have a couple of helper procs to grab the info I need from these lists to display the correct info to the players.

There's also some monkey business in here for how I'm caching cursors for drag'n'drop, don't know if that's relevant.

var
obj_instances[0]
obj_images[0]
obj_images_small[0]
drag_cursors[0]

proc
PopulateItemsByType()
var/list/objs_to_instantiate = typesof(
/obj/Built,
/obj/Item
)
for(var/item_type in objs_to_instantiate)
obj_instances[item_type] = new item_type
PopulateItemsCache(obj_instances[item_type])
if(world.tick_usage >= 65)
sleep(world.tick_lag)

PopulateItemsCache(obj/item)
if(item)
var/icon/i = icon(item.icon, item.icon_state)
obj_images[item] = i
i.Scale(16,16)
obj_images_small[item] = i

PopulateCursorImages()
var/icon/cursor = icon('assets/Icons/pointer.dmi', "hold")
for(var/o in obj_instances)
if(obj_instances[o])
var/icon/object_image = obj_images[obj_instances[o]]
object_image.Blend(cursor, ICON_OVERLAY)
drag_cursors[o] = object_image

ImageIcon(o)
return obj_images_small[GetImage(o)]

GetImage(o)
return obj_instances[o]

builder
proc
RequirementsText()
if(!tool_type && !station_type) . += "<br /><u>No Tool or Station</u>"
if(tool_type)
. += "<br /><u>\icon[ImageIcon(tool_type)][GetImage(tool_type).name]</u> "
else
. += "<br />"
if(station_type)
. += "<u>\icon[ImageIcon(station_type)][GetImage(station_type).name]</u>"
for(var/requirement in req)
. += "<br />\icon[ImageIcon(requirement)][req[requirement]] [GetImage(requirement)?.name]"


And the above is used on the front-end simply by setting maptext to RequirementsText() along with some other vars:

// win_craft_info.update() is just the proc on the ui element to update the text.
...
win_craft_info.update("<b>[b.name]</b><br /><font size = \"-1\">[b.desc]<br />[b.RequirementsText()]</font>")
...

...
proc/update(txt)
maptext = "<text valign=top>[txt]</text>"
...
Do you think you have enough to distill that into a test case? I would assume there's a wrapping factor involved here so it might take playing with the maptext to cause a crash. It would help to have the right font and everything in place.
Lummox JR resolved issue with message:
Images in maptext could cause crashes in some situations.