-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SR-15823] [AutoDiff] Runtime segfault from edge case #58097
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
Comments
@asl your comment on SR-15818 (#58095 (comment)) was right on point! I spent around 4 days investigating the bug, and the cause is something very massive. This bug can actually crash the compiler. Take this reproducer, for example. It crashes during SILGen. import _Differentiation
func myFunc(x: Float, y: Float) -> Float { x + y }
let item: @differentiable(reverse) (Float, Float) -> Float = myFunc
class Box<T> {
var value: T
init(value: T) {
self.value = value
}
}
let box = Box(value: item)
let retrieved = box.value My full investigation is published as a gist, but here is the summary:
|
The code in the 4/25 post is still causing recent toolchains (2023-01-02a, 2023-01-14a and 2023-01-18a) to crash. We have:
|
@fibrechannelscsi Looks like we've failed to create proper reabstraction thunk from Hence an assertion when address is scalar is casted to address of tuple. There is some special wrt |
Ok, the problem is quite weird. Looks like we're confusing The difference is caused by the context where we calculate the pullback type. In the first case we're inside generic function We can extend thunk generation to handle such case, but I'm not 100% sure we will not end with some other corner cases. @BradLarson @rxwei @dan-zheng any suggestions? |
@philipturner Why are you closing it? |
The reproducer from April 25, 2022, still triggers the above assertion failure as of the 2023-04-27 nightly snapshot, so this is still an issue. |
Reproducer no longer crashes with the 05/24 toolchain. |
@jkshtj Have you checked that the type of reabstraction thunk is correct now? |
I haven't. I'm doing a quick run-through of the list of issues that we have internally. If we need deeper investigation besides checking for no crashes, I'll keep this open. |
Thanks! I'd rather not close issues simply because "does not crash anymore" and instead try to check what changed, especially if some analysis was done before. |
Attachment: Download
Additional Detail from JIRA
md5: 7ac04b0e86fad47aa1f9a8580634f6ab
Issue Description:
The following code crashes at runtime under specific conditions as explained below. As-is, it crashes. To stop it from crashing, follow instructions in its comments.
The text was updated successfully, but these errors were encountered: