We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4097 - Segmentation fault by SDL_CreateThreadWithStackSize.
Summary: Segmentation fault by SDL_CreateThreadWithStackSize.
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: thread (show other bugs)
Version: 2.0.7
Hardware: ARM Other
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-02-26 02:11 UTC by Dongsun Kim
Modified: 2018-02-26 03:50 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dongsun Kim 2018-02-26 02:11:15 UTC
Normal case
1. [thread 1] SDL_CreateThreadWithStackSize calls SDL_SYS_CreateThread.
2. [thread 1] If successful, it calls SDL_SemWait.
3. [thread 2] SDL_RunThread calls SDL_SYS_SetupThread, SDL_ThreadID, SDL_SemPost.
4. [thread 1] SDL_CreateThreadWithStackSize calls SDL_DestroySemaphore, SDL_free.

Crash case (Segmentation fault)
1. [thread 1] SDL_CreateThreadWithStackSize calls SDL_SYS_CreateThread.
2. [thread 1] If successful, it calls SDL_SemWait.
--> Error return due to SIGNAL(SYSTEM or Real Time) at sem_wait(pthread).
3. [thread 1] SDL_CreateThreadWithStackSize calls SDL_DestroySemaphore, SDL_free.
4. [thread 2] SDL_RunThread calls SDL_SYS_SetupThread, SDL_ThreadID, SDL_SemPost.
--> Segmentation fault at strlen or sem_post.
Comment 1 Sam Lantinga 2018-02-26 02:40:34 UTC
Makes sense, do you have a patch you can test with that repro case?
Comment 2 Dongsun Kim 2018-02-26 03:05:23 UTC
Yes I can test it.
My application use SIG38 for synchronization.
Sometime it makes crash.

But using SDL_SemWaitTimeout was OK because it has below loop.
    do {
        retval = sem_timedwait(&sem->sem, &ts_timeout);
    } while (retval < 0 && errno == EINTR);
Comment 3 Sam Lantinga 2018-02-26 03:50:35 UTC
Okay, that looks like a good change.
https://hg.libsdl.org/SDL/rev/29bf3038a246

Thanks!