| Summary: | Crash with SDL_WaitEvent() on Mac OS X 10.3 | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Soltic Lucas <spootnikdev> |
| Component: | events | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | critical | ||
| Priority: | P2 | ||
| Version: | 1.2.12 | ||
| Hardware: | PowerPC | ||
| OS: | Mac OS X 10.3 (PPC) | ||
Actually, SDL_WaitEvent() doesn't seem to be the problem. I got it using SDL_PollEvent() too, but with very simple programs, it doesn't crash (even using SDL_PollEvent()). I'm now looking for what the problem could be. Here is a very sample code to reproduce the crash :
// code start
#include <stdlib.h>
#include <stdio.h>
#include <SDL.h>
#include <OpenGL/gl.h>
#define LARGEUR 640
#define HAUTEUR 480
#define FPS 24
static SDL_Surface *ecran = NULL;
void init (void)
{
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
printf("Couldn't initialize SDL: %s\n", SDL_GetError());
exit(1);
}
ecran = SDL_SetVideoMode(LARGEUR, HAUTEUR, 32, SDL_OPENGL);
if (ecran == NULL) {
puts("*** error while creating window");
exit(1);
}
}
void draw (void)
{
glClear(GL_COLOR_BUFFER_BIT);
glFlush();
}
void loop (void)
{
SDL_Event event;
int continuer = 1;
int delay = 1000/FPS;
int thenTicks = -1;
int nowTicks;
while (continuer) {
SDL_PollEvent(&event);
switch(event.type) {
case SDL_QUIT:
continuer = 0;
break;
case SDL_KEYDOWN:
switch(event.key.keysym.sym) {
case SDLK_ESCAPE:
continuer = 0;
break;
default:
break;
}
break;
}
draw();
SDL_GL_SwapBuffers();
if (thenTicks > 0) {
nowTicks = SDL_GetTicks();
delay += (1000/FPS - (nowTicks - thenTicks));
thenTicks = nowTicks;
if (delay < 0)
delay = 1000/FPS;
} else {
thenTicks = SDL_GetTicks ();
}
}
}
int main (int argc, char **argv) {
init();
loop();
SDL_Quit();
return 0;
}
// code end
gcc -o exec code.c -Wall `sdl-config --cflags --libs` -framework OpenGL
There is still a segfault.
This may be fixed with SDL from subversion: http://www.libsdl.org/svn.php Can you try this and let us know? I compiled the sources via subversion (SDL 1.2) and it now works ! |
I'm running Mac OS X 10.3 and there seems to be a problem with SDL_WaitEvent(), it happens just after I can see the main window (completely drawn). When using GDB I get this : "Program received signal EXC_BAD_ACCESS, Could not access memory. QZ_IsMouseInWindow (this=0x0) at src/video/quartz/SDL_QuartzWM.m:109 109 src/video/quartz/SDL_QuartzWM.m: No such file or directory. in src/video/quartz/SDL_QuartzWM.m" It is not the first time I get this problem, and I'm used to use SDL_PollEvent(). But I can't try other people sample programs due to this bug. Here is a test program that crashes : http://baptistecutajar.free.fr/Up/v1.0%20Cube.rar It is the one I compiled and tried, after removing each line using FMOD, as it doesn't work for me. To compile the test program I used : gcc -o exec -Wall main.c `sdl-config --cflags --libs` -lSDL_ttf sdl-config --cflags --libs returns this : -I/usr/local/include/SDL -D_GNU_SOURCE=1 -D_THREAD_SAFE -L/usr/local/lib -lSDLmain -lSDL -Wl,-framework,Cocoa /Developer/SDKs/MacOSX10.2.8.sdk/System/Library/Frameworks/QuickTime.framework/QuickTime -bind_at_load Actually you can notice I linked the executable against the QuickTime framework from the Mac OS X 10.2.8 SDK. I did this to avoid a problem of undefined symbol : "_HIPointConvert referenced from QuickTime expected to be defined in Carbon". I couldn't get anymore information using the Xcode 1.5 debugger interface. Note: the libSDL I'm using is the one I compiled myself. I hope it will help you. Lucas