Skip to content

Commit df48847

Browse files
authored
Merge pull request #62997 from mikeash/null-symbolic-reference-fatal-error
[Runtime] Fatal error when resolving a symbolic reference to NULL.
2 parents 5368235 + 7b33d2c commit df48847

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

stdlib/public/runtime/MetadataLookup.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,22 @@ ResolveAsSymbolicReference::operator()(SymbolicReferenceKind kind,
119119
const void *base) {
120120
// Resolve the absolute pointer to the entity being referenced.
121121
auto ptr = resolveSymbolicReferenceOffset(kind, isIndirect, offset, base);
122+
if (SWIFT_UNLIKELY(!ptr)) {
123+
auto symInfo = SymbolInfo::lookup(base);
124+
const char *fileName = "<unknown>";
125+
const char *symbolName = "<unknown>";
126+
if (symInfo) {
127+
if (symInfo->getFilename())
128+
fileName = symInfo->getFilename();
129+
if (symInfo->getSymbolName())
130+
symbolName = symInfo->getSymbolName();
131+
}
132+
swift::fatalError(
133+
0,
134+
"Failed to look up symbolic reference at %p - offset %" PRId32
135+
" - symbol %s in %s\n",
136+
base, offset, symbolName, fileName);
137+
}
122138

123139
// Figure out this symbolic reference's grammatical role.
124140
Node::Kind nodeKind;

0 commit comments

Comments
 (0)