Description
When collecting PInvoke in managed code and generate native m2n function, the function naming is following rules like
|
string FixupSymbolName(string name) |
Regarding special chars, there is a table
|
private static readonly char[] s_charsToReplace = new[] { '.', '-', '+', '<', '>' }; |
With the above logic, the generated function map would only have underscore representing all special chars.
However in interpreter logic, either .Net9
or .Net8
The function name resolving logic cannot cover all cases when generating them as only '.' is replaced. There should be logic which resembles the C#
FixupSymbolName. Otherwise we may resolve pinvoke function name from
Assemly-CSharp-firstpass.dll to
Also the function length currently 128 seems not sufficient. I have doubled it to 256. Any consideration here regarding the 128 length?
Reproduction Steps
Having C# functions marked with PInvoke in assembly with - in its name (or other special chars)
Expected behavior
Resolve those chars as understore
Actual behavior
Failed to find those functions in wasm_native_to_interp_map (calling wasm_dl_get_native_to_interp )
Regression?
Yes
Known Workarounds
Implement FixupSymbolName logic in naive code when calling get_native_to_interp so as to keep align with the way it is generated(Module name in particular). And increase the key size limit to 256 for some super long generated functions.
Configuration
.Net8
.Net9
Other information
No response
Description
When collecting PInvoke in managed code and generate native m2n function, the function naming is following rules like
runtime/src/tasks/WasmAppBuilder/ManagedToNativeGenerator.cs
Line 106 in 3eb8c7f
Regarding special chars, there is a table
runtime/src/tasks/WasmAppBuilder/ManagedToNativeGenerator.cs
Line 39 in 3eb8c7f
With the above logic, the generated function map would only have underscore representing all special chars.
However in interpreter logic, either .Net9
runtime/src/mono/browser/runtime/runtime.c
Line 217 in 3eb8c7f
or .Net8
runtime/src/mono/wasm/runtime/driver.c
Line 407 in 13d578b
The function name resolving logic cannot cover all cases when generating them as only '.' is replaced. There should be logic which resembles the C#
FixupSymbolName. Otherwise we may resolve pinvoke function name fromAssemly-CSharp-firstpass.dlltoAlso the function length currently 128 seems not sufficient. I have doubled it to 256. Any consideration here regarding the 128 length?
Reproduction Steps
Having C# functions marked with PInvoke in assembly with
-in its name (or other special chars)Expected behavior
Resolve those chars as understore
Actual behavior
Failed to find those functions in
wasm_native_to_interp_map(callingwasm_dl_get_native_to_interp)Regression?
Yes
Known Workarounds
Implement
FixupSymbolNamelogic in naive code when callingget_native_to_interpso as to keep align with the way it is generated(Module name in particular). And increase the key size limit to 256 for some super long generated functions.Configuration
.Net8
.Net9
Other information
No response