Crash on IR Generation in LLVM DenseMap, but it happens only in some configurations (Patch included) #70345
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
crash
Bug: A crash, i.e., an abnormal termination of software
triage needed
This issue needs more specific labels
Description
I'm currently compiling Swift in Fedora, and I encountered a crash during IR generation, but it occurs only in some configurations.
Steps to reproduce
Detailed build scripts are here
Expected result
Build succeeds, though some tests may fail
Actual result
In some cases, build fails.
Cases that do not crash
Cases that crash
The crash stack trace is as follows:
Patch
The crash occurred in LLVM DenseMap, and I found that it was caused by the following code.
https://github.com/apple/swift/blob/9d033372ac16ac72aadfadc4d1ad4ef2462babe0/lib/IRGen/GenDecl.cpp#L5451
From what I understand, the
GlobalFuncs
is a DenseMap that mapsLinkEntity
tollvm::Function*
.operator []
finds the value for the key, and if it doesn't exist, it creates a new value and returns it.It seems that this code is logically correct, but somehow it crashes. I think this is because the
entity
is not unique, but I'm not sure.Instead of using
operator []
, I changed the code to usefind
andinsert
as follows.(Full patch is here. It might need adjustments to apply to the main branch.)
With this patch, the crash is resolved, and the build succeeds.
The text was updated successfully, but these errors were encountered: