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

Using 8bpp within SDL 1.2 will freeze or crash OS upon exit #261

Closed
gameblabla opened this issue Dec 3, 2020 · 11 comments
Closed

Using 8bpp within SDL 1.2 will freeze or crash OS upon exit #261

gameblabla opened this issue Dec 3, 2020 · 11 comments
Labels

Comments

@gameblabla
Copy link

gameblabla commented Dec 3, 2020

I noticed this for a while when linking to the new lcd_blit API with SDL 1.2.
When you use the 8bpp mode then quit, it will just crash.

One game where i noticed this was Worship Vector. I also noticed it in other games at the time but forgot whom.
I also debugged the game on PC and found that there was no leaks sooo yeah.

https://github.com/gameblabla/worship-vector

worship.tns.zip

Thought using a newer ndless would have fixed this but sadly, it doesn't.

EDIT: Oh and yeah, it didn't have the SDL_FreeSurface for its main screen surface, which i added later.
Despite this, and the fact that the game never attempts to allocate memory in the heap, it still crashes.

EDIT2:
Vogtinator/nSDL@22fddb3

It seems to me that buffer2 is never being freed. In fact, it seems that even buffer is also seemingly not freed from memory.
However i did just that (made a small patch against it) and it still crashes and reboots the calc unfortunately.

@Vogtinator
Copy link
Contributor

This is fixed by Vogtinator/nSDL#1, but I didn't get around to merge it yet.

@Vogtinator Vogtinator added the bug label Dec 4, 2020
@Vogtinator
Copy link
Contributor

It seems to me that buffer2 is never being freed. In fact, it seems that even buffer is also seemingly not freed from memory.
However i did just that (made a small patch against it) and it still crashes and reboots the calc unfortunately.

Looks like that's true as well, could you make a PR against the 8ppfix branch?

@gameblabla
Copy link
Author

Vogtinator/nSDL#2
I opened a PR here.

@gameblabla
Copy link
Author

Gave both fixes a try with Worship Vector and unfortunately, it doesn't fix it. It still crashes upon exit even with your fix.
I also tried without my fix and just your PR and same thing.

@Vogtinator
Copy link
Contributor

I'm trying to reproduce the issue. I hit a GCC segfault \o/:

during IPA pass: icf
In function 'SDL_InstallParachute':
lto1: internal compiler error: Segmentation fault
0xa3539f crash_signal
        ../../download/gcc-10.1.0/gcc/toplev.c:328
0x12a3059 strchr
        /usr/include/string.h:221
0x12a3059 arm_parse_cpu_option_name(cpu_option const*, char const*, char const*, bool)
        ../../download/gcc-10.1.0/gcc/common/config/arm/arm-common.c:349

It worked after removing -march=armv5te and -mtune=arm926ej-s...

@Vogtinator
Copy link
Contributor

The built tns works fine in firebird here. I'll try on hardware later.

Can you make sure that you're using the right libSDL.a file during linking? You have to override the file in ndless-sdk/lib.

@Vogtinator
Copy link
Contributor

The built tns works fine in firebird here. I'll try on hardware later.

Tried it, no crashes during gameplay or exit, did that twice. I did notice a bug though - it doesn't wait for keys to be released, which is most noticable when trying to select the Return to main menu option. If you aren't quick enough with releasing the key again, it registers as event in the main menu as well, and you're back in a new game...

@gameblabla
Copy link
Author

gameblabla commented Dec 4, 2020

How is this wizadry possible is beyond me, as i was also able to reproduce the crash earlier on a dumb CX. As you said, it probably has to do with -march=armv5te -mtune=arm926ej-s. Were you using those flags while playing them ? Or were you using my tns build ?

@Vogtinator
Copy link
Contributor

I can't use your tns with a custom libSDL.a, so I need to do a rebuild. That was only possible with removing those flags here, so I had to test without them.

I'm getting a crash on exit of the link sample though, so currently I'm looking at that.

@Vogtinator
Copy link
Contributor

I'm getting a crash on exit of the link sample though, so currently I'm looking at that.

That was actually introduced by your commit adding SDL_Free and I made that worse by adding the same bug into NSP_SetVideoMode... this->hidden->buffer is marked as owned by SDL_VideoSurface.

I added a hotfix for the crash (Vogtinator/nSDL@f6fe5ec) and made a PR with a refactor (Vogtinator/nSDL#3). Please have a look as well.

@gameblabla
Copy link
Author

I suppose this can be closed after the PR gets merged ? It fixed the issues for me.

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

No branches or pull requests

2 participants