Skip to content

Utilising Swift demangler can cause hard-stop #912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
BananaIguana opened this issue Apr 16, 2025 · 2 comments · Fixed by #917 · May be fixed by #913
Closed

Utilising Swift demangler can cause hard-stop #912

BananaIguana opened this issue Apr 16, 2025 · 2 comments · Fixed by #917 · May be fixed by #913
Assignees

Comments

@BananaIguana
Copy link

Firstly, I'm not entirely sure if this is a bug or user error/setup so hopefully someone more knowledgable than myself could confirm.

I wrote a tool which parses Swift symbols from a Mach-O binary. It reads __fieldmd metadata and I extract the demangled object names using this crate.

Environment

symbolic-demangle = "12.15.3"
symbolic-common = "12.15.3"

Steps to Reproduce

Demangle string $sTB, read from binary. All other strings either demangle fine or the original string is returned. (I'm not sure if this is an valid or invalid mangled name)

Expected Result

I would have expected either:

  • a Result or Option type to allow capture of the error.
  • The original string returned if failed to demangle.
  • try_demangle to at least not hard stop.

Actual Result

The code hard stops on this assert:

if (PassID < 0 || PassID >= MAX_SPECIALIZATION_PASS)
{
    assert(false && "unexpected pass id");
    return nullptr;
}

Since I cannot control the outcome when using data driven output, I can not safely use this library unless there is a workaround or an alternative configuration.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Apr 16, 2025
@Dav1dde
Copy link
Member

Dav1dde commented Apr 16, 2025

The upstream swift demangler code does no longer have that assert: https://github.com/swiftlang/swift/blob/ace5c20b12ef404ef4f169a5484c2ae8b981cfc3/lib/Demangling/Demangler.cpp#L3544-L3547

Looks like we should patch that assert out and/or update the sources again.

@Dav1dde
Copy link
Member

Dav1dde commented May 2, 2025

Releasing this fix as 12.15.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
3 participants