Bug 21591 – Mangling problem wrt. backrefs and function types

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-01-29T13:59:48Z
Last change time
2021-02-13T12:30:03Z
Keywords
pull
Assigned to
No Owner
Creator
kinke

Comments

Comment #0 by kinke — 2021-01-29T13:59:48Z
First off, I don't have a reduced testcase for reproduction, sorry. While investigating a linker error with DMD v2.095.0, it turned out that a library A defines an instantiation of pure nothrow @nogc @trusted bool core.internal.array.equality.__equals!(void function(), void function()).__equals(scope const(void function()[]), scope const(void function()[])) as `_D4core8internal5array8equality__T8__equalsTPFZvTQfZQsFNaNbNiNeMxAPQwMxQgZb`. The executable B also instantiates it, but all instances get culled (fine). The external symbol is mangled slightly differently though: `_D4core8internal5array8equality__T8__equalsTPFZvTQfZQsFNaNbNiNeMxAPFZvMxQhZb` (missing backref for `FZv`). Direct comparison: A: _D4core8internal5array8equality__T8__equalsTPFZvTQfZQsFNaNbNiNeMxAPQwMxQgZb B: _D4core8internal5array8equality__T8__equalsTPFZvTQfZQsFNaNbNiNeMxAPFZvMxQhZb
Comment #1 by kinke — 2021-01-29T14:18:19Z
Looking at dmd/dmangle.d, some missing type merge must be causing this (the backrefs depend on equivalent types sharing the same `Type` instance).
Comment #2 by dlang-bot — 2021-01-29T18:23:43Z
@kinke created dlang/dmd pull request #12166 "[stable] Fix Issue 21591 - missed backrefs in mangled names wrt. unmerged function types" fixing this issue: - Fix Issue 21591 - missed backrefs in mangled names wrt. unmerged function types TypeFunctions are apparently special and not merged, so make sure to use the generic merged function type as backref cache key. Unfortunately, this requires special care to prevent an infinite recursion, as merging is based on mangling. https://github.com/dlang/dmd/pull/12166
Comment #3 by dlang-bot — 2021-02-04T09:15:07Z
dlang/dmd pull request #12166 "[stable] Fix Issue 21591 - missed backrefs in mangled names wrt. unmerged function types" was merged into stable: - 580d65d61e75b9a3724981a52ae67dcc0d9010bd by Martin Kinkelin: Fix Issue 21591 - missed backrefs in mangled names wrt. unmerged function types TypeFunctions are apparently special and not merged, so make sure to use the generic merged function type as backref cache key. Unfortunately, this requires special care to prevent an infinite recursion, as merging is based on mangling. https://github.com/dlang/dmd/pull/12166
Comment #4 by dlang-bot — 2021-02-13T12:30:03Z
dlang/dmd pull request #12195 "Merge stable" was merged into master: - d8668e1afa3c89d2ed50a86d7e495f9aa860e5bf by Martin Kinkelin: Fix Issue 21591 - missed backrefs in mangled names wrt. unmerged function types (#12166) TypeFunctions are apparently special and not merged, so make sure to use the generic merged function type as backref cache key. Unfortunately, this requires special care to prevent an infinite recursion, as merging is based on mangling. https://github.com/dlang/dmd/pull/12195