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

Crash with directory targets and multiple workspace contexts #10310

Closed
samoht opened this issue Mar 26, 2024 · 3 comments · Fixed by #10367 or #10382
Closed

Crash with directory targets and multiple workspace contexts #10310

samoht opened this issue Mar 26, 2024 · 3 comments · Fixed by #10367 or #10382
Assignees
Labels
Milestone

Comments

@samoht
Copy link
Member

samoht commented Mar 26, 2024

See https://github.com/samoht/dune-crash for a repro.

Full error message:

Internal error, please report upstream including the contents of _build/log.
Description:
  ("gen_rules returned a set of directory targets that doesn't match the set of directory targets from returned rules",
  { dir = In_build_dir "solo5"
  ; mismatched_directories =
      map { "solo5/mirage" : { message = "not generated"; loc = "dune:1" } }
  })
Raised at Stdune__Code_error.raise in file
  "otherlibs/stdune/src/code_error.ml", line 10, characters 30-62
Called from Dune_engine__Load_rules.Load_rules.load_build_directory_exn.(fun)
  in file "src/dune_engine/load_rules.ml", line 850, characters 6-145
Called from Fiber__Scheduler.exec in file "vendor/fiber/src/scheduler.ml",
  line 76, characters 8-11
-> required by ("load-dir", In_build_dir "solo5")
-> required by
   ("build-alias", { dir = In_build_dir "solo5"; name = "default" })
-> required by ("toplevel", ())

I must not crash.  Uncertainty is the mind-killer. Exceptions are the
little-death that brings total obliteration.  I will fully express my cases.
Execution will pass over me and through me.  And when it has gone past, I
will unwind the stack along its path.  Where the cases are handled there will
be nothing.  Only I will remain.
@gridbugs
Copy link
Collaborator

I've simplified this repro and added a test that reproduces it #10330

@gridbugs
Copy link
Collaborator

It looks like this crash happens whenever a directory target is disabled via enabled_if. E.g.

; dune
(rule
 (enabled_if false)
 (target (dir x))
 (action (progn)))
; dune-project
(lang dune 3.14)
(using directory-targets 0.1)

gridbugs added a commit to gridbugs/dune that referenced this issue Mar 29, 2024
The validation in question was comparing directory targets discovered
in the project from directories that are the target of enabled rules
(rules which lack an `enabled_if` field, or whose `enabled_if` condition
is false). This was incorrect as it doesn't account for directory
targets which are the target of disabled rules so the validation fails
if any rule with a directory target is disabled. The validation step was
introduced in 1fd19d7 but there aren't any clues to why it was
necessary.

Fixes ocaml#10310

Signed-off-by: Stephen Sherratt <stephen@sherra.tt>
vouillon pushed a commit to ocaml-wasm/dune that referenced this issue Mar 29, 2024
The validation in question was comparing directory targets discovered
in the project from directories that are the target of enabled rules
(rules which lack an `enabled_if` field, or whose `enabled_if` condition
is false). This was incorrect as it doesn't account for directory
targets which are the target of disabled rules so the validation fails
if any rule with a directory target is disabled. The validation step was
introduced in 1fd19d7 but there aren't any clues to why it was
necessary.

Fixes ocaml#10310

Signed-off-by: Stephen Sherratt <stephen@sherra.tt>
gridbugs added a commit to gridbugs/dune that referenced this issue Apr 3, 2024
Previously attempting to disable a rule with a directory target would
cause dune to crash.

Fixes ocaml#10310

Signed-off-by: Stephen Sherratt <stephen@sherra.tt>
gridbugs added a commit to gridbugs/dune that referenced this issue Apr 3, 2024
Previously attempting to disable a rule with a directory target would
cause dune to crash.

Fixes ocaml#10310

Signed-off-by: Stephen Sherratt <stephen@sherra.tt>
gridbugs added a commit to gridbugs/dune that referenced this issue Apr 3, 2024
Previously attempting to disable a rule with a directory target would
cause dune to crash.

