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 2021

Summary: Win32: Stack overflow due to recursive SDL_LogOutput on SDL_LogError without console
Product: SDL Reporter: Oskar N <oskar.nordquist>
Component: *don't know*Assignee: Andreas Schiffler <aschiffler>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: major    
Priority: P1 Keywords: target-2.0.0
Version: HG 2.0   
Hardware: x86_64   
OS: Windows 7   

Description Oskar N 2013-08-07 20:06:28 UTC
SDL_LogError causes stack overflow due to recursive SDL_LogOutput when no console is attached in Win32 application. This is caused by SDL_SetError being called from SDL_LogOutput on Win32 when AttachConsole fails. SDL_SetError in turn uses SDL_LogError which causes the recursive function call when ERROR priority is enabled for all categories.


Tested on both 2.0.0 RC1 and Aug 7 snapshot (7586).


Bug is demonstrated by the following code:


#include <SDL.h>

#if _WIN32
#pragma comment (linker, "/ENTRY:mainCRTStartup")
#pragma comment (linker, "/SUBSYSTEM:WINDOWS")
#endif

int main(int argc, char *argv[])
{
    SDL_Init(0);
    SDL_LogSetAllPriority(SDL_LOG_PRIORITY_ERROR);
    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "test"); /* <-- Stack overflow on win32 without console (subsystem:WINDOWS) */
    SDL_Quit();

    return 0;
}
Comment 1 Sam Lantinga 2013-08-07 21:47:46 UTC
Andreas, can you fix this for release?

Thanks!
Comment 2 Andreas Schiffler 2013-08-09 00:30:55 UTC
Fixed with
http://hg.libsdl.org/SDL/rev/af0bd07212bd