[PR #685] [CLOSED] fix(dotnet): preserve C identifier underscores in native matching #2166

Closed
opened 2026-10-16 21:15:08 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/685
Author: @rudycelekli
Created: 10/6/2026
Status: ❌ Closed

Base: main ← Head: fix/rea-native-symbol-abi-prefix-20261006


📝 Commits (1)

  • 32f4c89 fix(dotnet): preserve C identifier underscores in native matching

📊 Changes

2 files changed (+52 additions, -5 deletions)

View changed files

📝 src/domain/managedNativeVerificationMatch.ts (+6 -5)
📝 tests/conformance/providers/managed/managedNativeVerification.test.ts (+46 -0)

📄 Description

Problem

Managed/native symbol matching removes all leading underscores from both the managed declaration and native name. This collapses distinct C identifiers. A declaration open_native can be linked to a Mach-O export __open_native, which actually corresponds to C _open_native. The reverse raw-equality shortcut would be wrong too: declaration _open_native must not match export _open_native, which corresponds to C open_native.

Change

Preserve the managed declaration spelling. Remove exactly one ABI underscore from Mach-O export names for candidate comparison; do not apply that normalization to function-dossier names. Existing declared decorations and exact-name evidence behavior remain intact.

Verification

Two owned C dylibs compiled with the host clang provide actual controls:

Dylib C symbol Actual loader open_native Actual loader _open_native Public static workflow
open_native (Mach-O _open_native) returns 9 unavailable first inferred, second unresolved
_open_native (Mach-O __open_native) unavailable returns 7 first unresolved, second inferred

The workflow uses owned PE P/Invoke declarations with exact spelling, actual filesystem target resolution, the public ManagedStaticProvider, real NativeMacOSProvider/xcrun inspection, and authenticated Evidence. Before the fix, the crossed names are incorrectly inferred; after it, all four controls agree with the native loader observations.

  • 9 focused managed/native conformance tests pass.
  • All five npm run check tasks pass with Node 24.18.0 and the exact lock.
  • npm run verify:managed: all 11 source-owned static-format scenarios pass; optional operator manifest/ILSpy verification is unconfigured and not claimed.

The actual native loader controls validate these C export names. Static candidate matching still does not prove CLR binding, marshaling, managed call reachability, or target execution.

AI assistance was used for investigation, implementation, tests, description and independent patch review. Actual provider proof and its limits are stated above.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/685 **Author:** [@rudycelekli](https://github.com/rudycelekli) **Created:** 10/6/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/rea-native-symbol-abi-prefix-20261006` --- ### 📝 Commits (1) - [`32f4c89`](https://github.com/morluto/rea/commit/32f4c89403468ca3d9ce6e78c263cf5fa37aa38c) fix(dotnet): preserve C identifier underscores in native matching ### 📊 Changes **2 files changed** (+52 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `src/domain/managedNativeVerificationMatch.ts` (+6 -5) 📝 `tests/conformance/providers/managed/managedNativeVerification.test.ts` (+46 -0) </details> ### 📄 Description ## Problem Managed/native symbol matching removes *all* leading underscores from both the managed declaration and native name. This collapses distinct C identifiers. A declaration `open_native` can be linked to a Mach-O export `__open_native`, which actually corresponds to C `_open_native`. The reverse raw-equality shortcut would be wrong too: declaration `_open_native` must not match export `_open_native`, which corresponds to C `open_native`. ## Change Preserve the managed declaration spelling. Remove exactly one ABI underscore from Mach-O export names for candidate comparison; do not apply that normalization to function-dossier names. Existing declared decorations and exact-name evidence behavior remain intact. ## Verification Two owned C dylibs compiled with the host clang provide actual controls: | Dylib C symbol | Actual loader `open_native` | Actual loader `_open_native` | Public static workflow | |---|---|---|---| | `open_native` (Mach-O `_open_native`) | returns 9 | unavailable | first inferred, second unresolved | | `_open_native` (Mach-O `__open_native`) | unavailable | returns 7 | first unresolved, second inferred | The workflow uses owned PE P/Invoke declarations with exact spelling, actual filesystem target resolution, the public `ManagedStaticProvider`, real `NativeMacOSProvider`/xcrun inspection, and authenticated Evidence. Before the fix, the crossed names are incorrectly inferred; after it, all four controls agree with the native loader observations. - 9 focused managed/native conformance tests pass. - All five `npm run check` tasks pass with Node 24.18.0 and the exact lock. - `npm run verify:managed`: all 11 source-owned static-format scenarios pass; optional operator manifest/ILSpy verification is unconfigured and not claimed. The actual native loader controls validate these C export names. Static candidate matching still does not prove CLR binding, marshaling, managed call reachability, or target execution. AI assistance was used for investigation, implementation, tests, description and independent patch review. Actual provider proof and its limits are stated above. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-16 21:15:08 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#2166
No description provided.