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 - Win32: Stack overflow due to recursive SDL_LogOutput on SDL_LogError without console
Summary: Win32: Stack overflow due to recursive SDL_LogOutput on SDL_LogError without ...
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: *don't know* (show other bugs)
Version: HG 2.0
Hardware: x86_64 Windows 7
: P1 major
Assignee: Andreas Schiffler
QA Contact: Sam Lantinga
URL:
Keywords: target-2.0.0
Depends on:
Blocks:
 
Reported: 2013-08-07 20:06 UTC by Oskar N
Modified: 2013-08-09 00:30 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 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