Not logged inGosu Forums
Forum back to Help Search Register Login
Up Topic Gosu / Gosu Exchange / Gosu::Sample => segfault
- - By Jscher Date 2011-02-03 10:02

I'm new both to Ruby and Gosu. I tried to make my first game, following the tutorial. But as soon as I add this line to my code :
@beep =, "media/Beep.wav")

I get a seg fault. What could have gone wrong ? Should I open a ticket on google code ?
Here is the stack trace :

/dev/dsp: No such file or directory
/var/lib/gems/1.9.1/gems/gosu-0.7.27/lib/gosu/patches.rb:28: [BUG] Segmentation fault
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux]

-- control frame ----------
c:0013 p:---- s:0040 b:0040 l:000039 d:000039 CFUNC  :initialize
c:0012 p:0049 s:0036 b:0036 l:000035 d:000035 METHOD /var/lib/gems/1.9.1/gems/gosu-0.7.27/lib/gosu/patches.rb:28
c:0011 p:---- s:0032 b:0032 l:000031 d:000031 FINISH
c:0010 p:---- s:0030 b:0030 l:000029 d:000029 CFUNC  :new
c:0009 p:0049 s:0025 b:0025 l:000024 d:000024 METHOD /home/jo/Aptana RadRails Workspace/FirstTest/player.rb:5
c:0008 p:---- s:0021 b:0021 l:000020 d:000020 FINISH
c:0007 p:---- s:0019 b:0019 l:000018 d:000018 CFUNC  :new
c:0006 p:0070 s:0015 b:0015 l:000014 d:000014 METHOD /home/jo/Aptana RadRails Workspace/FirstTest/game_window.rb:7
c:0005 p:---- s:0012 b:0012 l:000011 d:000011 FINISH
c:0004 p:---- s:0010 b:0010 l:000009 d:000009 CFUNC  :new
c:0003 p:0087 s:0007 b:0007 l:0004f8 d:000550 EVAL   main.rb:9
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
c:0001 p:0000 s:0002 b:0002 l:0004f8 d:0004f8 TOP  
-- Ruby level backtrace information ----------------------------------------
main.rb:9:in <main>'
/home/jo/Aptana RadRails Workspace/FirstTest/game_window.rb:7:in initialize'
/home/jo/Aptana RadRails Workspace/FirstTest/game_window.rb:7:in
/home/jo/Aptana RadRails Workspace/FirstTest/player.rb:5:in initialize'
/home/jo/Aptana RadRails Workspace/FirstTest/player.rb:5:in
/var/lib/gems/1.9.1/gems/gosu-0.7.27/lib/gosu/patches.rb:28:in initialize'

-- C level backtrace information -------------------------------------------
/usr/lib/ [0x7fecff66be8f]
/usr/lib/ [0x7fecff576a56]
/usr/lib/ [0x7fecff576bc3]
/usr/lib/ [0x7fecff60bde5]
/lib/ [0x7fecff310b40]
/usr/lib/ [0x7fecfaba4224]
/var/lib/gems/1.9.1/gems/gosu-0.7.27/lib/ [0x7fecfd938e26]
/var/lib/gems/1.9.1/gems/gosu-0.7.27/lib/ [0x7fecfd939a55]
/var/lib/gems/1.9.1/gems/gosu-0.7.27/lib/ [0x7fecfd922eaf]
/usr/lib/ [0x7fecff665258]
/usr/lib/ [0x7fecff65d410]
/usr/lib/ [0x7fecff661e31]
/usr/lib/ [0x7fecff66411f]
/usr/lib/ [0x7fecff5b7e20]
/usr/lib/ [0x7fecff665258]
/usr/lib/ [0x7fecff65d410]
/usr/lib/ [0x7fecff661e31]
/usr/lib/ [0x7fecff66411f]
/usr/lib/ [0x7fecff5b7e20]
/usr/lib/ [0x7fecff665258]
/usr/lib/ [0x7fecff65d410]
/usr/lib/ [0x7fecff661e31]
/usr/lib/ [0x7fecff66411f]
/usr/lib/ [0x7fecff5b7e20]
/usr/lib/ [0x7fecff665258]
/usr/lib/ [0x7fecff65d410]
/usr/lib/ [0x7fecff661e31]
/usr/lib/ [0x7fecff662082]
/usr/lib/ [0x7fecff579d52]
/usr/lib/ [0x7fecff579d7d]
/usr/lib/ [0x7fecff57b63e]
/usr/bin/ruby1.9.1(main+0x4b) [0x40092b]
/lib/ [0x7fecfe6d4d8e]
/usr/bin/ruby1.9.1() [0x400819]

You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details:
Parent - - By jlnr (dev) Date 2011-02-03 10:14
You get a SEGFAULT due to this bug/incompatibility in Gosu on Linux:

It's actually supposed to be an exception, telling you that you have no sound card, as indicated by the debug output: "/dev/dsp: No such file or directory"

Does the previous version of the Gosu gem work for you?

To be honest it didn't work in my Ubuntu VM either, but then it's a VM and I have no sound at all. So, no idea how to debug this kind of stuff.

There is an outdated list of other libaudiere users here:

If you can find any of these games (and they still use audiere), it would be interesting to know it works for them.
Parent - - By Jscher Date 2011-02-03 10:49

> It's actually supposed to be an exception, telling you that you have no sound card, as indicated by the debug output

