Skip to content

docs: attribute the vendored Rust demangler - #250

Open
r0ny123 wants to merge 2 commits into
danielplohmann:masterfrom
r0ny123:docs/vendored-demangler-attribution
Open

docs: attribute the vendored Rust demangler#250
r0ny123 wants to merge 2 commits into
danielplohmann:masterfrom
r0ny123:docs/vendored-demangler-attribution

Conversation

@r0ny123

@r0ny123 r0ny123 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

src/smda/common/labelprovider/rust_demangler/ is vendored third-party code, and it currently ships with no attribution. This adds it.

Part of a linear stack: #249#250#254#255. The NOTICE created here is extended by #255, and #249 and #254 conflict unless merged in order.

What is in there

The commit that introduced the directory says so plainly — "Vendors the rust_demangler library into smda/common/labelprovider/rust_demangler with robustness improvements ported from Ghidra". The upstream is teambi0s/rust_demangler, MIT, Copyright (c) 2021 Team bi0s. Several sites in the same directory also carry comments naming Ghidra's rust-demangle.c as the behaviour they follow; Ghidra is Apache-2.0.

Neither is recorded anywhere. LICENSE is the project's own BSD 2-Clause covering Daniel Plohmann and Steffen Enders, there is no NOTICE, and the package has no header. The MIT licence asks that its copyright and permission notice travel with copies and substantial portions, and this code is redistributed in the smda wheel on PyPI.

What this changes

  • A top-level NOTICE recording the MIT component with its copyright line and full permission text, and the Ghidra-derived behaviour with a pointer to Apache-2.0.
  • A one-line module docstring on the vendored package pointing at NOTICE, so the provenance is visible from the code as well as from the distribution root.
  • A line in the README's Credits section, which already acknowledges the other vendored algorithm implementations.

No code behaviour changes.

Packaging

NOTICE reaches both artifacts without any pyproject.toml change — setuptools' default license-file glob already covers NOTICE*. Verified rather than assumed:

python -m build
wheel : smda-4.4.7.dist-info/licenses/LICENSE, smda-4.4.7.dist-info/licenses/NOTICE
sdist : smda-4.4.7/LICENSE, smda-4.4.7/NOTICE

The Ghidra citation was wrong, and is corrected here

The in-code comments this attribution was drawn from name "Ghidra's rust-demangle.c". No such file exists. Ghidra's Rust demanglers are Java, at Ghidra/Features/Rust/src/main/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemanglerV0.java and RustDemanglerLegacy.java; the C sources Ghidra bundles are the GNU demangler, which is a different thing under a different licence. The Apache-2.0 statement was right, the file it credited was fictional.

The NOTICE now names those files, and the two comments that were the source of the error are corrected too, so the NOTICE's claim that the individual sites carry comments naming what they follow is actually true. It also records that Ghidra's own V0 demangler is a port of the rustc-demangle crate, which is the real upstream of the behaviour being reimplemented.

Every vendored component, not just the one that prompted this

The NOTICE opens by saying it lists the third-party code this product includes, so it lists all of it: Tarjan.py (Bas Westerbaan's py-tarjan) and DominatorTree.py (Armin Rigo's PyPy implementation) are credited alongside the demangler, matching the README paragraph the new line joins.

Note

This is an attribution correction, not a legal opinion. The MIT copyright line and permission text are reproduced from the upstream LICENSE rather than paraphrased.

Validation

python -m pytest tests/ -q                  1184 passed, 1 skipped
make lint                                   clean
make typecheck                              exit 0, no new diagnostics
python -m build                             NOTICE present in wheel and sdist

Demangled names were passed through a port of Ghidra's CondensedString
before being stored, so <Error as core::fmt::Display>::fmt reached the
report as <Error_as_core::fmt::Display>::fmt and A, B became A,B. Ghidra
needs that because a Ghidra symbol name cannot contain spaces; SMDA has
no such constraint, and already stores names with spaces from another
source -- 39 of the 399 names recovered from a PDB on a rust-lld x64
image contain them, because MSVC proc records spell them that way. The
condensation was applying one spelling rule to names from a symbol table
and another to names from a PDB, in the same report.

