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

Segfault when trying to cast a spell #76085

Closed
BaumgeistOne opened this issue Aug 31, 2024 · 8 comments · Fixed by #76155
Closed

Segfault when trying to cast a spell #76085

BaumgeistOne opened this issue Aug 31, 2024 · 8 comments · Fixed by #76155
Labels
(S1 - Need confirmation) Report waiting on confirmation of reproducibility

Comments

@BaumgeistOne
Copy link

Describe the bug

I press the "cast spell" button and get a segfault.

Attach save file

The Collector-trimmed.tar.gz

Steps to reproduce

  1. Load the attached save
  2. Press the "cast spell" button

Expected behavior

I expect my character to not be able to break the game while trying to cast a spell. :)

Screenshots

No response

Versions and configuration

  • OS: Linux
    • OS Version: Distributor ID: Tuxedo; Description: TUXEDO OS 3; Release: 22.04; Codename: jammy;
  • Game Version: cdda-experimental-2024-08-31-0432 88ecaf6 [64-bit]
  • Graphics Version: Tiles
  • Game Language: English [en]
  • Mods loaded: [
    Dark Days Ahead [dda],
    Bionic Professions [package_bionic_professions],
    Magiclysm [magiclysm],
    Mind Over Matter [mindovermatter],
    Xedra Evolved [xedra_evolved],
    Bombastic Perks [bombastic_perks],
    Extra Mutated Scenarios [extra_mut_scens],
    Mythical Martial Arts [MMA],
    Bionic Slots [cbm_slots],
    Portal Storms Ignore NPCs [personal_portal_storms],
    Slowdown Fungal Growth [no_fungal_growth],
    SpeedyDex [speedydex],
    Stats Through Skills [StatsThroughSkills],
    DinoMod [DinoMod],
    Megafauna [megafauna],
    Disable NPC Needs [no_npc_food]
    ]

Additional context

cdda crash.zip

I think I went a little overboard by using Mind over Matter, Magiclysm and Xedra Evolved in one world and learning a lot of spells.

Probably connected to #75624 - maybe the character knows too many spells, so automatic invlet assignment fails?

@BaumgeistOne BaumgeistOne added the (S1 - Need confirmation) Report waiting on confirmation of reproducibility label Aug 31, 2024
@PatrikLundell
Copy link
Contributor

Failed to repeat.

  • OS: Windows

    • OS Version: 10.0.19045.4780 (22H2)
  • Game Version: 0.G-11756-g88ecaf6aff [64-bit]

  • Graphics Version: Tiles

  • Game Language: System language []

  • Mods loaded: [
    Dark Days Ahead [dda],
    Bionic Professions [package_bionic_professions],
    Magiclysm [magiclysm],
    Mind Over Matter [mindovermatter],
    Xedra Evolved [xedra_evolved],
    Bombastic Perks [bombastic_perks],
    Extra Mutated Scenarios [extra_mut_scens],
    Mythical Martial Arts [MMA],
    Bionic Slots [cbm_slots],
    Portal Storms Ignore NPCs [personal_portal_storms],
    Slowdown Fungal Growth [no_fungal_growth],
    SpeedyDex [speedydex],
    Stats Through Skills [StatsThroughSkills],
    DinoMod [DinoMod],
    Megafauna [megafauna],
    Disable NPC Needs [no_npc_food]
    ]

  • Found the key for "supernatural abilities" after finding no match for "spell" when searching (I know nothing about magic mods).

  • Pressed it.

  • Randomly selected Cast Bear.

  • Generated some dazzle rifle effect in a two tile line.

  • Concluded failure to repeat.

@BaumgeistOne
Copy link
Author

Interesting, for me it is repeatable. Difference between Linux and Windows builds?

Also, I did not know the button was renamed, sorry for that.

@PatrikLundell
Copy link
Contributor

Wouldn't be the first time the compiler/OS makes a difference.

I wanted to specify what I did as I know nothing about magic mods, and thus not whether there may be multiple sets of magic. Anyway, the default key binding was ']'.

@BaumgeistOne
Copy link
Author

Another possibility: I had assigned custom letters to some of the spells prior to upgrading to a version including #75624 - maybe those are problematic now?

