Skip to content

Commit fe9de7b

Browse files
committed
[Runtime] Fix _swift_validatePrespecializedMetadata when type lookup fails.
When we fail to look up a type by name, we print an error, then try to compare anyway, which crashes. Skip the comparison when that happens. While we're in there, modify _swift_validatePrespecializedMetadata to be more useful for debugging, by removing the parameters and having it print the results directly.
1 parent 1cccd79 commit fe9de7b

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

include/swift/Runtime/LibPrespecialized.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ Metadata *getLibPrespecializedMetadata(const TypeContextDescriptor *description,
6161
// were validated (which is the total number in the table), and outFailed is set
6262
// to the number that failed validation.
6363
SWIFT_RUNTIME_EXPORT
64-
void _swift_validatePrespecializedMetadata(unsigned *outValidated,
65-
unsigned *outFailed);
64+
void _swift_validatePrespecializedMetadata();
6665

6766
#endif // SWIFT_LIB_PRESPECIALIZED_H

stdlib/public/runtime/LibPrespecialized.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -149,20 +149,17 @@ swift::getLibPrespecializedMetadata(const TypeContextDescriptor *description,
149149
return result;
150150
}
151151

152-
void _swift_validatePrespecializedMetadata(unsigned *outValidated,
153-
unsigned *outFailed) {
154-
if (outValidated)
155-
*outValidated = 0;
156-
if (outFailed)
157-
*outFailed = 0;
158-
152+
void _swift_validatePrespecializedMetadata() {
159153
auto *data = getLibPrespecializedData();
160154
if (!data) {
161155
return;
162156
}
163157

164158
disableForValidation = true;
165159

160+
unsigned validated = 0;
161+
unsigned failed = 0;
162+
166163
auto *metadataMap = data->getMetadataMap();
167164
auto metadataMapSize = metadataMap->arraySize;
168165
auto *array = metadataMap->array();
@@ -171,8 +168,7 @@ void _swift_validatePrespecializedMetadata(unsigned *outValidated,
171168
if (!element.key || !element.value)
172169
continue;
173170

174-
if (outValidated)
175-
(*outValidated)++;
171+
validated++;
176172

177173
const char *mangledName = element.key;
178174
// Skip the leading $.
@@ -186,12 +182,16 @@ void _swift_validatePrespecializedMetadata(unsigned *outValidated,
186182
"Prespecializations library validation: unable to build metadata "
187183
"for mangled name '%s'\n",
188184
mangledName);
189-
if (outFailed)
190-
(*outFailed)++;
185+
failed++;
186+
continue;
191187
}
192188

193189
if (!compareGenericMetadata(result.getType().getMetadata(), element.value))
194-
if (outFailed)
195-
(*outFailed)++;
190+
failed++;
196191
}
192+
193+
fprintf(stderr,
194+
"Prespecializations library validation: validated %u entries, %u "
195+
"failures.\n",
196+
validated, failed);
197197
}

0 commit comments

Comments
 (0)