Derelict SDL segfaulting on ubuntu?

Robly18 via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Mar 21 12:26:47 PDT 2017


On Tuesday, 21 March 2017 at 14:21:30 UTC, Mike Parker wrote:
> On Tuesday, 21 March 2017 at 12:31:41 UTC, Robly18 wrote:
>
>> Two days of fix attempt laters, here I am. I tried 
>> reinstalling and recompiling SDL from source (since the 
>> version from apt-get was only 2.0.4 and the one Derelict uses 
>> seems to be 2.0.5), and it continues segfaulting at seemingly 
>> random places.
>
> Mismatched versions wouldn't be causing a segfault out of the 
> box. You'd be getting exceptions instead. The only way Derelict 
> would be the cause of the segfault is if one of the function 
> pointers is null or one of the function declarations has the 
> wrong signature.

Oh! Right, I forgot to mention that, my bad. The earliest errors 
were, as you said, mismatched version exceptions. However, to fix 
them, what I did was, at first, do the 2,0,2 version thing you 
said. Later, however, I decided to compile SDL 2.0.5 myself, and 
I believe the exceptions stopped occurring. The segfaults, 
however, did not.


> Looking over your code, I see you aren't doing any error 
> checking. Validate all of your return values and call 
> SDL_GetError when one of them shows an error (in SDL, that's 
> either null or a number < 0, depending on the function). Add 
> some asserts or debug code to check the state of the pointers 
> you're passing to SDL functions. Given that the program works 
> elsewhere, I wouldn't expect this to show the issue, but it's 
> still something you should be doing anyway.

Just filled my code with asserts, and nothing. That doesn't seem 
to be it.

You said something about null function pointers... Is this 
something I should be checking for? I know when I did the version 
downgrade I got dub complaining about some undefined functions, 
but should I be on the lookout for more?

Thanks in advance.


More information about the Digitalmars-d-learn mailing list