[Swift CI] Build Failure: 1. OSS - Swift ASAN - OS X (master) #114

Asan is detecting a use after free. Michael G or Joe, is this likely either of you?

SUMMARY: AddressSanitizer: heap-use-after-free (/Users/buildnode/jenkins/workspace/oss-swift-incremental-ASAN-RA-osx/buildbot_incremental_asan/swift-macosx-x86_64/bin/swift:x86_64+0x101bc796c) in swift::eraseUsesOfInstruction(swift::SILInstruction*, std::__1::function<void (swift::SILInstruction*)>)

···

On Aug 29, 2017, at 4:15 PM, no-reply@swift.org wrote:

[FAILURE] oss-swift-incremental-ASAN-RA-osx [#114]

Build URL: https://ci.swift.org/job/oss-swift-incremental-ASAN-RA-osx/114/
Project: oss-swift-incremental-ASAN-RA-osx
Date of build: Tue, 29 Aug 2017 16:26:15 -0500
Build duration: 1 hr 50 min

Changes

Commit 58fefc174cb6fade894c9c9349dbf34bab7f34a6 by mgottesman:
[sil-ownership] is_nonnull does not take trivial values, it takes

edit: test/SIL/ownership-verifier/use_verifier.sil
edit: lib/SIL/SILOwnershipVerifier.cpp

Commit fb1b2a8d9d2277a53c7b1bc76f983ccd38b9f925 by shajrawi:
Use emitCopy/Destroy value instead of LoweredCopy/Destroy for large

edit: lib/SILOptimizer/Transforms/SILLowerAggregateInstrs.cpp
edit: lib/SILOptimizer/Transforms/SILMem2Reg.cpp
edit: lib/SIL/TypeLowering.cpp

Commit 5c65887fd00e99237eb1032634249634e8a7a236 by xi_ge:
[SourceKit] Add function argument when optional chaining is used

edit: lib/IDE/SyntaxModel.cpp
edit: test/IDE/structure.swift
edit: test/SourceKit/DocumentStructure/structure.swift.response
edit: test/SourceKit/DocumentStructure/Inputs/main.swift

My commit might have uncovered an old bug in eraseUsesOfInstruction by changing which large-types are expanded in the optimizer, but it did not cause this underlying problem:

There’s a bug in the recursive eraser’s logic that, in rare occasions, deletes a ‘user’ that’s yet to be iterated over in the Instruction’s users loop. This caused the compiler to crash.

Last week I upstream a commit that worked around this issue by adding the following check:
    if (!User) {
      continue;
    }

I am assuming ASAN is hitting this issue now.

Regards,
—Joe |  | :e-mail: shajrawi@apple.com | :iphone:(+1) 408-930-5203

···

On Aug 29, 2017, at 4:17 PM, Michael Ilseman <milseman@apple.com> wrote:

Asan is detecting a use after free. Michael G or Joe, is this likely either of you?

SUMMARY: AddressSanitizer: heap-use-after-free (/Users/buildnode/jenkins/workspace/oss-swift-incremental-ASAN-RA-osx/buildbot_incremental_asan/swift-macosx-x86_64/bin/swift:x86_64+0x101bc796c) in swift::eraseUsesOfInstruction(swift::SILInstruction*, std::__1::function<void (swift::SILInstruction*)>)

On Aug 29, 2017, at 4:15 PM, no-reply@swift.org <mailto:no-reply@swift.org> wrote:

[FAILURE] oss-swift-incremental-ASAN-RA-osx [#114]

Build URL: https://ci.swift.org/job/oss-swift-incremental-ASAN-RA-osx/114/
Project: oss-swift-incremental-ASAN-RA-osx
Date of build: Tue, 29 Aug 2017 16:26:15 -0500
Build duration: 1 hr 50 min

Changes

Commit 58fefc174cb6fade894c9c9349dbf34bab7f34a6 by mgottesman:
[sil-ownership] is_nonnull does not take trivial values, it takes

edit: test/SIL/ownership-verifier/use_verifier.sil
edit: lib/SIL/SILOwnershipVerifier.cpp

Commit fb1b2a8d9d2277a53c7b1bc76f983ccd38b9f925 by shajrawi:
Use emitCopy/Destroy value instead of LoweredCopy/Destroy for large

edit: lib/SILOptimizer/Transforms/SILLowerAggregateInstrs.cpp
edit: lib/SILOptimizer/Transforms/SILMem2Reg.cpp
edit: lib/SIL/TypeLowering.cpp

Commit 5c65887fd00e99237eb1032634249634e8a7a236 by xi_ge:
[SourceKit] Add function argument when optional chaining is used

edit: lib/IDE/SyntaxModel.cpp
edit: test/IDE/structure.swift
edit: test/SourceKit/DocumentStructure/structure.swift.response
edit: test/SourceKit/DocumentStructure/Inputs/main.swift

This PR should fix it: Fixes a bug in eraseUsesOfInstruction's iterator by shajrawi · Pull Request #11686 · apple/swift · GitHub

Regards,
—Joe |  | :e-mail: shajrawi@apple.com <mailto:shajrawi@apple.com> | :iphone:(+1) 408-930-5203

···

On Aug 29, 2017, at 16:27, Joe Shajrawi <shajrawi@apple.com> wrote:

My commit might have uncovered an old bug in eraseUsesOfInstruction by changing which large-types are expanded in the optimizer, but it did not cause this underlying problem:

There’s a bug in the recursive eraser’s logic that, in rare occasions, deletes a ‘user’ that’s yet to be iterated over in the Instruction’s users loop. This caused the compiler to crash.

Last week I upstream a commit that worked around this issue by adding the following check:
    if (!User) {
      continue;
    }

I am assuming ASAN is hitting this issue now.

Regards,
—Joe |  | :e-mail: shajrawi@apple.com <mailto:shajrawi@apple.com> | :iphone:(+1) 408-930-5203

On Aug 29, 2017, at 4:17 PM, Michael Ilseman <milseman@apple.com <mailto:milseman@apple.com>> wrote:

Asan is detecting a use after free. Michael G or Joe, is this likely either of you?

SUMMARY: AddressSanitizer: heap-use-after-free (/Users/buildnode/jenkins/workspace/oss-swift-incremental-ASAN-RA-osx/buildbot_incremental_asan/swift-macosx-x86_64/bin/swift:x86_64+0x101bc796c) in swift::eraseUsesOfInstruction(swift::SILInstruction*, std::__1::function<void (swift::SILInstruction*)>)

On Aug 29, 2017, at 4:15 PM, no-reply@swift.org <mailto:no-reply@swift.org> wrote:

[FAILURE] oss-swift-incremental-ASAN-RA-osx [#114]

Build URL: https://ci.swift.org/job/oss-swift-incremental-ASAN-RA-osx/114/
Project: oss-swift-incremental-ASAN-RA-osx
Date of build: Tue, 29 Aug 2017 16:26:15 -0500
Build duration: 1 hr 50 min

Changes

Commit 58fefc174cb6fade894c9c9349dbf34bab7f34a6 by mgottesman:
[sil-ownership] is_nonnull does not take trivial values, it takes

edit: test/SIL/ownership-verifier/use_verifier.sil
edit: lib/SIL/SILOwnershipVerifier.cpp

Commit fb1b2a8d9d2277a53c7b1bc76f983ccd38b9f925 by shajrawi:
Use emitCopy/Destroy value instead of LoweredCopy/Destroy for large

edit: lib/SILOptimizer/Transforms/SILLowerAggregateInstrs.cpp
edit: lib/SILOptimizer/Transforms/SILMem2Reg.cpp
edit: lib/SIL/TypeLowering.cpp

Commit 5c65887fd00e99237eb1032634249634e8a7a236 by xi_ge:
[SourceKit] Add function argument when optional chaining is used

edit: lib/IDE/SyntaxModel.cpp
edit: test/IDE/structure.swift
edit: test/SourceKit/DocumentStructure/structure.swift.response
edit: test/SourceKit/DocumentStructure/Inputs/main.swift