-
Notifications
You must be signed in to change notification settings - Fork 1.2k
cmm miscompile: cross-module inlining causes catch ID collision #7702
Description
Original bug ID: 7702
Reporter: chengsun
Assigned to: @gasche
Status: resolved (set by @gasche on 2018-01-11T10:33:51Z)
Resolution: fixed
Priority: normal
Severity: crash
Version: 4.06.0
Fixed in version: 4.07.0+dev/beta2/rc1/rc2
Category: back end (clambda to assembly)
Monitored by: chengsun @nojb @hhugo @gasche @yakobowski
Bug description
The attached code miscompiles (on 4.03.0 through trunk, no flambda) due to cross-module inlining.
The cmm generated for b.ml looks incorrect. As far as I can tell, an ID is generated for a catch lambda using next_raise_count, but this ID is already used in the clambda inlined from a.ml.
a.ml:
let _unused _ = try () with _ -> ()
let trigger_bug x =
let ok =
match x with
| None
| Some "" -> true
| Some _ -> false
in
if x = Some "" && not ok then
failwith "impossible"
[@@inline always]
b.ml:
let bug x = A.trigger_bug x
c.ml:
let () =
B.bug (Some "");
Printf.printf "Bug failed to trigger :(\n
Steps to reproduce
$ tar xzf bug.tar.gz
$ ./compile.sh
$ ./a.out
Fatal error: exception Failure("impossible")