Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-14620] "Found over consume" and "Found ownership error" occur under rare conditions. #56972

Open
YOCKOW opened this issue May 11, 2021 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software

Comments

@YOCKOW
Copy link
Collaborator

YOCKOW commented May 11, 2021

Previous ID SR-14620
Radar rdar://problem/77851881
Original Reporter @YOCKOW
Type Bug
Environment
  • Ubuntu 20.04

  • Swift version 5.4 (swift-5.4-RELEASE)
    Target: x86_64-unknown-linux-gnu

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash
Assignee None
Priority Medium

md5: e1057da7f5049c466a656c6dfb4b9043

Issue Description:

Summary

The compiler crashes when the following code is being compiled where all the conditions below are met:

  • OS is Ubuntu (non-Darwin)

  • Swift 5.4

  • Optimization is enabled (-O)

// over-consume.swift
import Foundation
import XCTest

let queryItems: [URLQueryItem]? = []
XCTAssertNil(queryItems?.first(where: { _ in false }))

Result

Begin Error in Function: '$s4mainypSgyKXEfu_'
Found over consume?!
Value: %20 = argument of bb3 : $Optional<URLQueryItem>   // users: %27, %26
User:   br bb7(%20 : $Optional<URLQueryItem>)           // id: %27
Block: bb3
Consuming Users:
  br bb7(%20 : $Optional<URLQueryItem>)           // id: %27
  switch_enum %20 : $Optional<URLQueryItem>, case #Optional.some!enumelt: bb5, case #Optional.none!enumelt: bb4 // id: %26

End Error in Function: '$s4mainypSgyKXEfu_'
Found ownership error?!
triggering standard assertion failure routine
UNREACHABLE executed at /home/build-user/swift/lib/SIL/Verifier/LinearLifetimeCheckerPrivate.h:211!
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.
Stack dump:
0.  Program arguments: /usr/bin/swift-frontend -frontend -c -primary-file over-consume.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -color-diagnostics -O -module-name main -o /tmp/over-consume-6d3f5b.o 
1.  Swift version 5.4 (swift-5.4-RELEASE)
2.  While evaluating request ExecuteSILPipelineRequest(Run pipelines { PrepareOptimizationPasses, EarlyModulePasses, HighLevel,Function+EarlyLoopOpt, HighLevel,Module+StackPromote, Serialize, MidLevel,Function, ClosureSpecialize, LowLevel,Function, LateLoopOpt, SIL Debug Info Generator } on SIL for main.main)
3.  While running pass #&#8203;5068 SILFunctionTransform "OwnershipModelEliminator" on SILFunction "@$s4mainypSgyKXEfu_".
 for expression at [over-consume.swift:5:14 - line:5:53] RangeText="queryItems?.first(where: { _ in false }"
4.  Found verification error when verifying before lowering ownership. Please re-run with -sil-verify-all to identify the actual pass that introduced the verification error.
5.  While verifying SIL function "@$s4mainypSgyKXEfu_".
 for expression at [over-consume.swift:5:14 - line:5:53] RangeText="queryItems?.first(where: { _ in false }"
/usr/bin/swift-frontend[0x55f5064]
/usr/bin/swift-frontend[0x55f2c5e]
/usr/bin/swift-frontend[0x55f5245]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x153c0)[0x7f76761203c0]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xcb)[0x7f7675bc818b]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x12b)[0x7f7675ba7859]
/usr/bin/swift-frontend[0x5547a01]
/usr/bin/swift-frontend[0x12889de]
/usr/bin/swift-frontend[0x1285a75]
/usr/bin/swift-frontend[0x1286bb7]
/usr/bin/swift-frontend[0x1291a4c]
/usr/bin/swift-frontend[0x1293af0]
/usr/bin/swift-frontend[0x1293900]
/usr/bin/swift-frontend[0x12b89d1]
/usr/bin/swift-frontend[0x129e2aa]
/usr/bin/swift-frontend[0x129cbb6]
/usr/bin/swift-frontend[0x129547d]
/usr/bin/swift-frontend[0xf6dd3a]
/usr/bin/swift-frontend[0xaec232]
/usr/bin/swift-frontend[0xaed147]
/usr/bin/swift-frontend[0xaea648]
/usr/bin/swift-frontend[0xaea5fb]
/usr/bin/swift-frontend[0xb0aada]
/usr/bin/swift-frontend[0xaf50e3]
/usr/bin/swift-frontend[0xaea825]
/usr/bin/swift-frontend[0xaf775f]
/usr/bin/swift-frontend[0x69a8d2]
/usr/bin/swift-frontend[0x51bda1]
/usr/bin/swift-frontend[0x51b6e6]
/usr/bin/swift-frontend[0x50ffbe]
/usr/bin/swift-frontend[0x49cb51]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0x7f7675ba90b3]
/usr/bin/swift-frontend[0x49c66e]
<unknown>:0: error: unable to execute command: Aborted
<unknown>:0: error: compile command failed due to signal 6 (use -v to see invocation)

Notes

The compiler doesn't crash where one of the conditions below is met:

  • Swift 5.3.x

  • OS is macOS

  • Optimization is disabled

  • URLQueryItem is changed to other type such as Data

  • XCTAssertNil is changed to other function such as print

@typesanitizer
Copy link

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software
Projects
None yet
Development

No branches or pull requests

3 participants