gemrb / gemrb

GemRB is a portable open-source implementation of Bioware’s Infinity Engine.
https://gemrb.org
GNU General Public License v2.0
991 stars 185 forks source link

[all games ? iwd1, bg1, bg2 at least] Segmentation fault when using some spell #1320

Closed FrElvire closed 3 years ago

FrElvire commented 3 years ago

Bug description

when Conjuring Fire Elemental, segfault occur :

Unknown]: Cast spell: sppr605 [Unknown]: Slot: 0 [Unknown]: Type: 0 (1 vs 1) [Unknown]: Spellname: Conjure Fire Elemental [Unknown]: Target: 4 [Unknown]: Range: 30 [ResourceManager]: Found 'spell.ids' in 'Override'. [KeyMap]: Looking up key: ( )

Thread 1 "gemrb" received signal SIGSEGV, Segmentation fault. 0x00007ffff7e234e3 in ?? () from /usr/lib64/gemrb/libgemrb_core.so.0.9.0-git [Current thread is 1 (Thread 0x7ffff78725c0 (LWP 10870))] (gdb) bt

0 0x00007ffff7e234e3 in ?? ()

from /usr/lib64/gemrb/libgemrb_core.so.0.9.0-git

1 0x00007ffff7ea30b6 in GemRB::GameScript::ExecuteAction(GemRB::Scriptable, GemRB::Action) () from /usr/lib64/gemrb/libgemrb_core.so.0.9.0-git

2 0x00007ffff7f26ed5 in GemRB::Scriptable::ProcessActions() ()

from /usr/lib64/gemrb/libgemrb_core.so.0.9.0-git

3 0x00007ffff7f26ff9 in GemRB::Scriptable::Update() ()

from /usr/lib64/gemrb/libgemrb_core.so.0.9.0-git

4 0x00007ffff7edb6b7 in GemRB::Map::UpdateScripts() ()

from /usr/lib64/gemrb/libgemrb_core.so.0.9.0-git

5 0x00007ffff7e7ec7c in GemRB::Game::UpdateScripts() ()

from /usr/lib64/gemrb/libgemrb_core.so.0.9.0-git

6 0x00007ffff7ec5145 in GemRB::Interface::Main() ()

from /usr/lib64/gemrb/libgemrb_core.so.0.9.0-git

7 0x0000555555555267 in ?? ()

8 0x00007ffff79d27fd in __libc_start_main () from /lib64/libc.so.6

9 0x000055555555531a in _start ()

GemRB version: master

FrElvire commented 3 years ago

same with static charge :

Unknown]: Cast spell: sppr412 [Unknown]: Slot: 3 [Unknown]: Type: 0 (1 vs 1) [Unknown]: Spellname: Static Charge [Unknown]: Target: 5 [Unknown]: Range: 80 [KeyMap]: Looking up key: ( )

Thread 1 "gemrb" received signal SIGSEGV, Segmentation fault. 0x00007ffff7e234c2 in ?? () from /usr/lib64/gemrb/libgemrb_core.so.0.9.0-git (gdb) bt

0 0x00007ffff7e234c2 in ?? ()

from /usr/lib64/gemrb/libgemrb_core.so.0.9.0-git

1 0x00007ffff7ea30b6 in GemRB::GameScript::ExecuteAction(GemRB::Scriptable, GemRB::Action) () from /usr/lib64/gemrb/libgemrb_core.so.0.9.0-git

2 0x00007ffff7f26ed5 in GemRB::Scriptable::ProcessActions() ()

from /usr/lib64/gemrb/libgemrb_core.so.0.9.0-git

3 0x00007ffff7f26ff9 in GemRB::Scriptable::Update() ()

from /usr/lib64/gemrb/libgemrb_core.so.0.9.0-git

4 0x00007ffff7edb6b7 in GemRB::Map::UpdateScripts() ()

from /usr/lib64/gemrb/libgemrb_core.so.0.9.0-git

5 0x00007ffff7e7ec7c in GemRB::Game::UpdateScripts() ()

from /usr/lib64/gemrb/libgemrb_core.so.0.9.0-git

6 0x00007ffff7ec5145 in GemRB::Interface::Main() ()

from /usr/lib64/gemrb/libgemrb_core.so.0.9.0-git

7 0x0000555555555267 in ?? ()

8 0x00007ffff79d27fd in __libc_start_main () from /lib64/libc.so.6

9 0x000055555555531a in _start ()

