Strange Error

I am developing a game on a GNU/Linux box and I got this problem: when
the game starts, on the menu text rendering function
(TTF_RenderText_Blended), the program stops and I get the message “Fatal
signal: Segmentation Fault (SDL Parachute Deployed)”, but the window
remais open, and when I kill it through the WM, the window closes but
the process remains, the terminal is not freed.
On gdb I get:

36 rendered = TTF_RenderText_Blended(font, text_str, fg);
(gdb) next

Program received signal SIGSEGV, Segmentation fault.
0x4038c89e in _int_malloc () from /lib/libc.so.6
(gdb) next
Single stepping until exit from function _int_malloc,
which has no line number information.
Fatal signal: Segmentation Fault (SDL Parachute Deployed)
[Thread 16386 (LWP 2700) exited]

Any idea?

Thanks.–
Lucas Clemente Vella
@Lucas_Clemente_Vella

Most probably the font failed to open with TTF_OpenFont
http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fttf_2fFunctions_2fManagement_2fTTF_5fOpenFont.
See that the font is there, check for a NULL result for TTF_OpenFont and
use TTF_GetError() to see why it fails if it returns NULL.

Lucas Clemente Vella wrote:> 36 rendered = TTF_RenderText_Blended(font, text_str, fg);

(gdb) next

Program received signal SIGSEGV, Segmentation fault.

Uplink wrote:

Most probably the font failed to open with TTF_OpenFont
http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fttf_2fFunctions_2fManagement_2fTTF_5fOpenFont.
See that the font is there, check for a NULL result for TTF_OpenFont and
use TTF_GetError() to see why it fails if it returns NULL.

No, it is not NULL.–
Lucas Clemente Vella
@Lucas_Clemente_Vella

Then do
print font
print text_str
in gdb before you do next and see what the values are

Lucas Clemente Vella wrote:>

Most probably the font failed to open with TTF_OpenFont
http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fttf_2fFunctions_2fManagement_2fTTF_5fOpenFont.
See that the font is there, check for a NULL result for TTF_OpenFont
and use TTF_GetError() to see why it fails if it returns NULL.

No, it is not NULL.

Just memory address:

36 rendered = TTF_RenderText_Blended(font, text_str, fg);
(gdb) print text_str
$1 = 0x804c650 “Exit”
(gdb) print font
$2 = (TTF_Font *) 0x80b5fc8
(gdb) next

Program received signal SIGSEGV, Segmentation fault.
0x4038c89e in _int_malloc () from /lib/libc.so.6
(gdb) next
Single stepping until exit from function _int_malloc,
which has no line number information.
Fatal signal: Segmentation Fault (SDL Parachute Deployed)
[Thread 16386 (LWP 12074) exited]

Uplink wrote:> Then do

print font
print text_str
in gdb before you do next and see what the values are


Lucas Clemente Vella
@Lucas_Clemente_Vella

Hmm… Don’t what could be causing it. Everything looks ok to me.

What looks weird is that it SIGSEGVs in… malloc?

Can you post a small program that only opens the font and tryes to
render the text and crashes at that point and also attach the font file
you’re using so maybe someone can reproduce the problem?

Something like:

int main()
{
SDL_Surface * Rendered_Text;
SDL_Color Color;
TTF_Font * Font;

SDL_Init(SDL_INIT_VIDEO);
atexit(SDL_Quit);
TTF_Init();
atexit(TTF_Quit);

Font = TTF_OpenFont("font.ttf", 24);
Color = (SDL_Color) {r:255, g:255, b:255};
Rendered_Text = TTF_RendeText_Blended(Font, "Rendered text", Color);

printf("Got here in one piece\n");
return 0;

}

Lucas Clemente Vella wrote:> Just memory address:

36 rendered = TTF_RenderText_Blended(font, text_str, fg);
(gdb) print text_str
$1 = 0x804c650 “Exit”
(gdb) print font
$2 = (TTF_Font *) 0x80b5fc8
(gdb) next

Program received signal SIGSEGV, Segmentation fault.
0x4038c89e in _int_malloc () from /lib/libc.so.6

This is the most strange: the program once worked, but when I organized
the menu system into classes it stopped working. I did not find the
problem. It was working when it was not divided.

Uplink wrote:> Can you post a small program that only opens the font and tryes to

render the text and crashes at that point and also attach the font file
you’re using so maybe someone can reproduce the problem?


Lucas Clemente Vella
@Lucas_Clemente_Vella

Ok, I did not understand what happened, but when I removed some unused
members variables from a distant class on the classes hierarchy, it
worked. I is still strange, but worked at least.

Lucas Clemente Vella wrote:> I am developing a game on a GNU/Linux box and I got this problem: when

the game starts, on the menu text rendering function
(TTF_RenderText_Blended), the program stops and I get the message “Fatal
signal: Segmentation Fault (SDL Parachute Deployed)”, but the window
remais open, and when I kill it through the WM, the window closes but
the process remains, the terminal is not freed.
On gdb I get:

36 rendered = TTF_RenderText_Blended(font, text_str, fg);
(gdb) next

Program received signal SIGSEGV, Segmentation fault.
0x4038c89e in _int_malloc () from /lib/libc.so.6
(gdb) next
Single stepping until exit from function _int_malloc,
which has no line number information.
Fatal signal: Segmentation Fault (SDL Parachute Deployed)
[Thread 16386 (LWP 2700) exited]

Any idea?

Thanks.


Lucas Clemente Vella
@Lucas_Clemente_Vella

I am developing a game on a GNU/Linux box and I got
this problem: when
the game starts, on the menu text rendering function

(TTF_RenderText_Blended), the program stops and I
get the message “Fatal
signal: Segmentation Fault (SDL Parachute
Deployed)”, but the window
remais open, and when I kill it through the WM, the
window closes but
the process remains, the terminal is not freed.

If everything else fails, I vaguely remember a comment
in the SDL_ttf source about a bug that caused random
segfaults when using TTF_STYLE_UNDERLINE. I am not
able to find it in the source anymore, and it could
very well be a wrong synaptic link in my brain or that
the problem has already been solved.

Claudio=====

Claudio Fontana - contacts
web: cmdftp.sourceforge.net/cfontana/
general purpose: sick_soul at yahoo d0t it
free sw development: sick_soul at users dOt sourceforge d0t net
university: claudio.fontana at studenti d0t unitn d0t it
itc/irst: cfontana at itc d0t it


Nuovo Yahoo! Messenger: E’ molto pi? divertente: Audibles, Avatar, Webcam, Giochi, Rubrica
Scaricalo ora!
http://it.messenger.yahoo.it

Uplink wrote:

Hmm… Don’t what could be causing it. Everything looks ok to me.

What looks weird is that it SIGSEGVs in… malloc?

Usually the result of either a double free, or freeing an invalid pointer.

Stephane

You can also get a seg fault in malloc by writing out of bounds to previously
malloced memory. Doing so will step on malloc’s housekeeping information.

JeffOn Monday 18 October 2004 10:28 am, Stephane Marchesin wrote:

Uplink wrote:

What looks weird is that it SIGSEGVs in… malloc?

Usually the result of either a double free, or freeing an invalid pointer.