Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005636OCamlOCaml internal build/install (Makefiles, configure)public2012-06-06 00:252012-06-08 13:38
ReporterRichard Jones 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSLinuxOS Version
Product Version3.12.1 
Target VersionFixed in Version4.00.0+dev 
Summary0005636: pthread_atfork symbol not linked correctly when using glibc
DescriptionOn ppc/ppc64, when you link any bytecode threaded program, you'll get an error:

  $ cat test.ml
  let _ = Thread.create
  $ ocamlc -thread unix.cma threads.cma test.ml -o test
  File "test.ml", line 1, characters 0-1:
  Error: Error on dynamically loaded library: /usr/lib64/ocaml/stublibs/dllthreads.so: /usr/lib64/ocaml/stublibs/dllthreads.so: undefined symbol: pthread_atfork

In glibc, the pthread_atfork symbol is handled specially -- it is statically linked into programs, unlike other pthread_* symbols which are dynamically linked. To see how this works, examine /usr/lib*/libpthread.so on a glibc system. Notice that it's a linker script which links the program with both libpthread.so.0 (the dynamic library) and libpthread_nonshared.a which is a static library containing just the pthread_atfork symbol.

dllthreads.so (the bytecode standard threads library in otherlibs/systhreads) is currently created like this:

  $(MKLIB) -o threads $(BYTECODE_C_OBJS)

which means that it creates an external undefined reference to pthread_atfork:

  $ nm dllthreads.so | grep pthread_atfork
                 U pthread_atfork

Including the static symbol in dllthreads.so (using explicit -lpthread to invoke the linker script) makes the problem go away:

  $(MKLIB) -o threads $(BYTECODE_C_OBJS) -lpthread

  $ nm dllthreads.so | grep pthread_atfork
  0000000000003520 t __pthread_atfork
  0000000000003520 t pthread_atfork

(Note that you only see this error on ppc. The x86-64 version of glibc contains a dynamic version of pthread_atfork, which is a bug in glibc!)

For in-depth information, see this thread:

http://ryanarn.blogspot.co.uk/2011/07/curious-case-of-pthreadatfork-on.html [^]

and "pthread_atfork on ppc64" here:

https://lists.fedoraproject.org/pipermail/ppc/2012-June/thread.html#1655 [^]
Steps To ReproduceSee description.
Additional Informationhttp://ryanarn.blogspot.co.uk/2011/07/curious-case-of-pthreadatfork-on.html [^]
https://lists.fedoraproject.org/pipermail/ppc/2012-June/thread.html#1655 [^]
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0007517)
Richard Jones (reporter)
2012-06-06 00:27

This is the patch we carry in Fedora:

http://git.fedorahosted.org/git/?p=fedora-ocaml.git;a=commitdiff;h=e14375eca4f1ddd9d3b28c9b45ce4aca05070a95 [^]
(0007525)
xleroy (administrator)
2012-06-08 13:38

Thanks for the information and the patch, which is now applied in 4.00 branch (r12585) and in trunk (r12586).

- Issue History
Date Modified Username Field Change
2012-06-06 00:25 Richard Jones New Issue
2012-06-06 00:27 Richard Jones Note Added: 0007517
2012-06-08 13:38 xleroy Note Added: 0007525
2012-06-08 13:38 xleroy Status new => resolved
2012-06-08 13:38 xleroy Resolution open => fixed
2012-06-08 13:38 xleroy Fixed in Version => 4.00.0+dev


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker