Skip to content

[SR-13440] SILGen crash for ?? nil coalescing derivative registration #55882

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

Closed
dan-zheng opened this issue Aug 24, 2020 · 1 comment · Fixed by #71721
Closed

[SR-13440] SILGen crash for ?? nil coalescing derivative registration #55882

dan-zheng opened this issue Aug 24, 2020 · 1 comment · Fixed by #71721
Labels
AutoDiff bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself crash Bug: A crash, i.e., an abnormal termination of software expressions Feature: expressions generics Feature: generic declarations and types nil-coalescing operator Feature → operators: The nil-coalescing operator `??` operators Feature: operators SILGen Area → compiler: The SIL generation stage swift 6.0

Comments

@dan-zheng
Copy link
Contributor

Previous ID SR-13440
Radar None
Original Reporter @dan-zheng
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, AutoDiff, SILGen
Assignee None
Priority Medium

md5: 45e845b27c2d77c6964860dd086d124d

Issue Description:

import _Differentiation

@derivative(of: ??)
@usableFromInline
func _vjpNilCoalescing<T: Differentiable>(optional: T?, defaultValue: @autoclosure () throws -> T)
 rethrows -> (value: T, pullback: (T.TangentVector) -> Optional<T>.TangentVector)
{
 let hasValue = optional != nil
 let value = try optional ?? defaultValue()
 func pullback(_ v: T.TangentVector) -> Optional<T>.TangentVector {
   return hasValue ? .init(v) : .zero
 }
 return (value, pullback)
}
$ swift nil.swift
Assertion failed: (sig || !type.getASTType()->hasTypeParameter()), function getTypeLowering, file lib/SIL/IR/TypeLowering.cpp, line 2084.
Stack dump:
0.  Program arguments: build/Ninja-ReleaseAssert/swift-macosx-x86_64/bin/swift-frontend -frontend -interpret nil.swift -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -color-diagnostics -target-sdk-version 10.16 -module-name nil
1.  Swift version 5.3-dev (LLVM b6306aaf821d359, Swift 4e5ae00c2a933bc)
2.  While evaluating request ASTLoweringRequest(Lowering AST to SIL for module nil)
3.  While silgen emitFunction SIL function "@$s3nil17_vjpNilCoalescing8optional12defaultValuex5value_Sq16_DifferentiationAF14DifferentiableRzlE13TangentVectorVyx_GAHQzc8pullbacktxSg_xyKXKtKAfGRzlF".
 for '_vjpNilCoalescing(optional:defaultValue:)' (at nil.swift:5:1)
0  swift-frontend           0x0000000114330e05 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift-frontend           0x000000011432fdd8 llvm::sys::RunSignalHandlers() + 248
2  swift-frontend           0x00000001143313e6 SignalHandler(int) + 262
3  libsystem_platform.dylib 0x00007fff6af545fd _sigtramp + 29
4  libsystem_platform.dylib 000000000000000000 _sigtramp + 18446603338721704480
5  libsystem_c.dylib        0x00007fff6ae2a808 abort + 120
6  libsystem_c.dylib        0x00007fff6ae29ac6 err + 0
7  swift-frontend           0x00000001146a8423 swift::Lowering::TypeConverter::getTypeLowering(swift::SILType, swift::TypeExpansionContext, swift::CanGenericSignature) (.cold.3) + 35
8  swift-frontend           0x00000001108ed762 swift::Lowering::TypeConverter::getTypeLowering(swift::SILType, swift::TypeExpansionContext, swift::CanGenericSignature) + 242
9  swift-frontend           0x000000011085e597 swift::SILFunction::getTypeLowering(swift::SILType) const + 71
10 swift-frontend           0x0000000110229a6a swift::Lowering::SILGenFunction::emitManagedRValueWithCleanup(swift::SILValue) + 26
11 swift-frontend           0x000000011028b46f swift::Lowering::SILGenModule::getOrCreateCustomDerivativeThunk(swift::SILFunction*, swift::SILFunction*, swift::AutoDiffConfig const&, swift::AutoDiffDerivativeFunctionKind) + 3775
12 swift-frontend           0x00000001101c55b8 swift::Lowering::SILGenModule::emitDifferentiabilityWitness(swift::AbstractFunctionDecl*, swift::SILFunction*, swift::AutoDiffConfig const&, swift::SILFunction*, swift::SILFunction*, swift::DeclAttribute const*) + 552
@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
asavonic added a commit to asavonic/swift that referenced this issue Feb 19, 2024
The patch fixes the issue swiftlang#55882 and enables the nil coalescing operator
(aka `??`) for Optional type.
@jkshtj
Copy link
Contributor

jkshtj commented May 3, 2024

Still crashes on 05/24 toolchain.

@AnthonyLatsis AnthonyLatsis added crash Bug: A crash, i.e., an abnormal termination of software operators Feature: operators expressions Feature: expressions nil-coalescing operator Feature → operators: The nil-coalescing operator `??` swift 6.0 generics Feature: generic declarations and types labels May 3, 2024
asl pushed a commit to asavonic/swift that referenced this issue May 31, 2024
The patch fixes the issue swiftlang#55882 and enables the nil coalescing operator
(aka `??`) for Optional type.
asl pushed a commit to asavonic/swift that referenced this issue Jun 6, 2024
The patch fixes the issue swiftlang#55882 and enables the nil coalescing operator
(aka `??`) for Optional type.
@asl asl linked a pull request Jun 6, 2024 that will close this issue
@asl asl closed this as completed in #71721 Jun 6, 2024
asl added a commit that referenced this issue Jun 6, 2024
Enable the nil coalescing operator (aka `??`) for Optional type.

Fixes #55882

Co-authored-by: Anton Korobeynikov <[email protected]>
asl added a commit that referenced this issue Jun 13, 2024
Enable the nil coalescing operator (aka `??`) for Optional type.

Fixes #55882

Co-authored-by: Andrew Savonichev <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AutoDiff bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself crash Bug: A crash, i.e., an abnormal termination of software expressions Feature: expressions generics Feature: generic declarations and types nil-coalescing operator Feature → operators: The nil-coalescing operator `??` operators Feature: operators SILGen Area → compiler: The SIL generation stage swift 6.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants