Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007562OCamlback end (clambda to assembly)public2017-06-22 18:212017-10-20 16:21
Reporterrgdoliveira 
Assigned To 
PrioritynormalSeveritycrashReproducibilityalways
StatusacknowledgedResolutionopen 
Platformppc64leOSAlpine LinuxOS Version3.6.2
Product Version4.04.1 
Target VersionFixed in Version 
Summary0007562: Ocamlc got segfault in Alpine ppc64le
DescriptionI'm building ocaml in Alpine Linux ppc64le and it builds fine. But when I try to use ocamlc, I'm getting a segfault.

Gdb backtrace shows:

#0 0x00003fffb7fad710 in do_relocs (dso=0x3fffb7ff26a0 <app>, rel=0x200ab4b8, rel_size=2495088,
    stride=3) at ldso/dynlink.c:379
#1 0x00003fffb7fae1ec in reloc_all (p=0x3fffb7ff26a0 <app>) at ldso/dynlink.c:1195
#2 0x00003fffb7fafc94 in __dls3 (sp=<optimized out>) at ldso/dynlink.c:1638
0000003 0x00003fffb7faf3d4 in __dls2 (base=<optimized out>, sp=0x3ffffffffba0) at ldso/dynlink.c:1424
0000004 0x00003fffb7facd2c in _dlstart_c (sp=<optimized out>, dynv=<optimized out>)
    at ldso/dlstart.c:147
0000005 0x00003fffb7fb1104 in _dlstart () from /lib/ld-musl-powerpc64le.so.1

I know that ocaml was recently ported to ppc64le architecture and works fine with glic, but seems there is an issue with musl.
Steps To ReproduceThe steps bellow need to be done inside an Alpine ppc64le:

- Clone aports repository
  $ git clone https://github.com/alpinelinux/aports.git [^]

- Build ocaml package
  $ cd aports/community/ocaml
  $ abuild -r

- Install the built package:
  $ sudo apk add <ocaml_apk>

- Run ocamlc to get the segmentation fault.
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0017941)
gasche (developer)
2017-06-22 18:36

The OCaml version seems to be 4.04.1 ( https://github.com/alpinelinux/aports/blob/master/community/ocaml/APKBUILD [^] ) with some downstream patches ( https://github.com/alpinelinux/aports/tree/master/community/ocaml [^] ), most of them being build-system related -- the only one affecting code generation marks the stack as non-executable and a ppc64 fix to CONTEXT_* macros in signal_osdeps.h

  https://github.com/alpinelinux/aports/blob/master/community/ocaml/010_all_execstacks.patch [^]
  https://github.com/alpinelinux/aports/blob/master/community/ocaml/fix-mcontext-fields.patch [^]

Since 4.04.0, "ocamlc" points to the native-compiled ocamlc.opt instead of the bytecode-compiled ocamlc.byte. Out of curiosity, does running ocamlc.byte (also installed in PATH) work correctly?
(0017942)
rgdoliveira (reporter)
2017-06-22 18:57

I just tried ocamlc.byte and I was able to compile a simple .ml file and run the generated file (no segfault).
(0017943)
xleroy (administrator)
2017-06-22 20:03

Thanks for trying ocamlc.byte. This confirms my suspicion that the problem is with dynamic loading in OCaml programs compiled to native code, which is the case of ocamlc in this Alpine setup.

The bad news is that we have extremely limited access to ppc64le hardware: just one virtual machine provided by RedHat in Brno, running Fedora (I think). So, I'm at a loss on how to debug this issue.
(0017962)
rgdoliveira (reporter)
2017-06-23 15:39

xleroy,

I have a VM running Alpine ppc64le and I can give you access to this VM, if that helps you with debug.

Can you talk with me at freenode? My username is 'rdutra'.
(0018007)
shinwell (developer)
2017-06-27 17:44

I can also try to look at this, I think I can get access to a suitable machine now. @xleroy please let me know if you have time / want to do it.
(0018053)
rgdoliveira (reporter)
2017-07-06 14:50

I applied a downstream patch (workaround) in Alpine build of ocaml and it fixed the segfault. Basically, I compiled the ocaml natives using -no-pie flag (https://github.com/alpinelinux/aports/blob/1feea49eaec12328e73541436bd1612228cd7e9a/community/ocaml/fix-segfault-in-ppc64le.patch [^])
(0018426)
xleroy (administrator)
2017-09-30 18:28

@shinwell: I lost access to a ppc64le machine, so you are most welcome to try and understand this issue while I try to build a qemu-based VM. (virt-builder should make this easy, except that the version that comes with Ubuntu 16.04 LTS doesn't work.)

(0018427)
xleroy (administrator)
2017-09-30 18:30

That '-no-pie' helps suggests a misunderstanding between ocamlopt and the dynamic loader about register usage or what not. I'm afraid that even with -no-pie, later attempts to do dynamic loading would fail.

- Issue History
Date Modified Username Field Change
2017-06-22 18:21 rgdoliveira New Issue
2017-06-22 18:36 gasche Note Added: 0017941
2017-06-22 18:57 rgdoliveira Note Added: 0017942
2017-06-22 20:03 xleroy Note Added: 0017943
2017-06-22 20:03 xleroy Status new => acknowledged
2017-06-22 20:04 xleroy Category ~DO NOT USE (was: OCaml general) => back end (clambda to assembly)
2017-06-23 15:39 rgdoliveira Note Added: 0017962
2017-06-27 17:44 shinwell Note Added: 0018007
2017-07-06 14:50 rgdoliveira Note Added: 0018053
2017-09-30 18:28 xleroy Note Added: 0018426
2017-09-30 18:28 xleroy Target Version => 4.06.0 +dev/beta1/beta2/rc1
2017-09-30 18:30 xleroy Note Added: 0018427
2017-10-20 16:21 doligez Target Version 4.06.0 +dev/beta1/beta2/rc1 =>


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker