Hi, I have a project going to make Racket bindings to the libhackrf C
library installed on my Debian 9 system. I have successfully made and
used bindings to around a dozen procedures in the library. However,
when I get to the first really important one, my call is crashing with
a SIGSEGV. I have this procedure defined:

(define-hackrf hackrf_start_rx (_fun (_cpointer 'hackrf_device)
                                     (_fun _pointer -> _int)
                                     _pointer -> _int))


This procedure takes a pointer to a device, a callback function, and
another pointer (which I won't go into but is supposed to be null
usually). Internally, hackrf_start_rx is a C procedure which generates
a pthread which repeatedly calls the callback function while receiving
data, while the original thread returns 0.

christopher@nightshade:~/Repos/hackrf-rkt$ racketWelcome to Racket
v6.7.> ,load hackrf.rkt> ,enter hackrf.rkt"hackrf.rkt"> transf-
cb#<procedure:transf-cb>"hackrf.rkt"> (hackrf-init)"hackrf.rkt">
(define h (hackrf-open))"hackrf.rkt">
h#<cpointer:hackrf_device>"hackrf.rkt"> (sensible-defaults
h)"hackrf.rkt"> (define cb (transf-cb))"hackrf.rkt">
cb#<procedure:...f-rkt/hackrf.rkt:257:2>"hackrf.rkt"> (trace-call
'hackrf_start_rx hackrf_start_rx h cb #f)>(hackrf_start_rx 
#<cpointer:hackrf_device>  #<procedure:...f-rkt/hackrf.rkt:257:2> 
#f)<00"hackrf.rkt"> SIGSEGV MAPERR si_code 1 fault on addr (nil)Aborted

I can't figure out how to debug this further because I don't know how
to get Racket to display the C backtrace, and I don't know how to get
Racket to run successfully in gdb. I'm thinking either (1) I'm somehow
passing in my callback function wrong, or (2) something about Racket is
incompatible with C library functions that use pthreads. You can see
that hackrf_start_rx is returning 0, so the SIGSEGV MAPERR must be
occurring in the still running thread, but I'm not sure what I can
conclude from that.

For the whole code see

git clone git://lavender.qlfiles.net/pub/git/hackrf-rkt.git
git checkout cf81011be6509da00b779881a5d388af399a4d2e


-- 
Christopher Howard
p: +1 (907) 374-0257
w: https://librehacker.com
xmpp: [email protected]
otr: E9685B53 01F038DD D29281C9 30FDA71E BD0095D4
gnupg: 23FD5CC5 (keys.gnupg.net)
radio: KL1TL
featured: http://www.foi.org

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/1561523686.14508.3.camel%40qlfiles.net.
For more options, visit https://groups.google.com/d/optout.

Reply via email to