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("String.sub / Bytes.sub") crash during pinning #4936

Closed
sim642 opened this issue Nov 30, 2021 · 2 comments · Fixed by #4941, #5080 or #5150
Closed

Invalid_argument("String.sub / Bytes.sub") crash during pinning #4936

sim642 opened this issue Nov 30, 2021 · 2 comments · Fixed by #4941, #5080 or #5150
Projects
Milestone

Comments

@sim642
Copy link

sim642 commented Nov 30, 2021

After an innocent merge change opam pin started to crash setup-ocaml based GitHub Actions workflows:

  '/opt/hostedtoolcache/opam/2.1.1/x86_64/opam pin add goblint.dev . --no-action' failed.
  Fatal error:
  Invalid_argument("String.sub / Bytes.sub")
  Backtrace:
    Raised at Stdlib.invalid_arg in file "stdlib.ml", line 30, characters 20-45
    Called from Stdlib__string.sub in file "string.ml" (inlined), line 47, characters 2-23
    Called from OpamFile.Syntax.to_string_with_preserved_format.extract in file "src/format/opamFile.ml" (inlined), line 799, characters 31-66
    Called from OpamFile.Syntax.to_string_with_preserved_format.value_list_str.aux in file "src/format/opamFile.ml", line 815, characters 24-66
    Called from OpamFile.Syntax.to_string_with_preserved_format.value_list_str in file "src/format/opamFile.ml", line 860, characters 8-41
    Called from Stdlib__list.fold_left in file "list.ml", line 121, characters 24-34
    Called from OpamFile.Syntax.to_string_with_preserved_format in file "src/format/opamFile.ml", line 909, characters 8-1023
    Called from OpamFile.OPAMSyntax.to_string_with_preserved_format in file "src/format/opamFile.ml" (inlined), line 3152, characters 4-137
    Called from OpamFile.OPAMSyntax.write_with_preserved_format in file "src/format/opamFile.ml", line 3159, characters 6-89
    Called from OpamPinCommand.source_pin in file "src/client/opamPinCommand.ml", line 625, characters 4-193
    Called from OpamClient.PIN.pin in file "src/client/opamClient.ml", line 1549, characters 25-86
    Called from OpamCommands.pin.pin.(fun) in file "src/client/opamCommands.ml", line 3268, characters 9-79
    Called from OpamSwitchState.with_.(fun) in file "src/state/opamSwitchState.ml", line 1211, characters 14-18
    Re-raised at OpamStd.Exn.finalise in file "src/core/opamStd.ml", line 1372, characters 4-38
    Called from OpamStd.Exn.finally in file "src/core/opamStd.ml", line 1375, characters 10-14
    Re-raised at OpamStd.Exn.finalise in file "src/core/opamStd.ml", line 1372, characters 4-38
    Called from OpamGlobalState.with_ in file "src/state/opamGlobalState.ml", line 186, characters 14-18
    Re-raised at OpamStd.Exn.finalise in file "src/core/opamStd.ml", line 1372, characters 4-38
    Called from Cmdliner_term.app.(fun) in file "src_ext/cmdliner/src/cmdliner_term.ml", line 27, characters 19-24
    Called from Cmdliner.Term.ret.(fun) in file "src_ext/cmdliner/src/cmdliner.ml", line 27, characters 27-34
    Called from Cmdliner.Term.run in file "src_ext/cmdliner/src/cmdliner.ml", line 118, characters 32-39
    Called from Cmdliner.Term.term_eval in file "src_ext/cmdliner/src/cmdliner.ml", line 148, characters 18-36
    Called from Cmdliner.Term.eval_choice in file "src_ext/cmdliner/src/cmdliner.ml", line 266, characters 22-48
    Called from OpamCliMain.run.(fun) in file "src/client/opamCliMain.ml", line 441, characters 8-60
    Called from OpamCliMain.main_catch_all in file "src/client/opamCliMain.ml", line 328, characters 6-10
  Error: The process '/opt/hostedtoolcache/opam/2.1.1/x86_64/opam' failed with exit code 99

Full log here:
https://github.com/goblint/analyzer/runs/4364951592?check_suite_focus=true#step:3:1165.
The full opam file being pinned here: https://github.com/goblint/analyzer/blob/84a35b55bf98115920bd809cc402c8cebd78da27/goblint.opam.

Locally I cannot reproduce the problem, but I also have opam 2.1.0 from the PPA instead of opam 2.1.1 which setup-ocaml is using.

@sim642
Copy link
Author

sim642 commented Nov 30, 2021

I forgot that the CI job runs with OPAMLOCKED: locked, so the offending file is instead this one: https://github.com/goblint/analyzer/blob/84a35b55bf98115920bd809cc402c8cebd78da27/goblint.opam.locked. Using --locked I can also reproduce it locally on opam 2.1.0.

If I remove from pin-depends the goblint-cil pin

  [
  "goblint-cil.1.8.2"
  "git+https://github.com/goblint/cil.git#a3c91aa6e8f946fec9a9a13361b051a73b12a65c"
]

then the crash disappears. But of course it isn't what I want, I need the pin.

Maybe I'm already blind staring at this, but I cannot see what's the problem with it. Sure, it has some funky indentation but that's how opam lock wrote it, so I don't know. And the other pin-depends having that funky indentation is fine by opam pin, so I'm very confused now.

EDIT: Apparently just putting the goblint-cil pin first in the lock file manually fixes the crash... There must be something real funky happening here.

sim642 added a commit to goblint/analyzer that referenced this issue Nov 30, 2021
@rjbou
Copy link
Collaborator

rjbou commented Dec 1, 2021

Thanks for report, you reached a blind spot!
What happens: on pinning, the opam file is written in opam internals, with format preservation (most close formatting to hand written one). In the function call, instead of taking the lock file as the file to copy from, it takes the regular opam file (except the missing fallback). You had some modification between the files that makes it do some calculation and fail.

@rjbou rjbou added this to To do in Opam 2.2.0 via automation Dec 1, 2021
@rjbou rjbou added the KIND: BUG label Dec 1, 2021
@rjbou rjbou added this to the 2.2.0~alpha milestone Dec 1, 2021
@rjbou rjbou moved this from To do to To do: opam file updates in Opam 2.2.0 Dec 10, 2021
@rjbou rjbou mentioned this issue Dec 14, 2021
@rjbou rjbou moved this from To do: opam file updates to In progress in Opam 2.2.0 Dec 16, 2021
Opam 2.2.0 automation moved this from In progress to Done Mar 30, 2022
@rjbou rjbou reopened this Mar 30, 2022
Opam 2.2.0 automation moved this from Done to In progress Mar 30, 2022
Opam 2.2.0 automation moved this from In progress to Done May 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Opam 2.2.0
  
Done
2 participants