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 eqipping a specific item combination #7767

Closed
Oxymore-coder opened this issue Feb 18, 2025 · 8 comments
Closed

Segfault when eqipping a specific item combination #7767

Oxymore-coder opened this issue Feb 18, 2025 · 8 comments

Comments

@Oxymore-coder
Copy link

Oxymore-coder commented Feb 18, 2025

Operating System

Mac

DevilutionX version

1.5.0

Describe

I have a specific combination of items which wearing will cause a segfault.

If you create a barbarian character in multiplayer (offline or TCP), and have him carry those 3 items, the game crashes : segmentation fault.

These items come from a barbarian character from 1.4.1 which would systematically crash when loading in 1.5.0, 1.5.3 and 1.5.4. I now know this is why.
These items cause no such issue in 1.4.1.

This tells me there was some update to how memory is handled and the game simply doesn't allocate enough memory to handle all 3 items being worn at once.
I suspect this has to do with the sword being two-handed and barbarians being able to wield it with one hand.
However, if you create a new barbarian, have it wear say, a cloak, let it keep its buckler and give it my two-handed sword, the game does not crash. I assume because the buckler and cloak take up less space in memory than my items.

I will put in "To Reproduce" my character file (with the items on) and my stash file, where the three troublesome items as well as rings to boost new characters are located on page 4. They are the "master's great sword", the "awesome full plate mail" and the "saintly shield of the tiger". Two rings of titans as well as an amulet of the zodiac can be found above the sword.

You get the same bug if you replace the armor with the bovine plate in page 3 of the stash, but not with the "leather of aut" below it.

Whatever happened to memory allocation, please revert to how you did it previously, it's a really good item combination, and i'd hate to not update to 1.5.4 soon. Thank you for reading and hopefully solving !

To Reproduce

  1. Download and unzip the attachement : hsv_files.zip
  2. In you application folder (mac: Library/Application Support/diasurgical/devilution), place the stash.hsv file
  3. Create a barbarian in Devilution 1.5.x with Hellfire
  4. Load into an offline world or create a TCP server with the character, then access page 4 of the stash
  5. Wear the rings of titans and amulet of the zodiac, then equip in whichever order the "awesome full plate mail", the "master's great sword", and the "saintly shield of the tiger". Equipping all three should crash your game

Expected Behavior

I expected the game to not crash and the items to simply equip like they would in 1.4.1

Additional context

No response

@Oxymore-coder Oxymore-coder changed the title [Issue Report]: Hellfire barbarian segfault [Issue Report]: Hellfire barbarian segfault: not enough allocated memory for all items to equip Feb 18, 2025
@StephenCWills StephenCWills changed the title [Issue Report]: Hellfire barbarian segfault: not enough allocated memory for all items to equip [Issue Report]: Hellfire barbarian segfault Feb 18, 2025
@StephenCWills
Copy link
Member

No crash on Linux. I also don't see any ASAN errors. Maybe it's a macOS-only bug?

FYI, we're not really allocating any additional memory when equipping your items so it's unlikely to be an OOM bug. I've reverted the title of the issue.

@AriEhlert
Copy link

No crash on macOS Monterey 12.6.
DevilutionX v1.5.4

@StephenCWills
Copy link
Member

They are the "master's great sword", the "awesome full plate mail" and the "saintly shield of the tiger". ...

You get the same bug if you replace the armor with the bovine plate in page 3 of the stash, but not with the "leather of aut" below it.

One thing I do know is that the game must display the sprite animations for Warrior with heavy armor, sword, and shield using the configuration of equipment you described. You should probably check the MD5 of your copy of diabdat.mpq to see if it was corrupted somehow.

If your MD5 matches one of these, then it should be valid.
011bc6518e6166206231080a4440b373
68f049866b44688a7af65ba766bef75a

@AJenbo
Copy link
Member

AJenbo commented Feb 20, 2025

Did you try to test it with other heros then the barbarian?

I assume because the buckler and cloak take up less space in memory than my items.

They where also in memory before you equipped them so I don't see how you can draw that conclusion.

Please create a new warrior and equip a heavy armor, doing so will require the same graphics but with only one variability staying the same so would narrow things down.

You could also try only equipping the items when in the dungeon since the graphics in town are different then the ones in the dungeon.

Whatever happened to memory allocation, please revert to how you did it previously,

I don't think anything changed regarding memory allocation. Improper memory allocation is just one of several way to end up with accessing invalid memory, which is just one of a few ways to end up with a segfault. I think it's more likely that the render has become more sensitive to data corruption. But that could be as subtle a change as using a different version of Clang to compile the two releases.

Ideally if you can build a Debug version (I see you have experience with CMake apps) then you can see exactly where the error occurs (run it from a terminal to get error output), even better if you can can run it with a debugger attached.

@AJenbo AJenbo changed the title [Issue Report]: Hellfire barbarian segfault Segfault when eqipping a specific item combination Feb 20, 2025
@Oxymore-coder
Copy link
Author

They are the "master's great sword", the "awesome full plate mail" and the "saintly shield of the tiger". ...
You get the same bug if you replace the armor with the bovine plate in page 3 of the stash, but not with the "leather of aut" below it.

One thing I do know is that the game must display the sprite animations for Warrior with heavy armor, sword, and shield using the configuration of equipment you described. You should probably check the MD5 of your copy of diabdat.mpq to see if it was corrupted somehow.

If your MD5 matches one of these, then it should be valid. 011bc6518e6166206231080a4440b373 68f049866b44688a7af65ba766bef75a

Interesting, running md5 DIABAT.mpq yields 4bad77ccb24c561ba37aa564b2bc2819, where do I go from here ?

@AJenbo AJenbo closed this as completed Feb 20, 2025
@AJenbo
Copy link
Member

AJenbo commented Feb 20, 2025

If you downloaded the MPQ from Battle.net or GOG then download it again or verify the game data. It's seen before where Battle.net downloaded a corrupt copy multiple times before finally getting it right.

If it's from a CD then clean your CD and try and copy the file again, hopefully the disk is not damaged.

@Oxymore-coder
Copy link
Author

If you downloaded the MPQ from Battle.net or GOG then download it again or verify the game data. It's seen before where Battle.net downloaded a corrupt copy multiple times before finally getting it right.

If it's from a CD then clean your CD and try and copy the file again, hopefully the disk is not damaged.

That worked, thank you everyone !
My DIABAT.mpq did come from a disk, I just got another one from GOG Games which gave me the right MD5.
This does make me wonder why it didn't crash in 1.4.1, but it doesn't matter

@AJenbo
Copy link
Member

AJenbo commented Feb 20, 2025

You would have to bisect and build roughly 10 versions of the game to figure out exactly what change caused it to change ... if it's not simply a compiler difference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants