Skip to content

fix(regex): own PCRE string buffers before release - #790

Merged
ropoctl merged 1 commit into
withlang-dev:mainfrom
ropoctl:fix/regex-owned-pcre-strings
Aug 16, 2026
Merged

ropoctl merged 1 commit into
withlang-dev:mainfrom
ropoctl:fix/regex-owned-pcre-strings

Conversation

@ropoctl

@ropoctl ropoctl commented Aug 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • copy PCRE error-message buffers into owned With strings before freeing the raw buffer
  • copy capture names out of PCRE-owned tables instead of consuming a borrowed C-string view
  • preserve all existing function signatures and ABI

Root cause

with_regex_error_message wrapped the allocated PCRE buffer with with_str_from_cstr, then passed that borrowed view to the consuming with_str_clone parameter. Dropping the consumed temporary freed the buffer once; the following explicit with_free(buf) freed the same pointer again. The debug allocator reported:

invalid free
panic: invalid free: pointer is not an allocated payload start

The same ownership error existed for capture-name table entries owned by PCRE.

Verification

  • direct unfixed reproduction: err_regex_invalid_literal.w aborts in the debug allocator
  • fixed direct reproduction: reports invalid regex literal: missing closing parenthesis
  • ./src/main build
  • ./src/main build :native-compile-error-tests — 733/733 pass
  • ./src/main build :fixpoint — byte-identical FIXPOINT

@ropoctl
ropoctl merged commit 6993738 into withlang-dev:main Aug 16, 2026
3 checks passed
ropoctl added a commit that referenced this pull request Aug 18, 2026
The 0xC0000005 access violation in SemaCheck's in-process regex
compilation (#798) was fixed by #790 (own PCRE string buffers before
release). These 8 compile-error tests verify regex-literal comptime
capture-group diagnostics; each now emits its exact expected
expect-check-fail diagnostic on native Windows with no crash.

Verified natively on Windows x86_64: all 8 tests produce their
expected diagnostics (7x undefined-variable, 1x invalid-regex-literal)
with zero access violations.
ropoctl added a commit that referenced this pull request Aug 18, 2026
The 0xC0000005 access violation in SemaCheck's in-process regex
compilation (#798) was fixed by #790 (own PCRE string buffers before
release). These 8 compile-error tests verify regex-literal comptime
capture-group diagnostics; each now emits its exact expected
expect-check-fail diagnostic on native Windows with no crash.

Verified natively on Windows x86_64: all 8 tests produce their
expected diagnostics (7x undefined-variable, 1x invalid-regex-literal)
with zero access violations.
ropoctl added a commit that referenced this pull request Aug 18, 2026
The regex-literal comptime validation crash (#798, 0xC0000005 on native
Windows) was fixed in #790. These compile_errors fixtures assert
'undefined variable' diagnostics and no longer need the skip-windows gate;
un-skip them so native Windows CI exercises the diagnostics.
ropoctl added a commit that referenced this pull request Aug 18, 2026
The 0xC0000005 access violation in SemaCheck's in-process regex
compilation (#798) was fixed by #790 (own PCRE string buffers before
release). These 8 compile-error tests verify regex-literal comptime
capture-group diagnostics; each now emits its exact expected
expect-check-fail diagnostic on native Windows with no crash.

Verified natively on Windows x86_64: all 8 tests produce their
expected diagnostics (7x undefined-variable, 1x invalid-regex-literal)
with zero access violations.
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.

1 participant