Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

scrottie (4167)

scrottie
  scott@slowass.net
http://slowass.net/

My email address is scott@slowass.net. Spam me harder! *moan*

Journal of scrottie (4167)

Thursday November 13, 2008
07:06 PM

Coro and SDL

[ #37872 ]
SDL loves to suck in pthread, then as soon as Perl hits a Perl_safemalloc call, it coredumps. Apparently pthread does some magic that replaces malloc() with an evil twin that likes to die and take you with it.

#0  0x402ba038 in pthread_getspecific () from /lib/libpthread.so.0
#1  0x0809e795 in Perl_safesysmalloc ()
#2  0x40551b19 in pe_sys_multiplex () from /home/knoppix/lib/perl5/site_perl/5.8
.8/i686-linux/auto/Event/Event.so

gdb stacktrace.

Even building SDL with --enable-threads=no --enable-pthreads=no isn't enough. It'll just you you with a libSDL.so with dangling references to the pthreads librarty, that SDL_Perl won't be able to link to and the other SDL libs won't be able to build against. Joy of joys. I love it when something doesn't work, so you do the obvious thing, but that doesn't work, so you go to fix that... fucking yak shaving.

The most important SDL APIs on Unix have ifdefs to work without threads, but some just plain don't. You need to disable them:

./configure --enable-threads=no --enable-pthreads=no --enable-audio=no --enable-timers=no

I did a --prefix=/usr also but you probably want to keep the default of /usr/local and then build other stuff explicitly against that so you don't piss apt off and never get another system update again. Speaking of broken ass shit...

Then go get SDL_ttf-2.0.9.tar.gz and SDL_image-1.2.6.tar.gz and rebuild those. Make sure they're finding (use --includedir and --libdir) and using your hobbled libSDL.so, whereever you installed it. They should find the sdl-config command and use it to pick up on the lack of -lpthread. Build and install those.

SDL_Perl uses one of those new build systems that don't work right on Linux and don't have a chance in hell of working on anything else. There are a dozen build bug reports on rt.cpan.org for the thing, and I added a new one: it installs the XS .so files in ~usr/lib/perl5/site_perl/5.*.*/i686-linux/auto/src/SDL and SDL_Perl, adding a superfluous "/src" that keeps it from being found. You'll have to cd into your Perl's lib directory, find those two SDL directories, and copy them up a level, if you have this same problem. And remember kids, writing build systems is hard, so just fuckin' use MakeMaker and spare us all the grief.

But first you need to edit Build.PL and pull out mention of SDL_mixer, SDL_net, and SDL_timer -- the same modules we removed support for in the ./configure in the SDL source. So, if you can get it to go, build SDL_Perl:

perl Build.PL
./Build
./Build install

Then go fix the miss-installed .so files... then maybe, with some luck and probably about a dozen other "how to make this crap work right" tutorials like this one, you'll have an SDL that doesn't try to bloody pull in libpthread and make your Perl blow up! Yay!

-scott

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • That's interesting. Not long ago, someone showed [mongueurs.net] how, with a little help from SDL, Perl can be a suitable platform on which to develop a commercial-quality game [frozen-bubble.org]. I wonder whether the trouble with SDL's thread support [perl.org] means that this combination falls short of its promise; indeed, I can imagine games so demanding that this issue would be a show-stopper. But what kind of application are you writing that would cost you this kind of grief? And what did the SDL maintainers have to say about what you found?
    • Hey. Out of some mix of (false?) modesty and other factors, I don't like to talk about what I actually do. Usually I have more room to talk about stuff but in this case, it's kind of a three way and one of the parties is shy. But if you really care, telnet to weehours.net 2000 and ask for me. Obviously I'm not going to let anyone's cat out of the bag, but I can give some background. If you care, that is.

      SDL works okay as far as I know. For about anything, you can ignore the fact that SDL sucks in thre