Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005636OCamlconfigure and build/installpublic2012-06-06 00:252015-12-11 19:04
ReporterRichard Jones 
Assigned To 
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
  let _ = Thread.create
  $ ocamlc -thread unix.cma threads.cma -o test
  File "", line 1, characters 0-1:
  Error: Error on dynamically loaded library: /usr/lib64/ocaml/stublibs/ /usr/lib64/ocaml/stublibs/ 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*/ on a glibc system. Notice that it's a linker script which links the program with both (the dynamic library) and libpthread_nonshared.a which is a static library containing just the pthread_atfork symbol. (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 | grep pthread_atfork
                 U pthread_atfork

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

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

  $ nm | 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: [^]

and "pthread_atfork on ppc64" here: [^]
Steps To ReproduceSee description.
Additional Information [^] [^]
TagsNo tags attached.
Attached Files

- Relationships

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

This is the patch we carry in Fedora:;a=commitdiff;h=e14375eca4f1ddd9d3b28c9b45ce4aca05070a95 [^]
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
2015-12-11 19:04 xleroy Status resolved => closed
2017-02-23 16:38 doligez Category OCaml internal build/install (Makefiles, configure) => configure and build/install

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker