FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Segmentation Fault in DerelictSDL
Goto page Previous  1, 2
 
Post new topic   Reply to topic     Forum Index -> Derelict
View previous topic :: View next topic  
Author Message
gfannes



Joined: 06 Oct 2009
Posts: 7
Location: Zoersel, Belgium

PostPosted: Tue Dec 14, 2010 1:21 pm    Post subject: Reply with quote

Mmh, sorry for the "if (false)", that's indeed quit confusing...

Here is a more polished test program and a Ruby script that I used to compile it. Maybe other people running linux can test this too, just download both files to one folder, adjust the first line of build.rb to point to your Derelict2 dir and run "ruby build.rb". This results in 5 different executables (Manual, DerelictUtil, DerelictSDL, DerelictUtilLib and DerelictSDLLib).

The test program contains 3 different ways of loading SDL: manually using dl, using DerelictUtil, and using DerelictSDL. The last two methods are tested twice, once for an executable built immediately from source files (also the relevant Derelict2 files), and once linking against the Derelict2 lib.

Only DerelictSDL and DerelictSDLLib segfault for me, the rest is fine.

I'm currently running dmd v2.049 running on Arch linux for which "uname -a" gives: "Linux ri 2.6.35-ARCH #1 SMP PREEMPT Sat Oct 30 19:57:05 UTC 2010 i686 Intel(R) Core(TM)2 CPU T7200 @ 2.00GHz GenuineIntel GNU/Linux".

I'll test it for dmd v2.050 and on a Linux Mint box and post the results.

Greetings,
Geert.
Back to top
View user's profile Send private message
marcode



Joined: 08 Jan 2011
Posts: 3

PostPosted: Sun Jan 09, 2011 11:34 am    Post subject: Reply with quote

Maybe this is originated by a compiler bug?

I have the same problem with DerelictSDL. I also have problems with DerelictSDLImage and DerelictFT.

To test the loading of DerelictFT, I wrote the following program:

Code:

extern (C)
{
    void *dlopen(const char *, int);
    void *dlsym(void *, const char *);
}

alias int  FT_Error;

struct FT_LibraryRec_;

alias FT_LibraryRec_* FT_Library;

void main()
{
FT_Library ftlibrary;
void* h = dlopen("libfreetype.so.6", 2 );
auto init = cast(FT_Error function(FT_Library*)) dlsym(h, "FT_Init_FreeType");
init( &ftlibrary );
}

which crashes if i compile it without optimization in dmd 2.051. However, if i use the -O switch it doesn't crash anymore.
Back to top
View user's profile Send private message
tbone



Joined: 05 Nov 2009
Posts: 19

PostPosted: Mon Jan 10, 2011 1:27 pm    Post subject: Reply with quote

Try *NOT* linking with --export-dynamic or -rdynamic
Back to top
View user's profile Send private message
marcode



Joined: 08 Jan 2011
Posts: 3

PostPosted: Mon Jan 10, 2011 3:22 pm    Post subject: Reply with quote

The same thing happens without them:

dmd testderelict.d -c
gcc testderelict.o -o testderelict -m32 -ldl -lphobos2 -lpthread
./testderelict
(segfault)
Back to top
View user's profile Send private message
tbone



Joined: 05 Nov 2009
Posts: 19

PostPosted: Mon Jan 10, 2011 3:35 pm    Post subject: Reply with quote

Might be something in dmd then, because it is working fine for me with gdc
Back to top
View user's profile Send private message
marcode



Joined: 08 Jan 2011
Posts: 3

PostPosted: Tue Jan 11, 2011 2:32 pm    Post subject: Reply with quote

Yes. gdc works for me too.
Back to top
View user's profile Send private message
tbone



Joined: 05 Nov 2009
Posts: 19

PostPosted: Tue Jan 11, 2011 3:18 pm    Post subject: Reply with quote

Now the same issue is popping up for me with certain compiler optimizations turned on.

Its the same issue, SFML trying to call the glXGetConfig() defined in my binary rather than the one that it's suppose to be linked to (maybe some link-time optimizations do this?)

Edit: Found it!

This time it was -fPIC causing the issue, which really is only needed for shared libraries anyway.

It's all because of the way Derelict does its runtime loading of libraries, it breaks many things with the compiler and linker because it defines the library symbols differently (as pointers to the symbols, and not as symbols themselves).
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Derelict All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group