pi_piper
pi_piper copied to clipboard
pi_piper with gtk aborts ruby interpreter (RPi Raspbian Stretch)
program:
require 'gtk3'
require 'pi_piper'
win = Gtk::Window.new
win.window_position = :center
win.border_width = 5
win.signal_connect("destroy") { Gtk.main_quit }
pin = PiPiper::Pin.new(pin: 24, direction: :out)
win.show_all
Gtk.main
aborts with:
/var/lib/gems/2.3.0/gems/pi_piper-2.0.0/lib/pi_piper/platform.rb:11: [BUG] Segmentation fault at 0xe92d000e
ruby 2.3.3p222 (2016-11-21) [arm-linux-gnueabihf]
-- Control frame information -----------------------------------------------
c:0006 p:---- s:0020 e:000019 CFUNC :init
c:0005 p:0031 s:0017 e:000016 METHOD /var/lib/gems/2.3.0/gems/pi_piper-2.0.0/lib/pi_piper/platform.rb:11
c:0004 p:0254 s:0014 e:000013 METHOD /var/lib/gems/2.3.0/gems/pi_piper-2.0.0/lib/pi_piper/pin.rb:56 [FINISH]
c:0003 p:---- s:0010 e:000009 CFUNC :new
c:0002 p:0083 s:0006 E:001330 EVAL test_gtk.rb:12 [FINISH]
c:0001 p:0000 s:0002 E:000578 (none) [FINISH]
Tested on RPi 3B+ Raspbian Stretch. Works well on RPi 3B Raspbian Jessie
Any pointers?
[NOTE: this issue has been solved, pleaselook at the end]
ok, I was doing some testing... Program is three lines:
require 'gtk3'
require 'pi_piper/bcm2835'
PiPiper::Bcm2835.init
program versions:
ruby 2.3.3p222 (2016-11-21) [arm-linux-gnueabihf] gtk3-3.3.0 gem pi_piper-2.0.0 gem (with libbcm2835 1.49 library, see https://github.com/zsyed91/pi_piper)
hardware:
RPi 3B+ Raspbian Stretch
comments:
-This same program works well on RPi 3B (no plus) Raspbian Jessie
- if I comment require 'gtk3' it works
- if I comment PiPiper::Bcm2835.init it works
segfault log:
test_gtk.rb:15: [BUG] Segmentation fault at 0xe92d000e ruby 2.3.3p222 (2016-11-21) [arm-linux-gnueabihf]
-- Control frame information ----------------------------------------------- c:0003 p:---- s:0007 e:000006 CFUNC :init c:0002 p:0032 s:0004 E:001c70 EVAL test_gtk.rb:15 [FINISH] c:0001 p:0000 s:0002 E:001420 (none) [FINISH]
-- Ruby level backtrace information ----------------------------------------
test_gtk.rb:15:in <main>' test_gtk.rb:15:in init'
-- Other runtime information -----------------------------------------------
-
Loaded script: test_gtk.rb
-
Loaded features:
0 enumerator.so 1 thread.rb 2 rational.so 3 complex.so 4 /usr/lib/arm-linux-gnueabihf/ruby/2.3.0/enc/encdb.so 5 /usr/lib/arm-linux-gnueabihf/ruby/2.3.0/enc/trans/transdb.so 6 /usr/lib/ruby/2.3.0/unicode_normalize.rb 7 /usr/lib/arm-linux-gnueabihf/ruby/2.3.0/rbconfig.rb ... 143 /var/lib/gems/2.3.0/gems/ffi-1.9.25/lib/ffi/callback.rb 144 /var/lib/gems/2.3.0/gems/ffi-1.9.25/lib/ffi/io.rb 145 /var/lib/gems/2.3.0/gems/ffi-1.9.25/lib/ffi/autopointer.rb 146 /var/lib/gems/2.3.0/gems/ffi-1.9.25/lib/ffi/variadic.rb 147 /var/lib/gems/2.3.0/gems/ffi-1.9.25/lib/ffi/enum.rb 148 /var/lib/gems/2.3.0/gems/ffi-1.9.25/lib/ffi/ffi.rb 149 /var/lib/gems/2.3.0/gems/ffi-1.9.25/lib/ffi.rb 150 /var/lib/gems/2.3.0/gems/pi_piper-2.0.0/lib/pi_piper/bcm2835.rb
-
Process memory map:
00010000-00011000 r-xp 00000000 b3:02 147846 /usr/bin/ruby2.3 00020000-00021000 r--p 00000000 b3:02 147846 /usr/bin/ruby2.3 00021000-00022000 rw-p 00001000 b3:02 147846 /usr/bin/ruby2.3 01303000-01c01000 rw-p 00000000 00:00 0 [heap] 74fa1000-74fbe000 r-xp 00000000 b3:02 265396 /var/lib/gems/2.3.0/gems/ffi-1.9.25/lib/ffi_c.so ... 76f1b000-76f1c000 rw-p 00021000 b3:02 395 /lib/arm-linux-gnueabihf/ld-2.24.so 7e5c0000-7edbf000 rw-p 00000000 00:00 0 [stack] 7ef03000-7ef04000 r-xp 00000000 00:00 0 [sigpage] 7ef04000-7ef05000 r--p 00000000 00:00 0 [vvar] 7ef05000-7ef06000 r-xp 00000000 00:00 0 [vdso] ffff0000-ffff1000 r-xp 00000000 00:00 0 [vectors]
[NOTE] You may have encountered a bug in the Ruby interpreter or extension libraries. Bug reports are welcome. For details: http://www.ruby-lang.org/bugreport.html
[SOLVED]
In the end I've found the culprit...: neither gtk3, nor pi_piper..., but ruby interpreter ruby 2.3.3p222 (2016-11-21) [arm-linux-gnueabihf]
This is unfortunate because this ruby version is the one which gets installed with sudo apt-get install ruby on RPi Raspbian Stretch. Notice that Raspbian Jessie installs ruby 2.1 and the bug doesn't appear
Conclusion: using rvm with ruby 2.5 should be strongly recommended. You can close the ticket. Thanks for your attention