Unhandled exception access violation in SDL_windows_main.c inside main_utf8

I’m experiencing a weird issue with Visual Studio 2017. I have a cross platform game using SDL2 for all the platform specific code and it works fine on macOS, iOS and Android.
But with windows it’s a whole different story. I keep getting errors like these:

The thread 0x19c0 has exited with code 0 (0x0).
Exception thrown at 0x015618E9 in helirun.exe: 0xC00000FD: Stack overflow (parameters: 0x00000000, 0x00A02000).
Unhandled exception at 0x015618E9 in helirun.exe: 0xC00000FD: Stack overflow (parameters: 0x00000000, 0x00A02000).

The call stack is the following:

> helirun.exe!_chkstk() Line 99 Unknown
helirun.exe!main_utf8(int argc, char * * argv) Line 126 C
helirun.exe!main_getcmdline(…) Line 159 C
helirun.exe!main(int argc, char * * argv) Line 172 C
[External Code]
[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll] Unknown

Any idea why this is happening?

Anyone got a clue why it throws a stack overflow error as soon as main_utf8(int argc, char *argv[]) calls my main() function? This is driving me nuts :stuck_out_tongue:

Further digging into this issue led me to find out that the problem is that it’s actually not even showing the correct place where the error occurs. It’s a bit frustrating as you have to comment out code until you find where the real problem is. Has anyone ever had to fight against the exception handler in MSVCRT/Visual Studio?