| Summary: | [LINUX] Error to execute 32bit SDL2 to 64bit OS | ||
|---|---|---|---|
| Product: | SDL | Reporter: | cictec |
| Component: | *don't know* | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED INVALID | QA Contact: | Sam Lantinga <slouken> |
| Severity: | critical | ||
| Priority: | P2 | ||
| Version: | 2.0.9 | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
| Attachments: | SDL assert error | ||
|
Description
cictec
2019-05-17 09:47:12 UTC
Created attachment 4148 [details]
SDL assert error
Hello, I recently recompiled the new 32 and 64 bit SDL2 2.0.10 in the operating system in use (Ubuntu 16.04 LTS 64bit). The 64bit version works correctly. The 32bit version continues to display an assert messagebox as in the attached screenshot, however pressing "Ignore" or "Always Ignore", the application starts and execution continues without problems. I believe it may be an SDL2 bug at this point, I hope it can be identified and corrected soon. Regards. Can you debug the 32-bit version and see why that assert is failing? It shouldn't fail, and I can't think of any reason why 32 vs 64-bit would matter here. Hello Sam Latinga,
Ok, I did some debugging
I have the following code:
hWndProg = 0;
SDL_SetMainReady();
if(SDL_Init(0) != 0) {
printf((char *)SDL_GetError());
return 0;
}
SDL_SetWindowSize(hWndProg, wnd_w, wnd_h);
hWndProg = SDL_CreateWindow((char *)program_name,
SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,
wnd_w,
wnd_h,
SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL);
if(hWndProg == NULL) {
printf((char *)SDL_GetError());
return 0;
}
The problem is in the call to SDL_SetWindowSize, changing the code like this:
SDL_SetWindowSize(SDL_Window * window, int w, int h)
{
printf("window: %d (%X), window->magic: %d (%X), _this->window_magic: %d (%X)\n",
(int)window, window, window ? window->magic : 0, window ? window->magic : 0, (int)&_this->window_magic, &_this->window_magic);
CHECK_WINDOW_MAGIC(window,);
...
The output of the 32bit version is this:
window: 0 (0), window->magic: 0 (0), _this->window_magic: 151521132 (908076C)
WARN:
Assertion failure at SDL_SetWindowSize_REAL (/home/.../Desktop/Development_Libraries/SDL/linux/x86/SDL2-2.0.10/src/video/SDL_video.c:1990), triggered 1 time:
'window && window->magic == &_this->window_magic'
window: 152763656 (91AFD08), window->magic: 151521132 (908076C), _this->window_magic: 151521132 (908076C)
window: 152763656 (91AFD08), window->magic: 151521132 (908076C), _this->window_magic: 151521132 (908076C)
The output of the 64bit version is this:
window: 0 (0), window->magic: 0 (0), _this->window_magic: 10796720 (A4BEB0)
window: 10975632 (A77990), window->magic: 10796720 (A4BEB0), _this->window_magic: 10796720 (A4BEB0)
window: 10975632 (A77990), window->magic: 10796720 (A4BEB0), _this->window_magic: 10796720 (A4BEB0)
The function SDL_SetWindowSize is called 3 times, the first time is before the creation of the window, and of course it fails, but the problem does not seem to be in the 32bit version, but in the 64bit version since the assert fails to be executed.
I don't know the cause why assert fails in the 64bit version, I just compiled the library in the following way:
- 32bit:
./configure --build=i686-pc-linux-gnu CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=-m32
make
- 64bit:
./configure
make
I hope the information is useful to correct any bugs.
Regards.
(In reply to cictec from comment #4) > I don't know the cause why assert fails in the 64bit version, I just > compiled the library in the following way: We turn off assertions by default if optimizations are enabled in the build, and the configure script by default will turn _on_ optimizations. My guess is that building it with CFLAGS set for the 32-bit build overrides this, so you get no optimizations when building the library. Try this instead: ./configure --build=i686-pc-linux-gnu CFLAGS="-m32 -O3" CXXFLAGS=-m32 LDFLAGS=-m32 (added "-O3" to the CFLAGS) --ryan. Hi Ryan C. Gordon, Your guess is correct, adding -O3 the assert is not launched, I have corrected the program for SetWindowSize to be called later, thanks for the support. As a suggestion, it would be interesting to add options to cmake and make in order to generate 32bit and 64bit builds, it is very common and convenient especially in Linux to be able to build for multiple architectures and test them. For CMAKE you could indicate an option like: cmake -DSDL_BUILD_CPUARCH=32 .., this would allow you to create a 32bit build, if the value was 64 it would be created at 64bit, if you do not specify the option it would create the default SO (32 or 64bit that is), a similar option also for configure (make). Regards. Resolving this bug since the mystery was solved. I _think_ CMake can build for other CPU architectures with some magic incantation, like the configure's --build param, but I don't know it off the top of my head. I don't _think_ it needs any changes to SDL to do it, but I could be wrong. --ryan. |