473,805 Members | 2,023 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SDL_ttf bug causes segfault for weird reasons

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:rtT extUtil) to make rendering
easy.

Now if i call it from a class defined in a header file
(class.h:ClassG ood), 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.
Dec 3 '07 #1
1 1905
ns********@gmai l.com schrieb:
I would really appreciate it if someone could try it.
I did.

Did you notice that when it segfaults:

#0 0x00002b9724e84 510 in TTF_FontHeight () from
/usr/lib/libSDL_ttf-2.0.so.0
#1 0x0000000000404 1f2 in rtTextUtil::ren der (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

--
"Viele der Theorien der Mathematiker sind falsch und klar
Gotteslästerli ch. Ich vermute, dass diese falschen Theorien genau
deshalb so geliebt werden." -- Prophet und Visionär Hans Joss aka
HJP in de.sci.mathemat ik <47************ **********@news .sunrise.ch>
Dec 4 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

162
6746
by: Richard Heathfield | last post by:
I found something interesting on the Web today, purely by chance. It would be funny if it weren't so sad. Or sad if it weren't so funny. I'm not sure which. http://www.developerdotstar.com/community/node/291 This "teacher of C" demonstrates his prowess with a masterful display of incompetence in a 200-line program that travels as swiftly as possible to Segfault City.
12
2849
by: comp.lang.php | last post by:
index.php: // STUFF // STEP 1: imagecreatetruecolor ONLY IF GD 2.0+ SUPPORTED AND FOUND if ($this->isSuccessful && !$hasMogrified && $image && !$newImage && function_exists('imagecreatetruecolor') && preg_match('/2\.0/i', $this->gd_info_array)) { $newImage = @imagecreatetruecolor($configArray, $configArray);
3
2310
by: kj | last post by:
I am trying to diagnose a bug in my code, but I can't understand what's going on. I've narrowed things down to this: I have a function, say foo, whose signature looks something like: int foo( int w, int x, int y, int z, my_struct **results ) During its execution, foo initializes *results using calloc: ( *results ) = calloc( w+1, sizeof( my_struct ) );
0
1434
by: nirnimesh | last post by:
I'm intercepting a library function call using LD_PRELOAD and in-turn calling the orignial library function. Essentially, intercept.cc: void (*real_func)(void) = (void (*) (void)) dlsym(RTLD_NEXT, "_mangled_name_of_func_"); real_func(); //! Calling the original function -- SEGFAULT This is compiled as: g++ -shared -fPIC -Wall -o libintercept.so intercept.cc -ldl
8
3209
by: nobrow | last post by:
Okay ... Im out of practice. Is it not possible to have a 2D array where each column is of a different type, say an int and a struct*? The following seg faults for me and I cant figure out what I need to change. Thanks. #include <malloc.h> #include <string.h>
41
2098
by: SkyBlue | last post by:
Hi, can someone explain why the following simple C code segfaulted? I've stared it for 30mins but couldn't find the problem. Thx in advance #include <stdio.h> int main() { char *one; char *two;
10
533
by: danielesalatti | last post by:
Hello!! I'm studying c++ and I'm trying to get a little piece of code working, but I'm getting a segfault with strlen here: void tabhash::set (url *U) { uint hash = U->hashCode(); char* url = U->giveUrl(); char* chash = (char*)hash; char* Insert1="INSERT INTO sep_hashtable VALUES (";
49
1738
by: comp.lang.php | last post by:
/** * Class for grayscaling image * * @author Phil Powell * @version 1.2.1 * @package IMAGE_CATALOG::IMAGE */ class ImageGrayscaleGenerator extends ImageResizeComponents { /
2
1295
by: aviraldg | last post by:
I'm having a SEGFAULT on the following program. Weird thing is that it happens randomly with different "str"s (ie. user input; check main() for more info) and my debugger shows me that the getToken function is working and returning the correct answer. #include <stdio.h> #include <string.h> #include <ctype.h> char* getToken(char *src, unsigned int pos=0) { char *token=new char; unsigned int i=0;
0
9716
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10604
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10356
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9179
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7644
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6874
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5536
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3839
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.