On Wed, May 12, 2004 at 12:24:55AM +0400, Dmitry Samoyloff wrote: > On Tuesday 11 May 2004 21:47, Gregor Mückl wrote: > > On Monday 10 May 2004 22:53, Dmitry Samoyloff wrote: > > > Hi all, > > > > > > I want to implement the console commands in my game engine (to reload > > > scripts or maps on the fly, etc) and I'd like to use stdin for this > > > purpose to simplify the coding. So, I'm trying to read from stdin using > > > fgets() call (or the 'cin' object) in the program that uses libSDL's > > > event handling also and this always leads to a crash. Is it a known > > > conflict? Or maybe the problem is not libSDL? > > > > > > Regards, Dmitry Samoyloff > > > > Hi! > > > > Are you using SDL on a X display or on a text/framebuffer console? In the > > latter case SDL's keyboard handling might well interfere with standard > > stdin/stdout. In the former case the problem is more likely within your own > > code. But I haven't tried either myself yet, so I can't tell you for sure. > > Maybe you should try to get a stack backtrace to pinpoint the location of > > the crash. > > I'm using SDL with X. > > I ran my program in gdb several times and backtraces shows me that crashes > happens in two different places, but always in free() or malloc() calls > performed from different libs (Lua and OpenAL). This *only* happens if I'm > reading from stdin in my program's main loop, no matter where exactly :-( I'm > still trying to find out the reason of such strange behaviour... > segfaults in free() or malloc() are usually caused by freeing the same memory twice, or other misuses of the heap. If you set the MALLOC_CHECK_ environment variable to 1, it should print out diagnostics if it detects double frees or other problems. If you want to be able to debug problems in a debugger, setting MALLOC_CHECK_ to 2 causes libs to abort() whenever a malloc/free error occurs. Al -- Alistair Riddoch alriddoch@zepler.org http://www.zepler.org/~alriddoch/
Attachment:
pgp00000.pgp
Description: PGP signature