[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: SDL vs stdin?



On Wed, 12 May 2004, 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...

You might want to run your app using valgrind to rule out some silly
memory corruption bug in your memory handling.

-- 
  Om began to feel the acute depression that steals over every realist
       in the presence of an optimist.
                                        -- Terry Pratchett, Small Gods