Open swift-ci opened 4 years ago
Could you please:
Provide exact reproduction steps (you've noted the configuration, that's a good start). Ideally, we'd have your stdlib at a particular commit which can be checked out and known to trigger this issue. If you use create a branch for it (say sr-13095), please note down the HEAD commit hash as well in case someone (force) pushes to it.
Format the code in the description using Jira markup? The description is difficult to read without proper formatting.
Comment by Carl Peto (JIRA)
yes, sorry, I've reformatted the code accordingly
it's hard to extract the stdlib in a concise way, it's inside a project in a private repository, is there a channel for sharing protected code?
This is a completely separate project from the standard library inside swift/stdlib but as i understand it should be generally supported to do this sort of thing. 😉
Comment by Carl Peto (JIRA)
another approach on this, rather than trying to reproduce the bug elsewhere... i can look at various reasons why it's like this... I'd enjoy a bit more background on what's going on here.
The code seems to be trying to emit a SIL function, but is unable to lower the code to SIL because something isn't loaded.
1) what does getInterfaceType() retrieve? Is it loading some kind of cached information about the type of a valueDecl in the AST? In this case, the type being referenced is UnsafeMutableRawPointer and the field in question is _rawValue.
For reference the UnsafeMutableRawPointer code is like this (extracted for clarity)...
@frozen
public struct UnsafeMutableRawPointer: _Pointer {
public typealias Pointee = UInt8
public let _rawValue: Builtin.RawPointer
@_transparent
public init(_ _rawValue: Builtin.RawPointer) {
self._rawValue = _rawValue
}
...I would assume❓ that by the time SIL is being emitted, semantic analysis is complete and the code for UnsafeMutableRawPointer has been read and parsed, so i don't understand why the AST hasn't already got the type for this field as Builtin.RawPointer?
2) I've heard the terms declared type and canonical type in this area. I don't really know what they mean or if they are relevant here? Is there any documentation on this?
By the way, this bug comes out of a lab session. I spoke to Pavel this morning about this issue and he agreed it looked like a bug and asked me to raise a ticket on here because we ran out of time in our call to fix it there.
Thanks for formatting the code.
it's hard to extract the stdlib in a concise way, it's inside a project in a private repository, is there a channel for sharing protected code?
Yes, you can file a feedback using feedbackassistant.apple.com. Many people use it and attach code examples/projects that they cannot make public.
This is a completely separate project from the standard library inside swift/stdlib but as i understand it should be generally supported to do this sort of thing.
Well, I'm going to have to disagree since you are using the -parse-stdlib
flag. 😛 We don't expect most (99.99%+) people to be using that flag.
what does getInterfaceType() retrieve? Is it loading some kind of cached information about the type of a valueDecl in the AST?
There is a short description in docs/Lexicon.md
.
interface type
The type of a value or declaration outside its generic context. These types are written using "formal" generic types, which only have meaning when combined with a particular generic declaration's "generic signature". Unlike contextual types, interface types store conformances and requirements in the generic signature and not in the types themselves. They can be compared across declarations but cannot be used directly from within the context.
You might also want to see other descriptions in that file.
I've heard the terms declared type and canonical type in this area. I don't really know what they mean or if they are relevant here? Is there any documentation on this?
I don't know about declared type but canonical type is not relevant afaict. The doc comments are a bit sparse but docs/Lexicon.md
and Slava's article https://medium.com/@slavapestov/the-secret-life-of-types-in-swift-ff83c3c000a5 would be good places to start. You might also want to check out docs/README.md
which describes how the documentation is organized; it might help you find other relevant information.
By the way, this bug comes out of a lab session. I spoke to Pavel this morning about this issue and he agreed it looked like a bug and asked me to raise a ticket on here because we ran out of time in our call to fix it there.
I'm not saying it's not a bug. The compiler is crashing, and the compiler should not crash. So it's certainly a bug. All I'm saying is that providing more information would help in understanding things better. It's much easier to understand what's going on if the issue can be reproduced/debugged compared to just looking at the trace and the surrounding code. Moreover, reproduction information is valuable in case someone else encounters a similar issue; then they can compare/contrast what you were doing to what they are doing.
Also, please leave a comment here with the feedback number in case you decide to file a feedback so we can connect the feedback to this JIRA.
Comment by Carl Peto (JIRA)
I've submitted code and build instructions to the apple feedback assistant with reference FB7805790.
p.s. thanks so much for all your help, obviously making stdlib is a very rare thing to do, all I meant is that from my conversations with some developers they've suggested that even when compiling stdlib, the compiler shouldn't crash. That's all I meant! 🙂
Carl
Environment
macOS 10.15.5, compiler is Apple clang version 11.0.3 (clang-1103.0.32.62) installed as part of Xcode 11.5 swift built from source using ninjaAdditional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | | |Labels | Bug | |Assignee | None | |Priority | Medium | md5: 8bb7c54cb2ba7b645e29341efe127ff5Issue Description:
this code is crashing when compiled using -parse-stdlib...
Here's the C code being called...
where __swift_size_t is defined as
Seems to be a problem with the clang importer or something similar.
Here is the backtrace...
is trapping because
is false.
The struct being lowered seems to be UnsafeMutableRawPointer and the field being lowered seems to be _rawValue.
my standard library project has the basics, Unsafe pointers, integer types, optional, collections, sequence, iterator but not arrays or strings.