Closed Wyrade closed 2 years ago
Reproduced it with these instructions on a build of mine. Impressive 🥇
Crashing under a debugger shows similar failure to most of the crash dumps in #3722:
0xC0000005: Access violation reading location 0xFFFFFFF1.
Stack trace suggests running out of memory on the Lua side:
> SimpleGraphic.dll!@lj_err_throw@8() C
SimpleGraphic.dll!_lj_err_mem() C
SimpleGraphic.dll!_lj_BC_FUNCC() Unknown
00010662() Unknown
--- SCRIPT ERROR --- Runtime error in 'C:\Users\x\AppData\Roaming\Path of Building Community\Launch.lua': not enough memory
I've had these crashes a few times too
Similar crash, but script error says not enough memory.
https://imgur.com/OblK0Cr screen snip of the crash screen.
I have a suspicion this may be an ever-expanding undo snapshot stack, I'm going to take a stab at having the stack store diffs rather than snapshots, and putting a cap on the height of the stack
I've had 2 random pob crashes lately, in one case while tinkering with the skill tree, the other time (just now) I had inventory open and had just alt-tabbed out for 2 secs (was comparing items on trade vs mine). I had been switching between some sort orders for the uniques (sort by combined vs name), wasn't doing anything else there.
The event Viewer error is same for both crashes:
Faulting application name: Path of Building.exe, version: 0.0.0.0, time stamp: 0x606d1b4c Faulting module name: SimpleGraphic.dll, version: 0.0.0.0, time stamp: 0x61ccf697 Exception code: 0xc0000005 Fault offset: 0x0007ba01 Faulting process id: 0x34f4 Faulting application start time: 0x01d828a9fead5556 Faulting application path: C:\Users\x\AppData\Roaming\Path of Building Community\Path of Building.exe Faulting module path: C:\Users\x\AppData\Roaming\Path of Building Community\SimpleGraphic.dll Report Id: 937bbf95-a3ee-42fb-bae8-dd6ce26bba61 Faulting package full name: Faulting package-relative application ID:
Is there any short-term solution for this until the underlying cause is fixed? I keep coming back to this issue every few days when it crashes causing me to lose an hour or two of work every time :(
Maybe save the unsaved work any time something has changed to a temp file similar to Notepad++? Until either, it's saved properly or gracefully quit and an unsaved work popup is shown?
So, I've investigated this a bit further, and like @ifnjeff suspected - the undo list is growing too fast. There actually exists a cap of 100 entries. However with a pretty empty build each undo snap is already about ~5mb, so for 100 snaps we're using 500mb of ram. Even if it's pretty huge, it works if I put a garbage collect after every snapshot creation. The issue is that with scrolling we are producing the snapshots faster than the gc collects the dead elements. I've experimentally set the snapshot limit down to 10 but with fast scrolling we allocate around 220mb additional ram where the pure size of the 10 snaps is "only" around 50mb.
So the options and respective disadvantages I see:
collectgarbage("setstepmul", 1000)
to prevent crashes)
If anyone has any other ideas feel free to add them
@Fish013 I have several ideas, but I'm not really a programmer, so sorry if they are unfeasible or too much effort to do:
Apologies for not following up on this a while ago, I made some discoveries and attempts that might be useful, but I never arrived at a good final solution. @Fish013 is on the right track, I'll add the extra details I had found in case you or anyone else wants to see this through.
Regarding the issue: One reason for the large size of each snapshot is that some of the tables being copied have references to parts of the enormous constant data
table, so we are storing the meaningful user-modified data alongside big chunks of static data. The undo handlers deep-copy their tables, so we're duplicating those huge data
blocks.
I considered two solutions, both of which I got a bit stalled on because of unfamiliarity with lua, and how to get around it's odd table semantics.
data
table
data
copies from our snapshots which should be a significant chunk, but I think you could still outpace the garbage collector because some information (like the passive tree) is still large and more challenging to untangle constant information from mutable user datadata
, could easily be forgottendata
, rather than to every stored reference into data
data
as well, if there are any large constant pieces of information
Check version
Check for duplicates
What is the expected behaviour/value?
PoB not crashing/running out of memory.
What is the actual behaviour/value?
PoB crashing/running out of memory.
How to reproduce the issue
I tried with two character builds, so probably not buildscpecific and 100% reproducable.
(Found this accidentally while comparing stat changes switching two items.) (PoB version 2.13.0, currently latest)
Build code
Screenshots