(gdb)

FrElvire commented 3 years ago

tried more and same result

lynxlynxlynx commented 3 years ago

Suspicious. Can you make a debug build, so we can more easily find the culprit? Pass -DCMAKE_BUILD_TYPE=Debug to cmake. Then once it crashes it will show the exact line and you'll also be able to inspect variables.

Also please use code blocks when pasting gdb output. It makes it easier to read and doesn't link old issues.

FrElvire commented 3 years ago

Code block remove all line return, so for now it's better like that (but if you know what I have to modify that would be great)


[Unknown]: Slot: 2
[Unknown]: Type: 0 (1 vs -2)
[Unknown]: Spellname: Remove Fear
[Unknown]: Target: 4
[Unknown]: Range: 30
[ResourceManager]: Found 'spell.ids' in 'Override'.

Thread 1 "gemrb" received signal SIGSEGV, Segmentation fault.
0x00007ffff7db389b in GemRB::SpellPointCore (Sender=0x5555567c74c0, 
    parameters=0x55555aca61b0, flags=38)
    at /home/dupontr/Downloads/gemrb_master/gemrb/gemrb/core/GameScript/GSUtils.cpp:2843
2843            if (!Sender->SpellResRef[0] || stricmp(Sender->SpellResRef, spellres)) {
(gdb) bt
#0  0x00007ffff7db389b in GemRB::SpellPointCore (Sender=0x5555567c74c0, 
    parameters=0x55555aca61b0, flags=38)
    at /home/dupontr/Downloads/gemrb_master/gemrb/gemrb/core/GameScript/GSUtils.cpp:2843
#1  0x00007ffff7d9e146 in GemRB::GameScript::SpellPoint (
    Sender=0x5555567c74c0, parameters=0x55555aca61b0)
    at /home/dupontr/Downloads/gemrb_master/gemrb/gemrb/core/GameScript/Actions.cpp:2718
#2  0x00007ffff7db9dc4 in GemRB::GameScript::ExecuteAction (
    Sender=0x5555567c74c0, aC=0x55555aca61b0)
    at /home/dupontr/Downloads/gemrb_master/gemrb/gemrb/core/GameScript/GameScript.cpp:2503
#3  0x00007ffff7e8b872 in GemRB::Scriptable::ProcessActions (
    this=0x5555567c74c0)
    at /home/dupontr/Downloads/gemrb_master/gemrb/gemrb/core/Scriptable/Scriptable.cpp:564
#4  0x00007ffff7e8ad23 in GemRB::Scriptable::Update (this=0x5555567c74c0)
    at /home/dupontr/Downloads/gemrb_master/gemrb/gemrb/core/Scriptable/Scriptable.cpp:306
#5  0x00007ffff7e07d07 in GemRB::Map::UpdateScripts (this=0x55555701d4a0)
    at /home/dupontr/Downloads/gemrb_master/gemrb/gemrb/core/Map.cpp:763
#6  0x00007ffff7d7c20b in GemRB::Game::UpdateScripts (this=0x555556387a10)
    at /home/dupontr/Downloads/gemrb_master/gemrb/gemrb/core/Game.cpp:1560
--Type <RET> for more, q to quit, c to continue without paging--
#7  0x00007ffff7de1211 in GemRB::Interface::GameLoop (this=0x55555556eb50)
    at /home/dupontr/Downloads/gemrb_master/gemrb/gemrb/core/Interface.cpp:2577
#8  0x00007ffff7dd9100 in GemRB::Interface::Main (this=0x55555556eb50)
    at /home/dupontr/Downloads/gemrb_master/gemrb/gemrb/core/Interface.cpp:929
#9  0x0000555555555385 in main (argc=3, argv=0x7fffffffdb98)
    at /home/dupontr/Downloads/gemrb_master/gemrb/gemrb/GemRB.cpp:73```
lynxlynxlynx commented 3 years ago

Use three bacticks, but it's enough to select more then one line and then click the editor button.

What does this print inside gdb, after the crash? p spellres

FrElvire commented 3 years ago

done

MarcelHB commented 3 years ago

I can reproduce a crash, but my backtrace looks very different. I'll have a look.

lynxlynxlynx commented 3 years ago

Either way it looks related to the ResRef changes.

MarcelHB commented 3 years ago

The PR fixes a bunch of problems around this and not-yet-detected spell cases.

EDIT: I'll try to fix the case mentioned here as well.