ocaml / ocaml/ocamlbuild

non-termination

Open
#83 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
OCaml
Stars
133
Forks
87
PR merge metrics
No merged PRs in 30d

Description

To reproduce, create a directory with just the following file:

$ cat myocamlbuild.ml 
open Printf
open Ocamlbuild_plugin

let () = dispatch (function
  | After_rules -> (
      printf "BEFORE RULE\n%!";
      rule "m4" ~dep:"%.m4" ~prod:"%" (fun _ _ -> Nop);
      printf "AFTER RULE\n%!"
    )
  | _ -> ()
)

Now try to build anything:

$ ocamlbuild foo
Finished, 1 target (0 cached) in 00:00:00.
BEFORE RULE
AFTER RULE
(* program hangs ... never finishes here *)

The issue is related to the "%" pattern. A more specific pattern such as ~dep:"%.ml.m4" ~prod:"%.ml" avoids the problem. I guess the "%" pattern is too general and ocamlbuild goes into a loop trying to produce foo from foo.m4, which doesn't exist so it tries to produce that from foo.m4.m4, and so on.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the hang with myocamlbuild.ml and the ocamlbuild foo command, then trace handling of the rule pattern "%.m4" to "%". Compare it with the specific "%.ml.m4" to "%.ml" pattern. Done means the broad pattern no longer causes non-termination and the reproducer exits normally.

Written by the indexing model from the issue text.

Assessment

Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.