Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0004538OCamltools (ocaml{lex,yacc,dep,debug,...})public2008-04-23 12:262017-03-10 11:13
Assigned Todoligez 
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 -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:


=== 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 [^] (1,222 bytes) 2008-04-23 12:26 [Show Content]
zip file icon [^] (344,748 bytes) 2008-04-23 12:41

- Relationships

-  Notes
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.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)



Jonathan Knowles
Citrix Systems Research & Development

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

reproduced with 3.11+dev14 on Mac OS X 10.5.4
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]
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.
shinwell (developer)
2017-03-10 11:12

If ocamldebug is not supposed to work on threaded programs, can we add that to the manual (or add some warning in the code), and then close this rather old issue?

- Issue History
Date Modified Username Field Change
2008-04-23 12:26 jsk New Issue
2008-04-23 12:26 jsk File Added:
2008-04-23 12:34 jsk Note Added: 0004497
2008-04-23 12:41 jsk File Added:
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
2016-12-07 18:11 shinwell Category OCaml general => OCaml tools (ocaml{lex,yacc,dep,debug})
2017-02-23 16:45 doligez Category OCaml tools (ocaml{lex,yacc,dep,debug}) => tools (ocaml{lex,yacc,dep,debug,...})
2017-03-10 11:12 shinwell Note Added: 0017613
2017-03-10 11:13 shinwell Assigned To => doligez
2017-03-10 11:13 shinwell Status acknowledged => assigned

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker