Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0004538OCamlOCaml generalpublic2008-04-23 12:262012-09-06 19:17
Reporterjsk 
Assigned To 
PrioritynormalSeveritycrashReproducibilityalways
StatusacknowledgedResolutionopen 
PlatformOSOS Version
Product Version3.10.2 
Target VersionlaterFixed in Version 
Summary0004538: Remotely debugging multi-threaded bytecode program causes segmentation fault.
Description=== Operating System ===

Type: Ubuntu Linux
Version: 7.10
Platform: x86

=== OCaml Installation ===

Version: 3.10.2
Build: x86

=== Summary of Fault ===

When the attached program is compiled as a bytecode executable, remotely
debugging the program causes it to terminate with a segmentation fault,
when stepping through manually on the debugger.

=== Reproduction Steps ===

1. Compile the attached program with ocamlc:

   ocamlc -custom -thread -g unix.cma threads.cma test.ml -o test.exe

2. Start ocamldebug in remote debugging mode (manual loading):

   ocamldebug -s <socket-name> test.exe
   set loadingmode manual
   goto 0

3. Manually start the program (possibly on another machine):

   CAML_DEBUG_SOCKET=<socket_name> ./test.exe

4. Repeatedly issue the following command to ocamldebug:

   step

=== Fault Description ===

After some number of steps (different number each time), the executable
(test.exe) terminates with a "Segmentation Fault (core dumped)" message
(See the attached core dump files). Analysis of the core dumps with gdb
invariably points to the following location:

Program terminated with signal 11, Segmentation fault.
#0 0x08073570 in caml_interprete (prog=0x80ad1e8, prog_size=48680) at interp.c:284
284 curr_instr = *pc++;
(gdb) backtrace
#0 0x08073570 in caml_interprete (prog=0x80ad1e8, prog_size=48680) at interp.c:284
#1 0x0805bd3f in caml_main (argv=0xbf83daa4) at startup.c:414
#2 0x0805befb in main (argc=1, argv=0xbf83daa4) at main.c:56
TagsNo tags attached.
Attached Files? file icon test.ml [^] (1,222 bytes) 2008-04-23 12:26 [Show Content]
zip file icon cores.zip [^] (344,748 bytes) 2008-04-23 12:41

- Relationships

-  Notes
(0004498)
jsk (reporter)
2008-04-23 12:54
edited on: 2008-04-25 10:10

Some further info:

By modifying the lines between "Mutex.lock" and "Mutex.unlock", it's possible to coerce ocamlrun into producing various errors (other than segmentation faults).

For example, replace the pair of print_string statements with the following statement:

    Printf.printf "Thread %n Iteration %n"
        (Thread.id (Thread.self ())) i;

On my system, if this change is made, then the segmentation fault goes away, but only to be replaced with the following error:

    Fatal error: bad opcode (65726854)

Cheers

Jonathan

---
Jonathan Knowles
Citrix Systems Research & Development

(0004567)
doligez (administrator)
2008-08-04 16:55

reproduced with 3.11+dev14 on Mac OS X 10.5.4
(0005352)
doligez (administrator)
2010-04-20 14:38

the bug is still here in 3.11.2 and 3.12.0+dev17 [Mac OS 10.6.3]
(0007645)
doligez (administrator)
2012-07-06 16:10

Note that the debugger uses the fork() system call to do checkpointing of the process. The interactions between fork() and threads are tricky and platform-dependent, so it's not really a surprise that the debugger would fail on a multi-threaded program. Worse, it's not clear that we can do anything about it.

- Issue History
Date Modified Username Field Change
2008-04-23 12:26 jsk New Issue
2008-04-23 12:26 jsk File Added: test.ml
2008-04-23 12:34 jsk Note Added: 0004497
2008-04-23 12:41 jsk File Added: cores.zip
2008-04-23 12:42 jsk Note Edited: 0004497
2008-04-23 12:43 jsk Note Deleted: 0004497
2008-04-23 12:54 jsk Note Added: 0004498
2008-04-25 10:09 jsk Note Edited: 0004498
2008-04-25 10:10 jsk Note Edited: 0004498
2008-08-04 16:55 doligez Note Added: 0004567
2008-08-04 16:55 doligez Status new => acknowledged
2010-04-20 14:38 doligez Note Added: 0005352
2012-07-06 16:10 doligez Note Added: 0007645
2012-07-06 16:10 doligez Target Version => 4.01.0+dev
2012-07-31 13:36 doligez Target Version 4.01.0+dev => 4.00.1+dev
2012-09-06 19:17 frisch Target Version 4.00.1+dev => later


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker