Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

[MONO][Wasm] Potential function signature mismatch in m2n invoke #99514

Closed

Description

@Nemo-G

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.
image

However in interpreter logic, either .Net9

if (key [i] == '.')

or .Net8
if (key [i] == '.')

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
image

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

Activity

  1. ghost added
    needs-area-label
    on Mar 11, 2024
  2. added
    untriaged
    on Mar 11, 2024
  3. Nemo-G commented on Mar 11, 2024

    @Nemo-G
    Author

    #99241 Just saw a similar issue. Seems backqoutes can also be part of the special character list to be escaped/special handled.

  4. added
    arch-wasm
    os-browser
    and removed
    needs-area-label
    on Mar 11, 2024
  5. added and removed
    untriaged
    on Mar 14, 2024
  6. added this to the 9.0.0 milestone on Mar 14, 2024
  7. self-assigned this
    on Mar 25, 2024
  8. locked and limited conversation to collaborators on May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

arch-wasmarea-Build-monoos-browser

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions