Skip to content

Merge pull request #14010 from mshinwell/string-ops-machtypes#25

Open
dijkstracula wants to merge 1 commit into
5.4.0-semgrepfrom
nathan/backport-ocaml-14010-5.4
Open

Merge pull request #14010 from mshinwell/string-ops-machtypes#25
dijkstracula wants to merge 1 commit into
5.4.0-semgrepfrom
nathan/backport-ocaml-14010-5.4

Conversation

@dijkstracula

Copy link
Copy Markdown

Summary

Backport ocaml/ocaml#14010
to 5.4.0-semgrep.

The fix preserves address-typed Cmm expressions when computing addresses for
string/bytes operations and unaligned loads and stores. Without this distinction,
Flambda may fail to preserve the liveness relationship between an interior
address and its underlying allocation, resulting in GC-related memory
corruption.

This was encountered as nondeterministic corruption in an allocation-heavy
property test.

Backport Notes

The compiler change applies cleanly to OCaml 5.4. No source adaptation was
required: the resulting asmcomp/cmm_helpers.ml patch matches upstream ocaml#14010
exactly.

The conflicting upstream Changes entry was omitted because it records
inclusion in an upstream OCaml release, whereas this is a Semgrep-fork
backport.

No other fork code is changed.

Validation

  • Clean Flambda bootstrap of the exact branch:
    ./configure --enable-flambda && make -j8
  • Confirmed the resulting compiler reports:
    • version: 5.4.0+semgrep-fork@23106c6472
    • flambda: true
  • Compiled the current Semgrep preprocessor evaluator with the resulting
    compiler at -O3.
  • Ran four seeded allocation-heavy evaluator checks at 5,000,000 iterations
    each: 20,000,000 total cases passed.

The only changed source file is /Users/ntaylor/code/ocaml/asmcomp/cmm_helpers.ml:154.

Fix miscompilation / liveness errors for string operations
@dijkstracula
dijkstracula requested a review from nmote July 15, 2026 17:16
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants