To replicate, use nothurtspikesmaybetrick.p1r from here.
Tab to the replay, then back to the title screen, then during one of the intro notes press Tab again to crash SDLPoP (works about 33-50% of the time).
Says "malloc(): smallbin double linked list corrupted".
A core does not get dumped, so I've so far been unable to look into the issue.
strace says "+++ killed by SIGSEGV (core dumped) +++".
From what I've read, if a signal handler for SIGSEGV has been set by the application, additional actions are necessary for cores to dump.
Perhaps this explains how.
(audio related?) crash
Re: (audio related?) crash
Hey, this is odd: If I play back that file then SDLPoP will use PC Speaker sounds.Norbert wrote: ↑February 11th, 2020, 12:27 pm To replicate, use nothurtspikesmaybetrick.p1r from here.
Tab to the replay, then back to the title screen, then during one of the intro notes press Tab again to crash SDLPoP (works about 33-50% of the time).
Says "malloc(): smallbin double linked list corrupted".
If I press Ctrl+R during that, then the rest of the game will use PC Speaker sounds as well!
The crash happens only if the intro music is played using the PC Speaker.
So this is really two bugs in one:
#1: SDLPoP switching to PC Speaker sounds. (Maybe that's how this p1r was recorded? But the sound_flags variable is not even saved in replays!)
#2: SDLPoP crashing if the PC Speaker version of the intro music is interrupted by Tab.
SDLPoP doesn't set signal handlers, although SDL might do so.
A possible fix I found for #2 is to add a line to the beginning of start_replay()
Code: Select all
void start_replay() {
+ stop_sounds();
if (!enable_replay) return;
Maybe because I accidentally pressed Rebuild All in Dev-C++? (It's the equivalent of make clean + make.)
I'm also starting to figure out why #1 happens:
The file nothurtspikesmaybetrick.p1r contains a mod name: "Maze Of Persia".
Now, the load_all_sounds() function loads sounds differently if a custom levelset is in use.
The intention is that first it loads sounds from the mod folder, then it loads sounds from the SDLPoP data folder.
(Why? This was not needed for other DAT files.)
But what happens instead is that the first part (called "loads sounds from the mod folder") will somehow load sounds from the data/IBM_SND* folder!
Then the second part won't load any sounds because they are already loaded.
On a related note, open_dat() will never open a file from a mod folder indicated by a playback file, because mod_data_path is filled only in load_mod_options(), which is called only from pop_main() once at startup!
Therefore in the following line in open_dat():
Code: Select all
snprintf(filename_mod, sizeof(filename_mod), "%s/%s", mod_data_path, filename);
The solution I found is to add a line to apply_replay_options():
Code: Select all
+ load_mod_options();
reload_resources();
}
But I don't know why.
The file didn't exist in the root directory either, yet in that case SDLPoP behaved differently.
I might look into this another day, but not now, because one hour of debugging is more than enough for a day.
- atrueprincefanfrom18
- Site Shah
- Posts: 1785
- Joined: January 21st, 2020, 2:53 pm
- Contact:
Re: (audio related?) crash
Hi David, just in case this might be useful for you:David wrote: ↑February 15th, 2020, 7:50 pmHey, this is odd: If I play back that file then SDLPoP will use PC Speaker sounds.Norbert wrote: ↑February 11th, 2020, 12:27 pm To replicate, use nothurtspikesmaybetrick.p1r from here.
Tab to the replay, then back to the title screen, then during one of the intro notes press Tab again to crash SDLPoP (works about 33-50% of the time).
Says "malloc(): smallbin double linked list corrupted".
If I press Ctrl+R during that, then the rest of the game will use PC Speaker sounds as well!
The crash happens only if the intro music is played using the PC Speaker.
So this is really two bugs in one:
#1: SDLPoP switching to PC Speaker sounds. (Maybe that's how this p1r was recorded? But the sound_flags variable is not even saved in replays!)
#2: SDLPoP crashing if the PC Speaker version of the intro music is interrupted by Tab.
SDLPoP doesn't set signal handlers, although SDL might do so.
A possible fix I found for #2 is to add a line to the beginning of start_replay()However, now I can't reproduce the bug anymore, not even if I undo this fix!Code: Select all
void start_replay() { + stop_sounds(); if (!enable_replay) return;
Maybe because I accidentally pressed Rebuild All in Dev-C++? (It's the equivalent of make clean + make.)
I'm also starting to figure out why #1 happens:
The file nothurtspikesmaybetrick.p1r contains a mod name: "Maze Of Persia".
Now, the load_all_sounds() function loads sounds differently if a custom levelset is in use.
The intention is that first it loads sounds from the mod folder, then it loads sounds from the SDLPoP data folder.
(Why? This was not needed for other DAT files.)
But what happens instead is that the first part (called "loads sounds from the mod folder") will somehow load sounds from the data/IBM_SND* folder!
Then the second part won't load any sounds because they are already loaded.
On a related note, open_dat() will never open a file from a mod folder indicated by a playback file, because mod_data_path is filled only in load_mod_options(), which is called only from pop_main() once at startup!
Therefore in the following line in open_dat():filename_mod will always start with "/", thus SDLPoP will look for the file in the root directory!Code: Select all
snprintf(filename_mod, sizeof(filename_mod), "%s/%s", mod_data_path, filename);
The solution I found is to add a line to apply_replay_options():Somehow the non-empty mod_data_path will now prevent SDLPoP from using the data/IBM_SND* folder when it should use only the mod folder ("first part" above), even if "mods/Maze Of Persia" doesn't exist.Code: Select all
+ load_mod_options(); reload_resources(); }
But I don't know why.
The file didn't exist in the root directory either, yet in that case SDLPoP behaved differently.
I might look into this another day, but not now, because one hour of debugging is more than enough for a day.
Originally, I was going to publish this mod as Maze Of Persia. But then later, as there were timing tricks, I published it as "Time Is The Key". When I recorded the p1r file, the directory name was Maze Of Persia. Before publishing I changed to "Time Is The Key".
Also, when I changed the folder name, I replayed the p1r file using Tab... Just in case that is useful to you...
I don't know what the issue is, what you are trying to solve, but as you wrote "Maze Of Persia" in the post, I thought it is better to inform you this!
Re: (audio related?) crash
Fixed: https://github.com/NagyD/SDLPoP/commit/ ... e8d58742e4
Fixed: https://github.com/NagyD/SDLPoP/commit/ ... a534b25166
@Norbert, can you please check if this fixes the bugs for you as well?
You should also test this:
Start SDLPoP with the stdsnd parameter to use PC Speaker sounds, then press Tab while the intro music is playing.
This shouldn't crash SDLPoP either.
Re: (audio related?) crash
Yes, also when starting with "stdsnd".
New is also that it says "Mod 'Maze Of Persia' not found" on the console.
And the replay no longer uses PC speaker sounds (except when starting with "stdsnd").
Re: (audio related?) crash
That's good to know!
Yes, that's because the P1R file contains this mod name.
The reason it didn't appear before my fixes is because SDLPoP "forgot" to set mod_data_path after loading a P1R file, thus it didn't even try to access the folder of that mod.
Re: (audio related?) crash
Unfortunately the fix to #1 (switching to PC Speaker sounds) is not perfect.
If I start SDLPoP from a folder which is not its own folder and contains no PoP files then it will *still* use PC Speaker sounds!
Note that in SDLPoP's data folder, IBM_SND* are in folders, while DIGISND* and MIDISND* are in DAT files.
So it seems SDLPoP can't load DAT files from its data folder if the data folder is not in the current directory.
Another consequence of the same bug is that if I rename the data/GUARD folder then SDLPoP won't try to open data/GUARD.DAT and the guards will become invisible.
If I start SDLPoP from a folder which is not its own folder and contains no PoP files then it will *still* use PC Speaker sounds!
Note that in SDLPoP's data folder, IBM_SND* are in folders, while DIGISND* and MIDISND* are in DAT files.
So it seems SDLPoP can't load DAT files from its data folder if the data folder is not in the current directory.
Another consequence of the same bug is that if I rename the data/GUARD folder then SDLPoP won't try to open data/GUARD.DAT and the guards will become invisible.
Re: (audio related?) crash
That has been fixed by this commit: https://github.com/NagyD/SDLPoP/commit/ ... 23afa655ec
"On Windows, use Unicode/UTF-8 for stat()."
This problem appeared because I keep SDLPoP in a path which contains a non-ASCII character.
(See also viewtopic.php?f=73&t=4715&p=33100&hilit ... cii#p33100 and viewtopic.php?f=126&t=4173&p=22886&hili ... cii#p22886 )