Removing it exposed a printer bug it had been masking: a function
pointer's ABI ran into its fn, giving unsafe extern "C"fn(*mut u8). The
closing quote was emitted without the trailing space, and comparisons
against the reference implementation could not see it because the
condensation deleted that space from both sides. One existing test
asserted the wrong spelling and is corrected.

Measured against rustc-demangle 0.1.28 on 147 real symbols read out of a
rust-lld x64 image: 93 of 147 matched byte for byte before, 146 after
dropping the condensation, and 147 after the ABI fix.

Cross-checked against the 18 mangled symbols in the reference
implementation's own test corpus: 8 match, 9 raise and so keep the name
the binary gave them, and 1 differs -- a punycode identifier this port
renders as a placeholder, which is pre-existing and left alone here.
@r0ny123
r0ny123 force-pushed the docs/vendored-demangler-attribution branch from c253200 to 1dbe7eb Compare August 15, 2026 04:37
src/smda/common/labelprovider/rust_demangler/ is vendored third-party
code and carries no attribution. The commit that introduced it says so
directly -- it vendors the rust_demangler package by Team bi0s, MIT
licensed, with robustness behaviour reimplemented from Ghidra, which is
Apache-2.0. Neither is recorded: LICENSE covers only this project's own
BSD 2-Clause, there is no NOTICE, and the package has no header. The MIT
licence asks that its copyright and permission notice travel with copies
and substantial portions, and this code is redistributed in the wheel
published to PyPI.

Add a NOTICE carrying the MIT copyright line and permission text and a
pointer to Apache-2.0 for the Ghidra-derived parts, a docstring on the
vendored package pointing at it, and a line in the README credits.

The in-code comments this attribution was drawn from named "Ghidra's
rust-demangle.c", and no such file exists: Ghidra's Rust demanglers are
Java, at Ghidra/Features/Rust/src/main/java/ghidra/app/plugin/core/
analysis/rust/demangler/RustDemanglerV0.java and RustDemanglerLegacy.java.
Name those instead, in the NOTICE and in the two comments that were the
source of the error, and record that Ghidra's own V0 demangler is a port
of the rustc-demangle crate, which is the real upstream of the behaviour.

The NOTICE lists every vendored component rather than only the one that
prompted it, so Tarjan.py and DominatorTree.py -- both already credited
in the README paragraph the new line joins -- appear alongside it.

No pyproject change is needed: setuptools' default license-file glob
already matches NOTICE*, and a build confirms it reaches both the wheel
(dist-info/licenses/NOTICE) and the sdist.
@r0ny123

r0ny123 commented Aug 15, 2026

Copy link
Copy Markdown
Contributor Author

A review pass found the attribution itself was wrong, which is the one thing an attribution PR cannot be.

The in-code comments this was drawn from name "Ghidra's rust-demangle.c". No such file exists: Ghidra's Rust demanglers are Java, at Ghidra/Features/Rust/src/main/java/ghidra/app/plugin/core/analysis/rust/demangler/RustDemanglerV0.java and RustDemanglerLegacy.java. The Apache-2.0 statement was right, the source it credited was fictional. The NOTICE now names those files, and I corrected the two comments that were the origin of the error so the NOTICE's claim that "the individual sites carry comments naming what they follow" is actually true. It also records that Ghidra's own V0 demangler is a port of the rustc-demangle crate, which is the real upstream of the behaviour.

The NOTICE also opened by saying it lists the third-party code this product includes, then listed only one component. Tarjan.py (Bas Westerbaan's py-tarjan) and DominatorTree.py (Armin Rigo's PyPy implementation) — both already credited in the README paragraph the new line joins — are now listed alongside it.

This branch has been rebased into a linear stack, #249#250#254#255, so that the NOTICE created here is extended rather than duplicated by #255, and so that #249 and #254 (which conflict) merge in a defined order.

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