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

Invalid_argument("index out of bounds") in asmcomp/closure.ml when compiling packed module #8769

Closed
copy opened this issue Jun 25, 2019 · 4 comments

Comments

@copy
Copy link

commented Jun 25, 2019

Tested on 4.08.0 (no flambda). It compiles fine on 4.07.

% cat fortuna.ml 
% cat rng.ml 
module F = Fortuna
% cat nocrypto.mli 
module Rng : sig
  module F : sig end
end
% ocamlc -c -I src -o nocrypto.cmi nocrypto.mli
% ocamlopt -c -for-pack Nocrypto -I src -o fortuna.cmx fortuna.ml
% ocamlopt -c -for-pack Nocrypto -I src -o rng.cmx rng.ml
% ocamlopt -pack -I src rng.cmx -o nocrypto.cmx
Fatal error: exception Invalid_argument("index out of bounds")
Raised by primitive operation at file "asmcomp/closure.ml", line 450, characters 45-50
Called from file "asmcomp/closure.ml", line 1040, characters 28-51
Called from file "asmcomp/closure.ml", line 978, characters 25-53
Called from file "asmcomp/closure.ml", line 1154, characters 27-46
Called from file "asmcomp/closure.ml", line 1056, characters 21-55
Called from file "asmcomp/closure.ml", line 987, characters 31-71
Called from file "asmcomp/closure.ml", line 1154, characters 27-46
Called from file "asmcomp/closure.ml", line 1056, characters 21-55
Called from file "asmcomp/closure.ml", line 987, characters 31-71
Called from file "asmcomp/closure.ml", line 978, characters 25-53
Called from file "asmcomp/closure.ml", line 1438, characters 24-57
Called from file "asmcomp/asmgen.ml", line 225, characters 16-71
Called from file "utils/misc.ml", line 31, characters 8-15
Re-raised at file "utils/misc.ml", line 45, characters 10-56
Called from file "asmcomp/asmgen.ml", line 155, characters 7-231
Called from file "utils/misc.ml", line 31, characters 8-15
Re-raised at file "utils/misc.ml", line 45, characters 10-56
Called from file "asmcomp/asmgen.ml" (inlined), line 261, characters 2-151
Called from file "asmcomp/asmpackager.ml", line 119, characters 6-187
Called from file "utils/misc.ml", line 31, characters 8-15
Re-raised at file "utils/misc.ml", line 45, characters 10-56
Called from file "asmcomp/asmpackager.ml", line 231, characters 2-78
Called from file "utils/misc.ml", line 31, characters 8-15
Re-raised at file "utils/misc.ml", line 45, characters 10-56
Called from file "utils/misc.ml", line 31, characters 8-15
Re-raised at file "utils/misc.ml", line 45, characters 10-56
Called from file "driver/optmain.ml", line 298, characters 6-200
Re-raised at file "parsing/location.ml", line 904, characters 14-25
Called from file "driver/optmain.ml", line 333, characters 6-37
Called from file "driver/optmain.ml", line 337, characters 2-9
@nojb

This comment has been minimized.

Copy link
Contributor

commented Jun 26, 2019

Thanks for the report. The bug was introduced by 111d4e1 @lpw25

@nojb nojb added the bug label Jun 26, 2019

@mshinwell

This comment has been minimized.

Copy link
Contributor

commented Jun 26, 2019

This appears to be a miscompilation of ocamlopt, given the offending source line and position is:

  | Value_tuple a when n < Array.length a -> a.(n)
                                             ^^^^^
@mshinwell

This comment has been minimized.

Copy link
Contributor

commented Jun 26, 2019

Or maybe n is negative, in which case it's not a miscompilation.

@lpw25

This comment has been minimized.

Copy link
Contributor

commented Jun 26, 2019

Fix in #8770.

lpw25 added a commit that referenced this issue Jun 28, 2019

Fix #8769 (#8770)
* Don't generate illegal Pfield's when compiling alias coercions

* Simplify lambda code when compiling packs

* Add regression test for pr8769

* Add Changes entry

lpw25 added a commit that referenced this issue Jun 28, 2019

Fix #8769 (#8770)
* Don't generate illegal Pfield's when compiling alias coercions

* Simplify lambda code when compiling packs

* Add regression test for pr8769

* Add Changes entry

@lpw25 lpw25 closed this in 11edca8 Jun 28, 2019

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