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

Problem in the Mac OS X compiler [PPC code generator] #2719

vicuna opened this issue Jun 14, 2004 · 2 comments


None yet
1 participant
Copy link

commented Jun 14, 2004

Original bug ID: 2719
Reporter: administrator
Status: closed (set by @xavierleroy on 2015-12-11T18:27:57Z)
Resolution: fixed
Priority: normal
Severity: minor
Target version: 4.02.0+dev
Fixed in version: 4.02.0+dev
Category: ~DO NOT USE (was: OCaml general)
Related to: #4892

Bug description

Full_Name: Sylvain Chevillard
Version: 3.07+17
OS: Mac OS X v10.3
Submission from: (

I have noticed a bug which should be in the Mac OS X compiler of ocaml, I
Here is a minimal buggy code :

open Printf

let bug () =
let mat = [| [|false|] |]
and test = ref false in
printf "Value of test at the beginning : %b\n" !test; flush stdout;
(try let _ = mat.(0).(-1) in
(test := true;
printf "Am I going through this block of instructions ?\n";
flush stdout)
with Invalid_argument _ -> printf "Value of test now : %b\n" !test
(try if mat.(0).(-1) then ()
with Invalid_argument _ -> ()

let () = bug ()

We are waiting that the program (when run) should write :
Value of test at the beginning : false
Value of test now : false

and actually, that is what you could see when you run the bytecode generated by
ocamlc or if you compile the code on an x86 architecture with native compiler.

But, with the native compiler on Mac OS X, the program writes :
Value of test at the beginning : false
Value of test now : true

Notice that this part of the code seems to be useless but is actually essential
to the bug :
(try if mat.(0).(-1) then ()
with Invalid_argument _ -> ()

I think that it is a problem of pipeline in the processor. The instruction
test := true;
is probably pipelined in the processor and is run even when the exception is

Happy coding!

Sylvain Chevillard


This comment has been minimized.

Copy link

commented Jul 1, 2004

Comment author: administrator

Bug in scheduling of Icheckbound. The obvious fix diminishes the usefulness of
the scheduler quite a bit. Will not fix in 3.08.


This comment has been minimized.

Copy link

commented Jun 5, 2014

Comment author: @xavierleroy

Semi-obvious fix implemented in 4.02 (commit 14963) and on trunk (commit 14964): checkbound instructions are not rescheduled if they occur within a try...with block.

@vicuna vicuna closed this Dec 11, 2015

@vicuna vicuna added this to the 4.02.0 milestone Mar 14, 2019

@vicuna vicuna added the bug label Mar 19, 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.