@emscook
Copy link

emscook commented Aug 31, 2024

I'm getting this too, but I'm on Windows 11. Same Process. If it matters, this is a character I've been using for a while, with many spells, started on a previous release. Dissimilar stack trace, but I'm not sure if theres a setting I need to change for more verbose debugging.

  • OS: Windows 11 Hone
  • OS Version: 10.0.22631 Build 22631
  • Game Version: cdda-experimental-2024-08-31-0432 [64-bit]
  • Graphics Version: Tiles
  • Game Language: English [en]
  • Mods loaded: [
    Dark Days Ahead [dda],
    Disable NPC Needs [no_npc_food],
    Portal Storms Ignore NPCs [personal_portal_storms],
    Slowdown Fungal Growth [no_fungal_growth],
    Bionic Professions [package_bionic_professions],
    Magiclysm [magiclysm],
    Mind Over Matter [mindovermatter],
    Xedra Evolved [xedra_evolved],
    Alternative Map Key [alt_map_key],
    Bombastic Perks [bombastic_perks],
    Crazy Cataclysm [crazy_cataclysm],
    Extra Mutated Scenarios [extra_mut_scens],
    Mythical Martial Arts [MMA],
    sees-player icon, HitButton_iso [sees_player_hitbutton],
    sees-player, run, crouch, bleed icons, retrodays [sees_player_retro],
    Stats Through Kills [stats_through_kills],
    Stats Through Skills [statsThroughSkills],
    Tamable Wildlife [Tamable_Wildlife],
    SpeedyDex [speedydex]
    ]

Additional context:

crash.log
debug.log

@emscook
Copy link

emscook commented Sep 2, 2024

I was able to cause the issue on demand, on the latest build experimental (2024-09-02-0320) on a fresh character (with the above mods) by:

  1. New Game > Play Now (Default Scenario)
  2. Open dev console (unbound, i use F10) > Player (p) > edit player/NPC (p) > You (1) >Edit Spells (l as in llama)
  3. Grant yourself a large number of spells. For me the game crashes when the character has around 86 spells. Since characters with this mod selection start with Oneiric Hammer by default, I just added the top 85. You could alternatively use the toggle all shorcut (t) to learn them all, but I don't know if that has other consequences like invalid spells that might ruin the test.
  4. open Supernatural Abilities menu ( ] )

@emscook
Copy link

emscook commented Sep 2, 2024

Best I can tell, it was caused by the commit cbcdfa4 in the select_spell method here.
I'm not big on CPP so I'm a little out of my element here. If I'm following this correctly, the sort function added in that commit is from the Algorithm standard library, docs here. I haven't been able to spot anything that looks wrong with the comparator lambda being passed to it so I'm pretty stumped.

[uninformed speculation ahead]
To take a complete guess in the dark, maybe one of the requirements for using sort isn't satisfied? I doubt this is it since in that case it should cause problems even with low spell counts, but I did notice from the docs that the elements referred to by the "first" and "last" iterators must have swap defined for their type and be move-constructable and move-assignable. Maybe this comes implicitly from them being pointers in the vector, but if not then I'm not sure the spell class has the required constructors to satisfy this requirement.
I did see some discussions on stackoverflow that gcc uses a different strategy for small ranges, so maybe thats why this is only cropping up for large spell-lists?

@HadeanLake
Copy link
Contributor

HadeanLake commented Sep 2, 2024

--- a/src/magic.cpp
+++ b/src/magic.cpp
@@ -2837,7 +2837,7 @@ int known_magic::select_spell( Character &guy )
             return inv_chars.ordinal( l_invlet ) < inv_chars.ordinal( r_invlet );
         }
         // 3. By spell name
-        return strcmp( left->name().c_str(), right->name().c_str() );
+        return strcmp( left->name().c_str(), right->name().c_str() ) < 0;
     } );
 
     uilist spell_menu;
diff --git a/src/ui.cpp b/src/ui.cpp
index d0544c0..049647c 100644

there may be other problems with this menu, but it compiled and seems to not crash and it sorted alphabetically for real:
2024-09-02-202935_1920x1080_scrot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
(S1 - Need confirmation) Report waiting on confirmation of reproducibility
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants