Skip to content

Commit 4507307

Browse files
authored
Merge pull request #62982 from xymus/deser-safety-step2
[Serialization] Misc prep for the deserialization safety feature
2 parents 6ca5716 + faeb226 commit 4507307

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

include/swift/Basic/LangOptions.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,12 @@ namespace swift {
356356
/// new enough?
357357
bool EnableTargetOSChecking = true;
358358

359-
/// Whether to attempt to recover from missing cross-references and other
359+
/// Whether to attempt to recover from missing cross-references,
360+
/// differences in APIs between language versions, and other
360361
/// errors when deserializing from a binary swiftmodule file.
361362
///
362-
/// This flag should only be used in testing.
363+
/// This feature should only be disabled for testing as regular builds
364+
/// rely heavily on it.
363365
bool EnableDeserializationRecovery = true;
364366

365367
/// Enable early skipping deserialization of decls that are marked as

lib/Serialization/Deserialization.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7149,7 +7149,8 @@ static llvm::Error consumeErrorIfXRefNonLoadedModule(llvm::Error &&error) {
71497149
// Missing module errors are most likely caused by an
71507150
// implementation-only import hiding types and decls.
71517151
// rdar://problem/60291019
7152-
if (error.isA<XRefNonLoadedModuleError>()) {
7152+
if (error.isA<XRefNonLoadedModuleError>() ||
7153+
error.isA<UnsafeDeserializationError>()) {
71537154
consumeError(std::move(error));
71547155
return llvm::Error::success();
71557156
}
@@ -7161,7 +7162,8 @@ static llvm::Error consumeErrorIfXRefNonLoadedModule(llvm::Error &&error) {
71617162
auto errorInfo = takeErrorInfo(std::move(error));
71627163
auto *TE = static_cast<TypeError*>(errorInfo.get());
71637164

7164-
if (TE->underlyingReasonIsA<XRefNonLoadedModuleError>()) {
7165+
if (TE->underlyingReasonIsA<XRefNonLoadedModuleError>() ||
7166+
TE->underlyingReasonIsA<UnsafeDeserializationError>()) {
71657167
consumeError(std::move(errorInfo));
71667168
return llvm::Error::success();
71677169
}
@@ -7497,6 +7499,7 @@ void ModuleFile::finishNormalConformance(NormalProtocolConformance *conformance,
74977499
// errors - we're just doing a best effort to create the
74987500
// module in that case.
74997501
if (witnessSubstitutions.errorIsA<XRefNonLoadedModuleError>() ||
7502+
witnessSubstitutions.errorIsA<UnsafeDeserializationError>() ||
75007503
allowCompilerErrors()) {
75017504
consumeError(witnessSubstitutions.takeError());
75027505
isOpaque = true;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// Verifies that all of the generic signatures in the standard library are
22
// minimal and canonical.
33

4-
// RUN: %target-typecheck-verify-swift -verify-generic-signatures Swift
4+
// RUN: %target-typecheck-verify-swift -verify-generic-signatures Swift -disable-deserialization-safety

test/stdlib/RuntimeObjC.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %empty-directory(%t)
22
//
33
// RUN: %target-clang %S/Inputs/Mirror/Mirror.mm -c -o %t/Mirror.mm.o -g
4-
// RUN: %target-build-swift -parse-stdlib -Xfrontend -disable-access-control -module-name a -I %S/Inputs/Mirror/ -Xlinker %t/Mirror.mm.o %s -o %t.out
4+
// RUN: %target-build-swift -parse-stdlib -Xfrontend -disable-access-control -module-name a -I %S/Inputs/Mirror/ -Xlinker %t/Mirror.mm.o %s -o %t.out -Xfrontend -disable-deserialization-safety
55
// RUN: %target-codesign %t.out
66
// RUN: %target-run %t.out
77
// REQUIRES: executable_test

0 commit comments

Comments
 (0)