Title: IR Optimizer spec never terminates at hspec seeds 109, 152 and 478 · Issue #348 · purescript-lua/purescript-lua · GitHub
Open Graph Title: IR Optimizer spec never terminates at hspec seeds 109, 152 and 478 · Issue #348 · purescript-lua/purescript-lua
X Title: IR Optimizer spec never terminates at hspec seeds 109, 152 and 478 · Issue #348 · purescript-lua/purescript-lua
Description: Problem The IR Optimizer spec group contains optimization keeps expressions well-scoped, a hedgehog property that feeds generated well-scoped IR expressions through the whole optimizedUberModule pipeline (the full optimizer: uniquificati...
Open Graph Description: Problem The IR Optimizer spec group contains optimization keeps expressions well-scoped, a hedgehog property that feeds generated well-scoped IR expressions through the whole optimizedUberModule pi...
X Description: Problem The IR Optimizer spec group contains optimization keeps expressions well-scoped, a hedgehog property that feeds generated well-scoped IR expressions through the whole optimizedUberModule pi...
Opengraph URL: https://github.com/purescript-lua/purescript-lua/issues/348
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"IR Optimizer spec never terminates at hspec seeds 109, 152 and 478","articleBody":"## Problem\n\nThe `IR Optimizer` spec group contains `optimization keeps expressions well-scoped`, a hedgehog property that feeds generated well-scoped IR expressions through the whole `optimizedUberModule` pipeline (the full optimizer: uniquification, the optimize+dce fixpoint, and everything after it) and asserts that the result has no unbound local reference. On some inputs that call never returns.\n\nThe stall is reproducible once hspec's global seed is pinned. Over seeds 1..500 of the group, three of them — **109, 152 and 478** — never finish:\n\n```\n$ timeout 900 spec --match \"IR Optimizer\" --seed 109\nexit=124 elapsed=900s\n```\n\nA complete run of the same group takes **0.35 s**, so 900 seconds is over 2500× the normal cost, and the process was still killed by the cap rather than finishing. It is a livelock, not a memory blow-up: sampled over a minute the process holds 99.8 % of one core with a flat 50 MiB resident set, so nothing is growing — the optimizer is spinning.\n\nThe output stops at exactly the same place every time. These are the last lines before the process goes quiet, with the property that never reports:\n\n```\n inlining bindings does not unbind let-bound references [✔]\n ✓ property passed 1 test.\n beta reduction does not unbind a reference shadowed by the binder [✔]\n ✓ property passed 1 test.\n blanking an unused shadowing binder keeps outer references bound [✔]\n ✓ property passed 1 test.\n```\n\n`blanking an unused shadowing binder keeps outer references bound` is the test declared immediately before the property, so the hang is inside `optimization keeps expressions well-scoped` itself.\n\n## How it shows up\n\nAs an intermittent CI/local hang rather than an assertion failure: with no `--seed`, hspec draws a random one, so roughly 3 runs in 500 of that group wedge and are eventually killed by whatever timeout wraps them. Repository policy already treats a hang as a failing test, not as flakiness, but the failure mode is easy to misread because the suite prints nothing at all — the group simply stops emitting lines.\n\n## Approach\n\nThe pipeline is a fixpoint (`RunFixpoint \"optimize+dce\"`, plus the enclosing settle/lower phases), so the likeliest shape is two rewrites that undo each other on some generated term, with each round reporting `Rewritten` and the fixpoint never converging. A 1000-round backstop was added to the fixpoint in an earlier change; either these seeds spin inside a single round, or the spin is in a loop that the backstop does not cover.\n\n## Verification / Measurement\n\nThe group must complete for every seed, so the check is the same sweep that found the stall: run `spec --match \"IR Optimizer\"` over a range of pinned seeds and require that none of them exceeds a timeout generous against the 0.35 s a full run costs.\n\n```\n$ cabal build test:spec\n$ timeout 60 $(cabal list-bin spec) --match \"IR Optimizer\" --seed 109 ; echo \"exit=$?\"\n```\n\nPrints the group up to `blanking an unused shadowing binder keeps outer references bound` and then hangs; `exit=124`. Seeds 152 and 478 behave the same way. Any other seed in 1..500 completes in about a third of a second. Reproduced on `main` at d79d95f.\n\n## Prerequisites / Relations\n\nIndependent — nothing needs to land first.\n\n#345 was a different intermittent red in the same group: `freshenBinders` renamed a free reference that shared a `Let` binder's name, which surfaced as `inlines expressions referenced once` failing an alpha-equivalence check. That is fixed (#347). These three seeds hang identically before and after that fix — the same seed set, {109, 152, 478}, on both builds — so nothing about it is shared.\n\nThere is also a structural reason the two cannot be the same bug. `optimizedUberModule` begins with the uniquify pass:\n\n```haskell\n settlePhase =\n [ -- The entry pass (issue #139): establishes the global-uniqueness\n -- condition (GUC = 'UniqueBinders') that every\n -- following pass requires and preserves.\n RunPass uniquifyPass\n , RunFixpoint \"optimize+dce\" (optimizePass :| [dcePass])\n , …\n```\n\nso every expression this property optimizes has globally unique binders, the discipline under which the #345 shape cannot arise. The sibling property that did catch #345 calls `optimizedExpression` on deliberately non-uniquified terms instead.\n\n## Acceptance criteria\n\n- `spec --match \"IR Optimizer\" --seed 109` terminates, and likewise for seeds 152 and 478.\n- Whatever term drives the non-termination is captured as an example-based regression test, so the fix is pinned by something that does not depend on a generator draw.\n- If the cause is a non-converging rewrite pair, the fixpoint reports a diagnosable failure (naming the passes that keep firing) rather than spinning silently.\n","author":{"url":"https://github.com/Unisay","@type":"Person","name":"Unisay"},"datePublished":"2026-07-29T09:24:03Z","url":"https://github.com/purescript-lua/purescript-lua/issues/348"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5bb8ac83-83d3-3695-a848-a29aa2da3243 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E924:2D96F1:7A908A:A4A8C0:6B00DB5F |
| html-safe-nonce | dbee7020b333167d3450bb0eeaba5ea811d3e77c22ac3aa7f546b2d674d9881e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOTI0OjJEOTZGMTo3QTkwOEE6QTRBOEMwOjZCMDBEQjVGIiwidmlzaXRvcl9pZCI6IjU2MTQ3MDgzMjE0NzU5NDMyNjMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 0b00c2083d2deffe85c40a8d49d17ead700624eb295a20c70563cbc503235f3a |
| hovercard-subject-tag | issue:5007626493 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/purescript-lua/purescript-lua/348/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1fc47d0c9e3cbce75e93aea993621cdcf4624fa15ec7cd0d5578385e1c79b0a1/purescript-lua/purescript-lua/issues/348 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1fc47d0c9e3cbce75e93aea993621cdcf4624fa15ec7cd0d5578385e1c79b0a1/purescript-lua/purescript-lua/issues/348 |
| og:image:alt | Problem The IR Optimizer spec group contains optimization keeps expressions well-scoped, a hedgehog property that feeds generated well-scoped IR expressions through the whole optimizedUberModule pi... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Unisay |
| hostname | github.com |
| expected-hostname | github.com |
| None | 043c3f30fbcbe2c6c8e729e10cbbbc90c406546f9fbbb67c648d38f6b7d16daf |
| turbo-cache-control | no-preview |
| go-import | github.com/purescript-lua/purescript-lua git https://github.com/purescript-lua/purescript-lua.git |
| octolytics-dimension-user_id | 131581790 |
| octolytics-dimension-user_login | purescript-lua |
| octolytics-dimension-repository_id | 587200487 |
| octolytics-dimension-repository_nwo | purescript-lua/purescript-lua |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 587200487 |
| octolytics-dimension-repository_network_root_nwo | purescript-lua/purescript-lua |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 5425dc24e8bd8d6fca9641a12afc984825a43875 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width