Skip to content
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

Fix colliding WinEH TypeDescriptors for exceptions with the same TypeInfo_Class name #3614

Merged
merged 2 commits into from
Nov 13, 2020

Conversation

kinke
Copy link
Member

@kinke kinke commented Nov 13, 2020

[Extracted from #3517.]

As reported in #3501 (comment).

Previously, LDC would simply override an existing TypeDescriptor global with an equivalent definition if assertions were disabled.

Use different equivalent TypeDescriptors in this exotic case now, by using proper mangling. [The linker can presumably still fold duplicates via ICF.]

Ideally, these descriptors would be truly unique, but WinEH depends on string comparisons to check for matching catch clauses, and currently depends on TypeInfo_Class.name to generate these strings at runtime when throwing an exception, see https://github.com/ldc-developers/druntime/blob/19731a92a97dbe4d7f7a4e15ceaff8444a1f879a/src/ldc/eh_msvc.d#L192-L211.
So if those names were fully qualified (cd->toPrettyChars(*true*) during ClassInfo generation), we'd be fine, but that'd obviously be a breaking change and diverge from upstream.

…Info_Class name

As reported in ldc-developers#3501 (comment).

Previously, LDC would simply override an existing TypeDescriptor global
with an equivalent definition if assertions were disabled.

Use different equivalent TypeDescriptors in this exotic case now, by
using proper mangling. [The linker can presumably still fold duplicates
via ICF.]

Ideally, these descriptors would be truly unique, but WinEH depends on
string comparisons to check for matching catch clauses, and currently
depends on TypeInfo_Class.name to generate these strings at runtime when
throwing an exception, see
https://github.com/ldc-developers/druntime/blob/19731a92a97dbe4d7f7a4e15ceaff8444a1f879a/src/ldc/eh_msvc.d#L192-L211.
So if those names were fully qualified (`cd->toPrettyChars(*true*)`
during ClassInfo generation), we'd be fine, but that'd obviously be a
breaking change and diverge from upstream.
Instead of the ClassInfo global, which could theoretically be subject to
global variable replacement.
@kinke kinke merged commit 4abc48c into ldc-developers:master Nov 13, 2020
@kinke kinke deleted the wineh_desc2 branch November 13, 2020 14:18
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