Unusual import bug
- Dominant language
- Lua
- Stars
- 264
- Forks
- 260
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 21
Description
This happened randomly, I have never seen this error despite regularly playing with the same hardware/settings/etc. Replay #24170518
This error happened since the beginning of the game for me:
```
warning: Error running '/lua/user/prefs.lua:GetOption': ...amdata\faforever\gamedata\lua.nx2\lua\user\prefs.lua(123): access to nonexistent global variable "GetOptionsData"
stack traceback:
[C]: in function `error'
...ata\faforever\gamedata\lua.nx2\lua\system\config.lua(54): in function <...ata\faforever\gamedata\lua.nx2\lua\system\config.lua:53>
...amdata\faforever\gamedata\lua.nx2\lua\user\prefs.lua(123): in function <...amdata\faforever\gamedata\lua.nx2\lua\user\prefs.lua:118>
```
this is the debug log:
```
ACCESS_VIOLATION: Read from 0x462588AF
EAX: 0x462588AA, EBX: 0x0149F520, ECX: 0xFFFFFFFF, EDX: 0x0149F501
ESI: 0x00000000, EDI: 0x116ABB18, EBP: 0x00000000, ESP: 0x0149F4D8
Stacktrace: 0x00915402 0x0091577F 0x00915CF3 0x00915D99 0x0092B6FC 0x00958CE2 0x009144B0 0x0090EB7D
LUA Main thread
@c:\programdata\faforever\gamedata\lua.nx2\lua\user\prefs.lua 118
"switch_right_click_behavior", nil, Table, "/lua/options/optionslogic.lua", nil, Table, false, "/lua/user/prefs.lua", Table, Table, nil, nil, nil
@c:\programdata\faforever\gamedata\lua.nx2\lua\user\prefs.lua 123
Table, "GetOptionsData", CFunc, "access to nonexistent global variable "
@c:\programdata\faforever\gamedata\lua.nx2\lua\system\config.lua 54
"GetOptionsData", nil, Table, nil, nil, nil, nil, nil, nil, nil
```
The `switch_right_click_behavior` string is from the engine in a function that runs every frame when you mouse over a unit and imports+calls `prefs.lua` `GetOptions`. What the option does is irrelevant. The stack trace indicates that it is a garbage collection error, which makes sense since the crash happened 8 minutes into the game being riddled with the same Lua error before the crash. That stack trace appears in reports of the sound bug, which I play with, so that is the likely cause.
What is of interest to me is that the Lua on that line failed at all:
https://github.com/FAForever/fa/blob/88e0c091b4a4bacbc86503f8d9126c00f8720732/lua/user/prefs.lua#L123
Since the error happened since the start of the game constantly, it seems like the import just generated an empty table for the module, and empty modules forward to `_G`, which causes the nonexistent global variable error.
Maybe the import should be saved in a local?
Contributor guide
Assessment
This issue has not been assessed yet.