Fixes ocaml#10310

Signed-off-by: Stephen Sherratt <stephen@sherra.tt>
gridbugs added a commit that referenced this issue Apr 3, 2024
Previously attempting to disable a rule with a directory target would
cause dune to crash.

Fixes #10310

Signed-off-by: Stephen Sherratt <stephen@sherra.tt>
@jchavarri
Copy link
Collaborator

See #10367 (comment).

@jchavarri jchavarri reopened this Apr 3, 2024
gridbugs added a commit to gridbugs/dune that referenced this issue Apr 4, 2024
Previously attempting to disable a rule with a directory target would
cause dune to crash.

Fixes ocaml#10310

Signed-off-by: Stephen Sherratt <stephen@sherra.tt>
gridbugs added a commit to gridbugs/dune that referenced this issue Apr 4, 2024
Previously attempting to disable a rule with a directory target would
cause dune to crash.

Fixes ocaml#10310

Signed-off-by: Stephen Sherratt <stephen@sherra.tt>
@rgrinberg rgrinberg added this to the 3.16.0 milestone Apr 4, 2024
@rgrinberg rgrinberg added the bug label Apr 4, 2024
gridbugs added a commit to gridbugs/dune that referenced this issue Apr 5, 2024
Previously attempting to disable a rule with a directory target would
cause dune to crash.

Fixes ocaml#10310

Signed-off-by: Stephen Sherratt <stephen@sherra.tt>
gridbugs added a commit to gridbugs/dune that referenced this issue Apr 5, 2024
Previously attempting to disable a rule with a directory target would
cause dune to crash.

Fixes ocaml#10310

Signed-off-by: Stephen Sherratt <stephen@sherra.tt>
rgrinberg pushed a commit to gridbugs/dune that referenced this issue Apr 7, 2024
Previously attempting to disable a rule with a directory target would
cause dune to crash.

Fixes ocaml#10310

Signed-off-by: Stephen Sherratt <stephen@sherra.tt>
rgrinberg pushed a commit that referenced this issue Apr 7, 2024
* Allow rules with directory targets to be disabled

Previously attempting to disable a rule with a directory target would
cause dune to crash.

Fixes #10310

Signed-off-by: Stephen Sherratt <stephen@sherra.tt>
emillon pushed a commit to emillon/dune that referenced this issue Apr 17, 2024
* Allow rules with directory targets to be disabled

Previously attempting to disable a rule with a directory target would
cause dune to crash.

Fixes ocaml#10310

Signed-off-by: Stephen Sherratt <stephen@sherra.tt>
emillon added a commit that referenced this issue Apr 17, 2024
* Add repro for gh10310 (#10330)

Signed-off-by: Stephen Sherratt <stephen@sherra.tt>

* Allow rules with directory targets to be disabled (again) (#10382)

* Allow rules with directory targets to be disabled

Previously attempting to disable a rule with a directory target would
cause dune to crash.

Fixes #10310

Signed-off-by: Stephen Sherratt <stephen@sherra.tt>

---------

Signed-off-by: Stephen Sherratt <stephen@sherra.tt>
Co-authored-by: Stephen Sherratt <stephen@sherra.tt>
emillon added a commit to emillon/opam-repository that referenced this issue Apr 17, 2024
CHANGES:

### Fixed

- Fix overflow in sendfile stubs (copy of large files could fail or end with
  truncated files) (ocaml/dune#10333, @tonyfettes)

- Fix crash when a rule with a directory target is disabled with `enabled_if`
  (ocaml/dune#10382, fixes ocaml/dune#10310, @gridbugs)

- melange: remove all restrictions around virtual libraries in Melange. They
  may be used as otherwise in libraries and executables. (ocaml/dune#10412, @anmonteiro)

- spawn: fix compatibility with RHEL7 (ocaml/dune#10428, @emillon)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment