SDL_ttf bug causes segfault for weird reasons

N

nsm.nikhil

I'm writing a small game, and I've been getting an almost pathetic bug
with SDL.

I've written a small wrapper (textutil.h:rtTextUtil) to make rendering
easy.

Now if i call it from a class defined in a header file
(class.h:ClassGood), it works fine, but if i call it in a class
declared in a header file but defined in a .cpp (ClassBad) it
segfaults.

gdb reports the bug is in TTF, since it crashes on any TTF_* call.

I've put together a program just to demonstrate the bug.

http://fileurls.com/gojjhy

I would really appreciate it if someone could try it. To see what i
mean by not segfaulting on ClassGood, you could try uncommenting the
line (43) in main.cpp and commenting line 42.

Just so you know, I'm facing these bugs using g++, SDL 1.2 running on
linux.
 
J

Johannes Bauer

I would really appreciate it if someone could try it.

I did.

Did you notice that when it segfaults:

#0 0x00002b9724e84510 in TTF_FontHeight () from
/usr/lib/libSDL_ttf-2.0.so.0
#1 0x00000000004041f2 in rtTextUtil::render (text=0x404663 "From
ClassBad",
color={r = 255 '�', g = 0 '\0', b = 0 '\0', unused = 0 '\0'}, font=0x0,
dest=0x629870, x=30, y=560, align=0, bold=false, italic=false,
yPadding=5)
at textutil.h:135

That "font", which you're passing to TTF_FontHeight, is a NULL pointer?

I'd segfault too if I was a TTF rendering lib.

Greetings,
Johannes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top