You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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: 132.176.250.100 (132.176.250.100)
I have noticed a bug which should be in the Mac OS X compiler of ocaml, I
think.
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
raised.
Happy coding!
Sylvain Chevillard
The text was updated successfully, but these errors were encountered:
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.
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: 132.176.250.100 (132.176.250.100)
I have noticed a bug which should be in the Mac OS X compiler of ocaml, I
think.
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
raised.
Happy coding!
Sylvain Chevillard
The text was updated successfully, but these errors were encountered: