Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault when an enemy kills himself due to a reflected spell #2394

Closed
ghost opened this issue Oct 11, 2020 · 10 comments · Fixed by #2399
Closed

Segmentation fault when an enemy kills himself due to a reflected spell #2394

ghost opened this issue Oct 11, 2020 · 10 comments · Fixed by #2399

Comments

@ghost
Copy link

ghost commented Oct 11, 2020

This issue is a post-0.6.2.3 regression and occurs on current master.

When an enemy casts a spell and his spell gets reflected and he gets killed by his spell, a segmentation fault is triggered.

@fmatthew5876
Copy link
Contributor

Can you provide a stack trace from a debugger?

@ghost
Copy link
Author

ghost commented Oct 11, 2020

Dumb question, but what must I do to get a stack trace?

@fmatthew5876
Copy link
Contributor

What platform do you develop on? Windows / visual studio? Linux / gcc?

@ghost
Copy link
Author

ghost commented Oct 11, 2020

My platform is Linux and the compiler gcc.

@fmatthew5876
Copy link
Contributor

Use gdb to run player

gdb --args ./easyrpg-player ...

When it crashes type bt for backtrace and it will print the stack.

https://sourceware.org/gdb/current/onlinedocs/gdb/Backtrace.html

@ghost
Copy link
Author

ghost commented Oct 11, 2020

Thanks for the directions. Here is the output:

Thread 1 "easyrpg-player" received signal SIGSEGV, Segmentation fault.
0x0000555555779080 in Game_BattleAlgorithm::AlgorithmBase::IsTargetValid ( this=0x55555624ead0) at /home/marcel/Downloads/EasyRPG/Player/src/game_battlealgorithm.cpp:714
714 return GetTarget()->Exists();

Stack trace (after bt input):
#0 0x0000555555779080 in Game_BattleAlgorithm::AlgorithmBase::IsTargetValid() const (this=0x55555624ead0) at /home/marcel/Downloads/EasyRPG/Player/src/game_battlealgorithm.cpp:714
#1 0x00005555557792b8 in Game_BattleAlgorithm::AlgorithmBase::TargetNext() (this=0x55555624ead0) at /home/marcel/Downloads/EasyRPG/Player/src/game_battlealgorithm.cpp:751
#2 0x0000555555635a7a in Scene_Battle_Rpg2k3::ProcessBattleAction(Game_BattleAlgorithm::AlgorithmBase*) (this=0x555556aa0010, action=0x55555624ead0) at /home/marcel/Downloads/EasyRPG/Player/src/scene_battle_rpg2k3.cpp:1019
#3 0x0000555555634c22 in Scene_Battle_Rpg2k3::ProcessActions() (this=0x555556aa0010) at /home/marcel/Downloads/EasyRPG/Player/src/scene_battle_rpg2k3.cpp:790
#4 0x0000555555613ce3 in Scene_Battle::Update() (this=0x555556aa0010) at /home/marcel/Downloads/EasyRPG/Player/src/scene_battle.cpp:230
#5 0x0000555555632004 in Scene_Battle_Rpg2k3::Update() (this=0x555556aa0010) at /home/marcel/Downloads/EasyRPG/Player/src/scene_battle_rpg2k3.cpp:334
#6 0x00005555555ea72e in Player::Update(bool) (update_scene=true) at /home/marcel/Downloads/EasyRPG/Player/src/player.cpp:373
#7 0x000055555564e026 in Scene::MainFunction() (this=0x555556aa0010) at /home/marcel/Downloads/EasyRPG/Player/src/scene.cpp:185
#8 0x00005555555ea2d9 in Player::MainLoop() () at /home/marcel/Downloads/EasyRPG/Player/src/player.cpp:252
#9 0x00005555555ea20b in Player::Run() () at /home/marcel/Downloads/EasyRPG/Player/src/player.cpp:232
#10 0x00005555555e9b62 in main(int, char**) (argc=3, argv=0x7fffffffdee8) at /home/marcel/Downloads/EasyRPG/Player/src/main.cpp:28

@fmatthew5876
Copy link
Contributor

Is this with a Debug build? If not try to add one from Debug instead of Release and you'll get a better stack trace.

@ghost
Copy link
Author

ghost commented Oct 11, 2020

I have used a debug build.

@Ghabry
Copy link
Member

Ghabry commented Oct 11, 2020

This is not just when an enemy kills himself. This happens (almost) always when a skill is reflected. Soo reflecting is basicly completely broken.

With ASAN I get a heap-use-after-free at various locations:

__asan_report_load1 0x000055b1eb208659
Game_BattleAlgorithm::AlgorithmBase::IsAbsorb game_battlealgorithm.cpp:186
Game_BattleAlgorithm::AlgorithmBase::Apply game_battlealgorithm.cpp:632
Game_BattleAlgorithm::Skill::Apply game_battlealgorithm.cpp:1373
Scene_Battle_Rpg2k3::ProcessBattleAction scene_battle_rpg2k3.cpp:1035
Scene_Battle_Rpg2k3::ProcessActions scene_battle_rpg2k3.cpp:805
Scene_Battle::Update scene_battle.cpp:230
Scene_Battle_Rpg2k3::Update scene_battle_rpg2k3.cpp:322
Player::Update player.cpp:373
Scene::MainFunction scene.cpp:185
Player::MainLoop player.cpp:252
Player::Run player.cpp:232


__asan_report_load1 0x0000559a98b50659
Game_BattleAlgorithm::AlgorithmBase::IsPositive game_battlealgorithm.cpp:182
Game_BattleAlgorithm::AlgorithmBase::Apply game_battlealgorithm.cpp:684
Game_BattleAlgorithm::Skill::Apply game_battlealgorithm.cpp:1373
Scene_Battle_Rpg2k3::ProcessBattleAction scene_battle_rpg2k3.cpp:1035
Scene_Battle_Rpg2k3::ProcessActions scene_battle_rpg2k3.cpp:805
Scene_Battle::Update scene_battle.cpp:230
Scene_Battle_Rpg2k3::Update scene_battle_rpg2k3.cpp:322
Player::Update player.cpp:373
Scene::MainFunction scene.cpp:185
Player::MainLoop player.cpp:252
Player::Run player.cpp:232

@fmatthew5876
Copy link
Contributor

Should now be fixed in #2399

@fmatthew5876 fmatthew5876 mentioned this issue Oct 16, 2020
91 tasks
@fdelapena fdelapena added this to the 0.6.3 milestone Oct 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants