Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ocaml segfault when List.fold_left is traced then executed #6443

Closed
vicuna opened this issue May 26, 2014 · 6 comments

Comments

Projects
None yet
2 participants
@vicuna
Copy link

commented May 26, 2014

Original bug ID: 6443
Reporter: Reventlov
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2015-12-11T18:27:42Z)
Resolution: fixed
Priority: normal
Severity: crash
Platform: Linux
OS: Archlinux
OS Version: Up to date.
Version: 4.01.0
Fixed in version: 4.02.0+dev
Category: tools (ocaml{lex,yacc,dep,debug,...})
Monitored by: @diml @hcarty

Bug description

In the ocaml toplevel, when launching List.fold_left after tracking List.fold_left, you get a crash (segfault).

Steps to reproduce

Open the toplevel ocaml, type trace List.fold_left;; then type
List.fold_left;;

@vicuna

This comment has been minimized.

Copy link
Author

commented May 26, 2014

Comment author: @gasche

Could reproduce on 4.01 and trunk. Crashes on List.map as well (but not for List.filter, List.rev or Array.fold_left).

@vicuna

This comment has been minimized.

Copy link
Author

commented May 26, 2014

Comment author: @diml

This crashes as well:

#trace List.fold_left;;

List.fold_left is now traced.

0;;

Segmentation fault

#trace Toploop.use_file;;

Toploop.use_file is now traced.

0;;

  • : int = 0

#use "foo.ml";;

Segmentation fault

It seems to be the case for any function used by the compiler/toplevel.

@vicuna

This comment has been minimized.

Copy link
Author

commented May 26, 2014

Comment author: azynheira

Hi,
I am on MacOSX 10.9.3 and can reproduce this as well.

@vicuna

This comment has been minimized.

Copy link
Author

commented May 27, 2014

Comment author: @garrigue

This is a rather strange one.
I could localize the breakage between in trunk at revision 11123,
namely when merging the changes from 3.12.0 to 3.12.1 into trunk.
Note that 3.12.1 doesn't exhibit this behavior, so this looks like a merge problem.

Still looking for the cause.

@vicuna

This comment has been minimized.

Copy link
Author

commented May 27, 2014

Comment author: @garrigue

I eventually found the cause.
It was not commit 11123, but 11102.
This is a "small optimization" by Luc, reduces let-expressions whose body is the variable itself, to allow more tail-calls.
It is supposed to be always correct.
However, there is one pitfall: this is precisely the idiom used in trace.ml to prevent a tail call...

@vicuna

This comment has been minimized.

Copy link
Author

commented May 27, 2014

Comment author: @garrigue

Fixed in version/4.02 at revision 14922.
Replaced the optimized away let-expansion by a try-with, which cannot be optimized away without heavy static analysis... Should be safe for a while.

@vicuna vicuna closed this Dec 11, 2015

@vicuna vicuna added the tools label Mar 14, 2019

@vicuna vicuna added the bug label Mar 20, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.