Hi, I could use some help on this.
Some background first: Java was developed by Sun to compete on the
desktop with Windows. In particular Java was "write once run anywhere"
and it came with a GUI. Neither Java nor the GUI were very good, but
the appeal of a platform independent GUI was one of the main reasons
for Java’s success.
I am developing a “write once run anywhere” system too, but it is uses
a different technology. Instead of a VM and bytecode compiler, my
system generates C++ source which is then compiled down to
machine binary by your system C++ compiler. This should be faster,
and in particular, better for game development
Because I generate C++, bindings to C libraries are particularly
easy to create and usually involve mapping types but little or no
executable code (unlike, say, bindings in Python). Here’s an
example of a library of bindings … for SDL of course:
http://felix-lang.org/$/usr/local/lib/felix/felix-latest/share/lib/sdl
Before developing games I need some tools. In particular
a GUI would be useful. And of course it has to be platform
independent! So of course I’m trying to use SDL because
the aim of SDL is to provide a platform independent game
development environment.
http://felix-lang.org/$/usr/local/lib/felix/felix-latest/share/lib/gui
It’s a bit crude at the moment, but the methodology seems to
work up to a point:
http://felix-lang.org/$/usr/local/lib/felix/felix-latest/share/src/web/tutopt//sdlgui
But I have a problem. Tests gui_04_* on do event handling. When I resize a
window the program seems to work, unless the bounding rect of the stuff
I’m drawing is entirely outsize the window rect. That seems to crash my
program every time.
This is a clear indication of a bug in SDL because none of my code
knows anything about clipping etc… Indeed, examining some of the SDL
code and docs, it is not specified clearly what happens intersecting
non-intersecting rects and it is not clear that every drawing routine
in the whole of SDL correctly handles negative width or height.
SDL_IntersectRect DOES product a negative dimension if there
is no intersection, and this is set to a SDL_Surface clipping rectangle.
A lot of SDL code does not do any special checks for this.
In some cases it works anyhow. It’s hard to be sure.
Unfortunately I cannot experiment because I’m running OSX 10.6.8 and
can no longer compile SDL from source.
However here’s the quandary. I have tried to make a C program
doing roughly the same drawing operations crash with a resize
and it doesn’t.
Which is a strong indication SDL works and the bug is in my code
[And I’m sure I’m not the only SDL user about … :]
So now I have a contradiction.
Using gdb I find more than one of my programs crashes with
exactly the same single symbol on the stack, unfortunately
it has nothing to do with the problem. It’s not even a function.
The indication is corruption.
Using Valgrind, my program crashes, Valgrind crashes, the
iTerm terminal emulator crashes and my computer hangs.
A hardware reset is required.
The crash also occurs on Linux, so it isn’t OSX specific.
[Not surprising, since I’m using software rendering].
I am not asking for debugging help but thinking help!
Logically, the bug is in SDL because my code is entirely
independent of the context creating the crash, and the SDL C handling
this is very suspicious, but my C code designed to demonstrate
this fails to crash, indicating a corruption caused by my system
or my test code, bindings, or compiler. But the bindings and
test code work without resizing and the compiler compiles a
lot of other code and is fairly robust after 20+ years of development.–
john skaller
@john_skaller
http://felix-lang.org