Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005474OCamlOCamlbuild (the tool)public2012-01-12 11:162012-09-25 20:10
Reporterdlovasko 
Assigned To 
PrioritynormalSeveritycrashReproducibilityalways
StatusclosedResolutionunable to reproduce 
Platformx86_64OSLinux x86_64OS VersionopenSUSE 11.4
Product Version3.12.0 
Target VersionFixed in Version 
Summary0005474: Ocamlopt generates segfaulting binary
Descriptionsource code:
let _ = Printf.printf "hello\n"

compilation:
ocamlopt -o foo ocaml.segfault.ml

result:
see attachment

after running the executable, error pops out:
Program received signal SIGSEGV, Segmentation fault.
0x000000000062ee00 in strcpy@@GLIBC_2.2.5 ()

the same code, but in ocaml interpreter works

glibc version: "2.11.3-12.15.1"



Steps To ReproduceRun the attachment
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0006660)
ygrek (reporter)
2012-01-12 11:27

cannot reproduce
(0006662)
dlovasko (reporter)
2012-01-12 12:10

works(reproducing) for me:

ocaml-3.12.0-11.1.2.x86_64
glibc-2.14.1-14.12.5.x86_64
openSUSE 12.1

are you running the executable attached, or have you compiled one yourself?
(0006664)
ygrek (reporter)
2012-01-12 13:20

There is nothing attached. Where did you get ocaml from - self-compiled or from suse package? In the latter case - you'd better first discuss this issue with suse packagers.
(0006665)
dlovasko (reporter)
2012-01-12 13:25

somehow the upload does not work for me, so i uploaded the binary here, please try it:
http://www.2shared.com/file/-V0LOCXj/foo.html [^]
(0006666)
glondu (reporter)
2012-01-12 15:08

Indeed, the executable provided segfaults in a virtual machine running Debian stable. But I cannot reproduce it by recompiling from sources (but I tried only 3.12.1). I guess something is wrong with your toolchain.

strace output:
> [...]
> brk(0) = 0xec9000
> brk(0xeea000) = 0xeea000
> mmap(NULL, 270336, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f0aef5f1000
> mmap(NULL, 1024000, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f0aef4f7000
> sigaltstack({ss_sp=0x62f0a0, ss_flags=0, ss_size=8192}, NULL) = 0
> rt_sigaction(SIGSEGV, {0x410e80, [], SA_RESTORER|SA_STACK|SA_NODEFER|SA_SIGINFO, 0x7f0aeec6a1e0}, NULL, 8) = 0
> readlink("/proc/self/exe", "/home/steph/foo", 256) = 15
> stat("/home/steph/foo", {st_mode=S_IFREG|0755, st_size=572315, ...}) = 0
> lseek(0, 0, SEEK_CUR) = -1 ESPIPE (Illegal seek)
> lseek(1, 0, SEEK_CUR) = -1 ESPIPE (Illegal seek)
> lseek(2, 0, SEEK_CUR) = -1 ESPIPE (Illegal seek)
> --- SIGSEGV (Segmentation fault) @ 0 (0) ---
> getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM_INFINITY}) = 0
> rt_sigaction(SIGSEGV, {SIG_DFL, [], SA_RESTORER, 0x7f0aeec6a1e0}, NULL, 8) = 0
> rt_sigreturn(0xb) = 15540656
> --- SIGSEGV (Segmentation fault) @ 0 (0) ---
> +++ killed by SIGSEGV +++

ltrace output:
> __libc_start_main(0x40fecc, 1, 0x7fff705a20f8, 0x41fcc0, 0x41fd50 <unfinished ...>
> malloc(16) = 0x00fa8010
> malloc(16) = 0x00fa8030
> malloc(16) = 0x00fa8050
> getenv("OCAMLRUNPARAM") = NULL
> getenv("CAMLRUNPARAM") = NULL
> calloc(1024, 8) = 0x00fa8070
> malloc(266240) = 0x7f7f9c152010
> malloc(1019936) = 0x7f7f9c058010
> malloc(16384) = 0x00faa080
> sigemptyset(0x7fff705a1f18) = 0
> sigaltstack(0x7fff705a1fb0, 0, 10, 0, 0xffffffff) = 0
> sigaction(11, 0x7fff705a1f10, NULL) = 0
> readlink(0x42127d, 0x636ca0, 256, -1, 0) = 15
> __xstat64(1, "/home/steph/foo", 0x7fff705a1f30) = 0
> __sigsetjmp(0x639040, 0, 0, -1, 0) = 0
> malloc(4176) = 0x00fae090
> lseek64(0, 0, 1, 0xfae080, 0) = -1
> malloc(4176) = 0x00faf0f0
> lseek64(1, 0, 1, 0xfaf0e0, 4) = -1
> malloc(4176) = 0x00fb0150
> lseek64(2, 0, 1, 0xfb0140, 4) = -1
> malloc(45) = 0x00fb11b0
> --- SIGSEGV (Segmentation fault) ---
> getrlimit64(3, 0x630c90, 0x630cc0, 0xfb11a0, 0x7f7f9baf5ec8) = 0
> sigemptyset(0x00630bf8) = 0
> sigaction(11, 0x00630bf0, NULL) = 0
> unexpected breakpoint at 0x62edff
> --- SIGSEGV (Segmentation fault) ---
> +++ killed by SIGSEGV +++

It looks like something is wrong in the initialization of the OCaml runtime. Did you try recompiling OCaml yourself, then use it to generate foo?
(0006667)
glondu (reporter)
2012-01-12 15:19

Oh, and the backtrace (with gdb):
> #0 0x000000000062ee00 in strcpy@@GLIBC_2.2.5 ()
> #1 0x000000000041bb4d in caml_register_named_value (vname=6461304, val=6459320) at /usr/include/bits/string3.h:105
> #2 0x000000000041da24 in caml_c_call ()
> 0000003 0x00000000000003e8 in ?? ()
> 0000004 0x0000000000404e29 in caml_program ()
> 0000005 0x000000000008bb9b in ?? ()
> 0000006 0x000000000041da7a in caml_start_program ()
> 0000007 0x0000000000000000 in ?? ()
(0006668)
glondu (reporter)
2012-01-12 15:40

I couldn't reproduce your segfaulting executable, even with an openSUSE 12.1 live CD and the same version of ocaml and glibc. The version of binutils is 2.21.1-12.1.4.

- Issue History
Date Modified Username Field Change
2012-01-12 11:16 dlovasko New Issue
2012-01-12 11:27 ygrek Note Added: 0006660
2012-01-12 12:10 dlovasko Note Added: 0006662
2012-01-12 13:20 ygrek Note Added: 0006664
2012-01-12 13:25 dlovasko Note Added: 0006665
2012-01-12 15:08 glondu Note Added: 0006666
2012-01-12 15:19 glondu Note Added: 0006667
2012-01-12 15:40 glondu Note Added: 0006668
2012-01-13 20:22 xleroy Status new => resolved
2012-01-13 20:22 xleroy Resolution open => unable to reproduce
2012-02-02 15:17 protz Category OCamlbuild => OCamlbuild (the tool)
2012-09-25 20:10 xleroy Status resolved => closed


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker