Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Question re: otherlibs/systhread/posix.c
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: annan@h...
Subject: [Caml-list] Question re: otherlibs/systhread/posix.c

Hash: SHA1

  Please excuse me if this is a newbie-ish question, I haven't been using
OCaml that long.  (But am enjoying it very much!)

  I'm working on a Jack ( binding for Ocaml, and things
are progressing well.  However, I'm running into a problem currently;
the design of Jack uses lots of out-of-process callbacks to communicate
between the daemon and client connections.

  I have a callback interface where an Ocaml client registers callbacks
locally using Callback.register, then registers them in the C code with
the jack daemon. However, I'm getting segfaults in caml_thread_leave_blocking_section
(), in otherlibs/systhreads/posix.c, when dereferencing curr_thread.
 I'm guessing that this is due to there not being a pthread_key_t valid
for the daemon process within the Ocaml context.  Can someone suggest
a workaround for this?

  If gdb is accurate, the jackd callback-handler thread appears in the
client process as a new LWP, can I use pthread_key_create somehow within
the callback code itself, and register it for use within Ocaml?

  Thanks in advance for any help,
  Annan Harley

PS:  Is there a fast way to get all of the C code in the libraries built
with "-g"?  I haven't seen it in the Makefiles, but I miss these things
pretty regularly.

PPS:  I have the code itself in browseable CVS at ($CVSROOT)
and as a tarball at
Any comments or constructive criticism on the code itself are very welcome.
 It will be released under GPL when it seems to be generally usable,
and I've done all of the requisite documentation. Thanks!

client code causing segfault

ocaml callback setup code

ocaml extern declarations

C extern functions

C native functions executed by jackd

The segfault occurs when the xrun_handler runs, usually during initialization
in the following run, LWP 18692 is the jackd handler appearing in this

bash-2.05b$ gdb port_connector
GNU gdb 5.2.1
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and
you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-slackware-linux"...
(gdb) run
Starting program: /home/annan/proj/jahcaml/jahcaml/port_connector
[New Thread 16384 (LWP 18689)]
[New Thread 32769 (LWP 18690)]
[New Thread 16386 (LWP 18691)]
start_package activated
[New Thread 32771 (LWP 18692)]
writing req... fd:8 sizeof(*req):92
reading response... fd:8

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 32771 (LWP 18692)]
caml_thread_leave_blocking_section () at posix.c:191
191       caml_bottom_of_stack= curr_thread->bottom_of_stack;
(gdb) info threads
* 4 Thread 32771 (LWP 18692)  caml_thread_leave_blocking_section ()
    at posix.c:191
  3 Thread 16386 (LWP 18691)  0x403b87be in select () from /lib/
  2 Thread 32769 (LWP 18690)  0x403b631c in poll () from /lib/
  1 Thread 16384 (LWP 18689)  0x4030acd1 in sigsuspend () from /lib/
(gdb) where
#0  caml_thread_leave_blocking_section () at posix.c:191
#1  0x080ad0f9 in leave_blocking_section ()
#2  0x08099291 in caml_io_mutex_lock (chan=0x8101340) at posix.c:239
#3  0x080b1cd1 in caml_output ()
#4  0x0808a119 in Pervasives__output_string_212 ()
#5  0x080a0021 in xrun (param=0x1) at jc_ntv.c:156
#6  0x4007943e in jack_client_thread () from /usr/local/lib/
Note: This signature can be verified at
Version: Hush 2.3


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: