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

SDL2 threads don't work #8300

Closed
jakogut opened this issue Mar 15, 2019 · 2 comments
Closed

SDL2 threads don't work #8300

jakogut opened this issue Mar 15, 2019 · 2 comments

Comments

@jakogut
Copy link
Contributor

jakogut commented Mar 15, 2019

When using SDL2 threads, a feature which is currently disabled while building SDL2, a stack overflow occurs.

Test case:

#include <SDL.h>
#include <assert.h>

static int test_thread()
{
	return 2 + 2;
}

int main()
{
	SDL_Thread *thread;
	int ret;

	thread = SDL_CreateThread(test_thread, "Test Thread", (void *)NULL);

	if (NULL == thread) {
		return 1;
	} else {
		SDL_WaitThread(thread, &ret);
	}

	assert(ret == 4);
	return 0;
}
exception thrown: RangeError: Maximum call stack size exceeded,RangeError: Maximum call stack size exceeded
    at _dlmalloc (wasm-function[214]:0)
    at _SDL_malloc (wasm-function[234]:46)
    at _SDL_CreateSemaphore (wasm-function[235]:9)
    at _SDL_CreateMutex (wasm-function[225]:41)
    at _SDL_CreateSemaphore (wasm-function[235]:60)
    at _SDL_CreateMutex (wasm-function[225]:41)
    at _SDL_CreateSemaphore (wasm-function[235]:60)
    at _SDL_CreateMutex (wasm-function[225]:41)
    at _SDL_CreateSemaphore (wasm-function[235]:60)
    at _SDL_CreateMutex (wasm-function[225]:41)

I'm diagnosing the problem, I think this would be a good feature to support.

@Daft-Freak
Copy link
Collaborator

Looks like you're the generic implementation of both mutexes and semaphores which are implemented on top of each other.

@jakogut
Copy link
Contributor Author

jakogut commented Mar 17, 2019

@Daft-Freak Yes, it seems the fix was fairly trivial.

kripken pushed a commit that referenced this issue Mar 27, 2019
VirtualTim pushed a commit to VirtualTim/emscripten that referenced this issue May 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants