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-11126] Compiler Crashes on Property Wrapper with Default Parameter Value #53522

Closed
swift-ci opened this issue Jul 14, 2019 · 2 comments
Closed
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 property wrappers Feature: property wrappers

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-11126
Radar None
Original Reporter nickffox (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

Xcode 11 beta 3 targeting an iPhone Xs simulator

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

md5: 9b518181b7e1556c8bece8b467feef64

Issue Description:

Steps to Reproduce:

1. Create a New Single View Application (not using Swift UI).

2. Replace ViewController.swift with the following code:

//
//  ViewController.swift
//  DebounceTest
//
//  Created by Nick Fox on 7/13/19.
//  Copyright © 2019 LiveSafe, Inc. All rights reserved.
//


import UIKit
import Foundation


class ViewController: UIViewController {


  var test = Temp()


  override func viewDidLoad() {
    super.viewDidLoad()


    test.text = "New"


    DispatchQueue.global(qos: .userInteractive).asyncAfter(deadline: .now() + 4) { [weak self] in
      guard let self = self else { return }
      print(self.test.text)
    }
  }
}








@propertyWrapper
class Debouncing<T> {


  var value: T
  var delay: TimeInterval
  var queue: DispatchQueue
  private var currentWorkItem: DispatchWorkItem?


  init(
    initialValue: T,
    delay: TimeInterval,
    queue: DispatchQueue = DispatchQueue(label: UUID().uuidString, qos: .default)
  ) {
    self.value = initialValue
    self.delay = delay
    self.queue = queue
  }


  var wrappedValue: T {
    get { value }
    set {
      currentWorkItem?.cancel()
      let workItem = DispatchWorkItem { [weak self] in self?.value = newValue }
      currentWorkItem = workItem
      queue.asyncAfter(deadline: .now() + delay, execute: workItem)
    }
  }
}


struct Temp {
  @Debouncing(delay: 3) var text: String = "Start"
}

3. Run targeting an iPhone Xs simulator, and the compiler will crash:

Stack dump:
0.  Program arguments: /Applications/Xcode-11beta3.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/nickfox/Desktop/DebounceTest/DebounceTest/ViewController.swift /Users/nickfox/Desktop/DebounceTest/DebounceTest/AppDelegate.swift /Users/nickfox/Desktop/DebounceTest/DebounceTest/SceneDelegate.swift -emit-module-path /Users/nickfox/Library/Developer/Xcode/DerivedData/DebounceTest-ekyerasndfweaifhgetnrhvvvfek/Build/Intermediates.noindex/DebounceTest.build/Debug-iphonesimulator/DebounceTest.build/Objects-normal/x86_64/ViewController~partial.swiftmodule -emit-module-doc-path /Users/nickfox/Library/Developer/Xcode/DerivedData/DebounceTest-ekyerasndfweaifhgetnrhvvvfek/Build/Intermediates.noindex/DebounceTest.build/Debug-iphonesimulator/DebounceTest.build/Objects-normal/x86_64/ViewController~partial.swiftdoc -serialize-diagnostics-path /Users/nickfox/Library/Developer/Xcode/DerivedData/DebounceTest-ekyerasndfweaifhgetnrhvvvfek/Build/Intermediates.noindex/DebounceTest.build/Debug-iphonesimulator/DebounceTest.build/Objects-normal/x86_64/ViewController.dia -emit-dependencies-path /Users/nickfox/Library/Developer/Xcode/DerivedData/DebounceTest-ekyerasndfweaifhgetnrhvvvfek/Build/Intermediates.noindex/DebounceTest.build/Debug-iphonesimulator/DebounceTest.build/Objects-normal/x86_64/ViewController.d -emit-reference-dependencies-path /Users/nickfox/Library/Developer/Xcode/DerivedData/DebounceTest-ekyerasndfweaifhgetnrhvvvfek/Build/Intermediates.noindex/DebounceTest.build/Debug-iphonesimulator/DebounceTest.build/Objects-normal/x86_64/ViewController.swiftdeps -target x86_64-apple-ios13.0-simulator -enable-objc-interop -sdk /Applications/Xcode-11beta3.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.0.sdk -I /Users/nickfox/Library/Developer/Xcode/DerivedData/DebounceTest-ekyerasndfweaifhgetnrhvvvfek/Build/Products/Debug-iphonesimulator -F /Users/nickfox/Library/Developer/Xcode/DerivedData/DebounceTest-ekyerasndfweaifhgetnrhvvvfek/Build/Products/Debug-iphonesimulator -enable-testing -g -module-cache-path /Users/nickfox/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -swift-version 5 -enforce-exclusivity=checked -Onone -D DEBUG -serialize-debugging-options -Xcc -working-directory -Xcc /Users/nickfox/Desktop/DebounceTest -enable-anonymous-context-mangled-names -Xcc -I/Users/nickfox/Library/Developer/Xcode/DerivedData/DebounceTest-ekyerasndfweaifhgetnrhvvvfek/Build/Intermediates.noindex/DebounceTest.build/Debug-iphonesimulator/DebounceTest.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/nickfox/Library/Developer/Xcode/DerivedData/DebounceTest-ekyerasndfweaifhgetnrhvvvfek/Build/Intermediates.noindex/DebounceTest.build/Debug-iphonesimulator/DebounceTest.build/DebounceTest-generated-files.hmap -Xcc -I/Users/nickfox/Library/Developer/Xcode/DerivedData/DebounceTest-ekyerasndfweaifhgetnrhvvvfek/Build/Intermediates.noindex/DebounceTest.build/Debug-iphonesimulator/DebounceTest.build/DebounceTest-own-target-headers.hmap -Xcc -I/Users/nickfox/Library/Developer/Xcode/DerivedData/DebounceTest-ekyerasndfweaifhgetnrhvvvfek/Build/Intermediates.noindex/DebounceTest.build/Debug-iphonesimulator/DebounceTest.build/DebounceTest-all-target-headers.hmap -Xcc -iquote -Xcc /Users/nickfox/Library/Developer/Xcode/DerivedData/DebounceTest-ekyerasndfweaifhgetnrhvvvfek/Build/Intermediates.noindex/DebounceTest.build/Debug-iphonesimulator/DebounceTest.build/DebounceTest-project-headers.hmap -Xcc -I/Users/nickfox/Library/Developer/Xcode/DerivedData/DebounceTest-ekyerasndfweaifhgetnrhvvvfek/Build/Products/Debug-iphonesimulator/include -Xcc -I/Users/nickfox/Library/Developer/Xcode/DerivedData/DebounceTest-ekyerasndfweaifhgetnrhvvvfek/Build/Intermediates.noindex/DebounceTest.build/Debug-iphonesimulator/DebounceTest.build/DerivedSources-normal/x86_64 -Xcc -I/Users/nickfox/Library/Developer/Xcode/DerivedData/DebounceTest-ekyerasndfweaifhgetnrhvvvfek/Build/Intermediates.noindex/DebounceTest.build/Debug-iphonesimulator/DebounceTest.build/DerivedSources/x86_64 -Xcc -I/Users/nickfox/Library/Developer/Xcode/DerivedData/DebounceTest-ekyerasndfweaifhgetnrhvvvfek/Build/Intermediates.noindex/DebounceTest.build/Debug-iphonesimulator/DebounceTest.build/DerivedSources -Xcc -DDEBUG=1 -module-name DebounceTest -o /Users/nickfox/Library/Developer/Xcode/DerivedData/DebounceTest-ekyerasndfweaifhgetnrhvvvfek/Build/Intermediates.noindex/DebounceTest.build/Debug-iphonesimulator/DebounceTest.build/Objects-normal/x86_64/ViewController.o -index-store-path /Users/nickfox/Library/Developer/Xcode/DerivedData/DebounceTest-ekyerasndfweaifhgetnrhvvvfek/Index/DataStore -index-system-modules 
1.  While emitting IR SIL function "@$s12DebounceTest4TempVACycfC".
 for 'init()' (at /Users/nickfox/Desktop/DebounceTest/DebounceTest/ViewController.swift:59:8)
0  swift                    0x00000001055dac83 PrintStackTraceSignalHandler(void*) + 51
1  swift                    0x00000001055da456 SignalHandler(int) + 358
2  libsystem_platform.dylib 0x00007fff7c147b5d _sigtramp + 29
3  libsystem_platform.dylib 0x00007ffa532d2958 _sigtramp + 3608718872
4  libsystem_c.dylib        0x00007fff7c0076a6 abort + 127
5  libsystem_malloc.dylib   0x00007fff7c115aef malloc_vreport + 545
6  libsystem_malloc.dylib   0x00007fff7c1158b0 malloc_report + 151
7  libsystem_malloc.dylib   0x00007fff7c11269a realloc + 313
8  swift                    0x00000001012fc19d swift::irgen::SingleScalarTypeInfo<(anonymous namespace)::ClassTypeInfo, swift::irgen::ReferenceTypeInfo>::getSchema(swift::irgen::ExplosionSchema&) const + 157
9  swift                    0x000000010146f2ae swift::SILInstructionVisitor<(anonymous namespace)::IRGenSILFunction, void>::visit(swift::SILInstruction*) + 35646
10 swift                    0x0000000101463bfa swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 9866
11 swift                    0x0000000101311360 swift::irgen::IRGenerator::emitGlobalTopLevel() + 1616
12 swift                    0x0000000101440cce performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::LLVMContext&, swift::SourceFile*, llvm::GlobalVariable**) + 1182
13 swift                    0x000000010122ee2b performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 37131
14 swift                    0x0000000101222474 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6868
15 swift                    0x00000001011b0fb3 main + 1219
16 libdyld.dylib            0x00007fff7bf623d5 start + 1
error: Abort trap: 6 (in target 'DebounceTest')
@theblixguy
Copy link
Collaborator

cc @DougGregor

@belkadan
Copy link
Contributor

Fixed in master and the 5.1 branch as rdar://problem/52116923.

@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
This issue was closed.
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 property wrappers Feature: property wrappers
Projects
None yet
Development

No branches or pull requests

4 participants