It is very strange : the Gnome video player can actually play sounds.

Looking on Internet, I found this workaround : I use "padsp ruby1.9.1 main.rb".

man padsp :
padsp starts the specified program and redirects its access to OSS compatible audio devices (/dev/dsp and auxiliary devices) to a  PulseAudio sound server.

With this command, the sound is actually played.
Do you think that my issue comes from a misconfiguration of my linux ? I installed it only a few days ago...

> If you can find any of these games (and they still use audiere), it would be interesting to know it works for them.

They are all either not downloadable, or windows only :(
Parent - - By jlnr (dev) Date 2011-02-04 02:31
Hmm, I think this just means that Ubuntu doesn't provide an OSS compatible audio device anymore; I'll see if I can tell audiere to use a different backend, and re-release ASAP :)

The previous version of Gosu (sudo gem uninstall gosu; sudo gem install gosu --version '= 0.7.26') might work until then, it used SDL_mixer. Sorry for the trouble!
Parent - - By AmIMeYet Date 2011-02-05 12:07
I would just like to confirm I have the same problem (on Ubuntu 10.10, PulseAudio). Only mine isn't a segfault, I get a proper exception:
/dev/dsp: No such file or directory
/home/#/.rvm/gems/ruby-1.9.2-p0/gems/gosu-0.7.27/lib/gosu/patches.rb:28:in `initialize': Could not initialize audiere or library not found (RuntimeError)

padsp worked for me as well, although the sound quality is terrible, and I actually had Tutorial.rb freeze up on me a lot. Ending the process had no effect. Only killing it did.

As far as I can tell, there really is no way to tell Audiere what backend to use.
Parent - - By 1ntegral Date 2011-02-05 20:40

padsp gives a segfault for me. How are u using it?  I'm running Ubuntu 10.10 as well.
Parent - By AmIMeYet Date 2011-02-05 22:35
I use it like this:
padsp ruby Tutorial.rb

Maybe you should try using this instead, to see if you can get some debug output:
padsp -d ruby Tutorial.rb
Parent - - By RavensKrag Date 2011-02-05 20:48
Hmm... interesting, I unfortunately have to say that I get the segfault instead.
Parent - By jlnr (dev) Date 2011-02-06 05:08
Whether you get a segfault or an exception depends on a lot of things. An apparently common cause is that your gl driver might link to an older version of libstdc++ so that Gosu's attempt to use "__cxx_exception_alloc" (or whatever it's called) causes the segfault. For a workaround see the link from
Parent - By jlnr (dev) Date 2011-02-06 05:26
padsp is already going into the right direction :)

I just wasted a whole day trying to fix the problem as a Linux outsider. My "insight":

audiere uses OSS, for which emulation is disabled by default. You can turn on emulation (powered by ALSA) by running "aoss ruby Tutorial.rb", but it sucks to tell everybody to do that.
You can do " ruby Tutorial.rb" (which is what 'aoss' does), that also kinda worked for me, but apparently there is no way to do the same thing at compile time.

Then, the wiki gods proceed to tell me that "some" installations of Ubuntu may use PulseAudio, and aoss "might not" work anyway, and I'd need to use padsp in that case, and apparently there is not even a library that will do the same thing. And even if there were, how would I come up with a "PulseAudio installation" and an "ALSA installation" of Linux to test stuff? ...

When I have time for Gosu again next week, I'll probably just revert the Linux port to SDL_mixer even though it has less features.
Parent - - By jlnr (dev) Date 2011-02-07 09:03
Fixed this by reverting to SDL_mixer.

There's an inofficial SDL backend for audiere on the webz, just like SDL_mixer uses SDL as its backend. Makes me wish I had time to fork audiere onto github, apply that patch and use this combination for Gosu; with the possible option of adding a proper OpenAL backend later. But then again, it's annoying LGPL :(
Parent - - By RavensKrag Date 2011-02-11 07:23

> But then again, it's annoying LGPL :(

As opposed to GPL? I thought LGPL was less restrictive?
Parent - - By jlnr (dev) Date 2011-02-11 13:08
Depends, LGPL allows you to dynamically link to an LGPL library from your program. When you have no dynamic linker available (iOS) LGPL and LGPL are effectively the same. Even when you have a dynamic linker, not being able to link it all into one big binary just for licensing reasons is annoying. MIT/BSD ftw :)
Parent - - By erisdiscord Date 2011-02-11 15:52
On which subject: If I ever release something under [L]GPL that you think would be useful, just ask and I'm willing to make an exception for you. Consider it fair is fair for making this great library for your commercial game available under a permissive license.

I suppose it's kind of a useless offer since I've been leaning towards BSD-style licenses myself, but I do feel that LGPL is sometimes appropriate. A static-linking-is-ok-too version of LGPL would be really nice since all I really care about is ensuring that any improvements to my code come back to me.
Parent - By jlnr (dev) Date 2011-02-12 06:37
Hehe thanks!

Well, I see it as some kind of DRM for code. I agree with the intentions, but between trusting the programmer and forcing them to do the good things with handcuffs, I think the LGPL has made the wrong choice. I guess it's more reasonable in a secretive, commercially interesting environment. (Of course, Gosu 1.0 is going to be just that!!1) :)
Up Topic Gosu / Gosu Exchange / Gosu::Sample => segfault

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill