Skip to content

crash on enum-like signatures due to unsafe use of succ() #28

@hackedy

Description

@hackedy

If I define an enum-like type

bit : Type

zero : bit
one : bit

then autosubst-ocaml crashes with the error message

Fatal error: exception Invalid_argument("[ocamlgraph] succ")
Raised at Stdlib.invalid_arg in file "stdlib.ml", line 30, characters 20-45
Called from Graph__Blocks.Unlabeled.succ in file "src/blocks.ml", line 235, characters 28-71
Called from Autosubst_lib__AssocList.map.(fun) in file "lib/assocList.ml", line 39, characters 30-35
Called from Stdlib__List.map in file "list.ml", line 92, characters 20-23
Called from Autosubst_lib__SigAnalyzer.build_signature in file "lib/sigAnalyzer.ml", line 82, characters 18-53
Called from Stdlib__Result.map in file "result.ml", line 25, characters 32-37
Called from Monadic__Result.MakeT.ResultMonad.bind in file "monadic/library/result.ml", line 31, characters 24-33
Called from Autosubst_lib__Program.main in file "lib/program.ml", line 186, characters 19-51
Called from Stdlib__Result.map in file "result.ml", line 25, characters 32-37
Called from Monadic__Result.MakeT.ResultMonad.bind in file "monadic/library/result.ml", line 31, characters 24-33
Called from Stdlib__Result.map in file "result.ml", line 25, characters 32-37
Called from Monadic__Result.MakeT.ResultMonad.bind in file "monadic/library/result.ml", line 31, characters 24-33
Called from Dune__exe__Main.main in file "bin/main.ml", line 6, characters 12-35
Called from Dune__exe__Main in file "bin/main.ml", line 10, characters 9-16

If, however, the enum-like type appears as a parameter of a constructor in some other type, then there is no crash.

bit : Type

zero : bit
one : bit

expr : Type
const : bit -> expr
and : expr -> expr -> expr

I guess there is some use of the succ() function while analyzing the signature that does not guard against the possibility of a symbol having no successors of some kind.

@bamarsha found this bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions