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-3446] Implement in the driver a state dumper when a crash is detected #46034

Open
gottesmm opened this issue Dec 18, 2016 · 5 comments
Open
Labels
compiler The Swift compiler in itself improvement legacy driver Area → compiler: the integrated C++ legacy driver. Succeeded by the swift-driver project

Comments

@gottesmm
Copy link
Member

Previous ID SR-3446
Radar None
Original Reporter @gottesmm
Type Improvement
Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Improvement, Driver
Assignee None
Priority Medium

md5: 2fd1e26deeddd3e7f98fc4018716d178

Issue Description:

One thing that we have in clang that would be very useful in Swift is the ability to do a dump of the compiling module when the compiler crashes.

At a high level, I believe the problem basically comes down to the driver determining how far into the compilation the crash happened, rerunning to before that stage and dumping all intermediate, ast, sib files, packaging those up into a zip file.

My proposal for how to do this is to create a global variable that shows the stage of the compilation and have an RAII struct that sets up a signal handler that catches the signal and exits with the value in the global.

@gottesmm
Copy link
Member Author

@belkadan Thoughts?

@belkadan
Copy link
Contributor

Okay, let's see. I ignored this when Michael first filed it because I figured it was intractable or at least impractical, but Clang being able to do this even in the presence of modules means that a bunch of the worst problems have been solved. Let's take just the simplest approach: a crash during type-checking or SIL optimization, where re-running the same compiler will very likely end up with the same crash. What information do we need to collect/modify?

  • The command-line invocation of the frontend, obviously. Modifications: search paths? including those passed to Clang through -Xcc?

  • Any filelists / output file maps used in that invocation. Modifications: these are usually absolute paths, so we need to change those

  • All files in the current target.

  • All imported Clang headers and module maps, obviously.

  • All imported Swift modules. If something was imported using its module interface, we can grab that; if it was imported using a compiled module, we can grab that. (Ideally we'd get both; even when importing something using its interface, it'll have a compiled module form, either prebuilt next to the compiler or cached near the Clang PCMs in the module cache directory. These record dependency paths like PCMs do, though.)

I think that's all you'd need to handle regular frontend crashes. For crashes in the merge-modules phase, we'd go a bit further and add the partial modules into the mix, which shouldn't be hard because they're inputs of the merge-modules frontend invocation.

@gottesmm
Copy link
Member Author

@belkadan Thanks for looking at this. Being able to do this automagically would make it significantly easier for us to improve the quality of the compiler and make our users happy that they do not need to "construct" a test case. That being said, I think we would need to have some sort of modal dialog for automatic sending (or maybe something that lets the user attach it to a radar). Perhaps we can obfuscate/minify (not sure).

@belkadan
Copy link
Contributor

I'm very concerned about obfuscation because (sadly) some parts of the compiler use user-written names for ordering, and therefore we might lose the bug. (Thinking of protocol ordering in particular, which is used for generic signature canonicalization.)

@gottesmm
Copy link
Member Author

Ok. Even without the obfuscation I think it is still worth it.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler in itself improvement legacy driver Area → compiler: the integrated C++ legacy driver. Succeeded by the swift-driver project
Projects
None yet
Development

No branches or pull requests

2 participants