SDL + OpenGL Crashes on exit with electric fence

When using electric fence on Linux, using SDL with OpenGL causes a crash. Here’s the code of a reproducible test I wrote:

Code:

#include <GL/gl.h>
#include <SDL.h>

int main() {
if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK) < 0) {
return -1;
}

if(SDL_SetVideoMode(1024,768,0,SDL_OPENGL) == NULL) {
	return -1;
}

SDL_Quit();

}

This can be compiled like this to link with electric fence:

Code:

g++ -g ef-test.cpp sdl-config --cflags sdl-config --libs -lefence -o ef-test

And then the environment variable EF_ALLOW_MALLOC_0 set to 1 before running to allow malloc(0) to work, when run, the program crashes on exit.

Does anybody have any ideas why this is? This is a minimal reproducible case from a much larger program I’m working on which sometimes crashes on exit.

Any help would be appreciated.

David

Did you run it in a debugger? I think that’s the appropriate way to use
Electric Fence. If there’s a memory error, then it is supposed to crash
(with a segfault).

Jonny DOn Mon, Nov 23, 2009 at 2:43 PM, Sirp wrote:

When using electric fence on Linux, using SDL with OpenGL causes a crash.
Here’s the code of a reproducible test I wrote:

Code:

#include
#include

int main() {
if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK) < 0) {
return -1;
}

if(SDL_SetVideoMode(1024,768,0,SDL_OPENGL) == NULL) {
return -1;
}

SDL_Quit();
}

This can be compiled like this to link with electric fence:

Code:

g++ -g ef-test.cpp sdl-config --cflags sdl-config --libs -lefence -o
ef-test

And then the environment variable EF_ALLOW_MALLOC_0 set to 1 before running
to allow malloc(0) to work, when run, the program crashes on exit.

Does anybody have any ideas why this is? This is a minimal reproducible
case from a much larger program I’m working on which sometimes crashes on
exit.

Any help would be appreciated.

David


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Also, what version of SDL were you using? If you were using SDL 1.2, does
it also happen with SDL 1.3?

Thanks!On Tue, Nov 24, 2009 at 8:13 AM, Jonathan Dearborn wrote:

Did you run it in a debugger? I think that’s the appropriate way to use
Electric Fence. If there’s a memory error, then it is supposed to crash
(with a segfault).

Jonny D

On Mon, Nov 23, 2009 at 2:43 PM, Sirp wrote:

When using electric fence on Linux, using SDL with OpenGL causes a
crash. Here’s the code of a reproducible test I wrote:

Code:

#include
#include

int main() {
if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK) < 0) {
return -1;
}

if(SDL_SetVideoMode(1024,768,0,SDL_OPENGL) == NULL) {
return -1;
}

SDL_Quit();
}

This can be compiled like this to link with electric fence:

Code:

g++ -g ef-test.cpp sdl-config --cflags sdl-config --libs -lefence -o
ef-test

And then the environment variable EF_ALLOW_MALLOC_0 set to 1 before
running to allow malloc(0) to work, when run, the program crashes on exit.

Does anybody have any ideas why this is? This is a minimal reproducible
case from a much larger program I’m working on which sometimes crashes on
exit.

Any help would be appreciated.

David


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


-Sam Lantinga, Founder and President, Galaxy Gameworks LLC