Closed
Bug 1180549
Opened 9 years ago
Closed 9 years ago
Fix a startup crash when using the clang-plugin with clang>3.5
Categories
(Developer Infrastructure :: Source Code Analysis, defect)
Developer Infrastructure
Source Code Analysis
Tracking
(firefox42 fixed)
RESOLVED
FIXED
mozilla42
Tracking | Status | |
---|---|---|
firefox42 | --- | fixed |
People
(Reporter: ehsan.akhgari, Assigned: ehsan.akhgari)
References
Details
Attachments
(1 file)
1.67 KB,
patch
|
nika
:
review+
|
Details | Diff | Splinter Review |
The unique_ptr temporary object returned by getOtherConsumer() would be destroyed, which would cause the vector to point to a deleted object! With this fixed, the plugin can be built with more recent versions of clang.
Assignee | ||
Comment 1•9 years ago
|
||
Attachment #8629750 -
Flags: review?(michael)
Assignee | ||
Comment 2•9 years ago
|
||
Botond, I think you may be interested in this. This patch fixes the crash that I was seeing when using the plugin on recent versions of clang! With this fixed, I hope to be able to upgrade the clang versions we use for static analysis on the infrastructure to the ToT clang. \o/
Comment 3•9 years ago
|
||
Comment on attachment 8629750 [details] [diff] [review] Fix a startup crash when using the clang-plugin with clang>3.5 Review of attachment 8629750 [details] [diff] [review]: ----------------------------------------------------------------- ::: build/clang-plugin/clang-plugin.cpp @@ +1199,5 @@ > class MozCheckAction : public PluginASTAction { > public: > ASTConsumerPtr CreateASTConsumer(CompilerInstance &CI, StringRef fileName) override { > #if CLANG_VERSION_FULL >= 306 > + std::unique_ptr<MozChecker> checker(llvm::make_unique<MozChecker>(CI)); Is there any particular reason for the addition of the llvm:: to make_unique? It's already in namespace, and seems unnecessary. @@ -1206,2 @@ > consumers.push_back(std::move(checker)); > - consumers.push_back(checker->getOtherConsumer()); Isn't the problem that we were de-referencing checker after moving it into consumers here? The explanation in the commit message seems odd to me. We could also fix this (I think) by just swapping the above two lines, but it's probably better to act the same as below.
Attachment #8629750 -
Flags: review?(michael) → review+
Assignee | ||
Comment 4•9 years ago
|
||
(In reply to Michael Layzell [:mystor] from comment #3) > ::: build/clang-plugin/clang-plugin.cpp > @@ +1199,5 @@ > > class MozCheckAction : public PluginASTAction { > > public: > > ASTConsumerPtr CreateASTConsumer(CompilerInstance &CI, StringRef fileName) override { > > #if CLANG_VERSION_FULL >= 306 > > + std::unique_ptr<MozChecker> checker(llvm::make_unique<MozChecker>(CI)); > > Is there any particular reason for the addition of the llvm:: to > make_unique? It's already in namespace, and seems unnecessary. Just copying what LLVM consumers do, and a bit of C++14 safety. :-) > @@ -1206,2 @@ > > consumers.push_back(std::move(checker)); > > - consumers.push_back(checker->getOtherConsumer()); > > Isn't the problem that we were de-referencing checker after moving it into > consumers here? The explanation in the commit message seems odd to me. > > We could also fix this (I think) by just swapping the above two lines, but > it's probably better to act the same as below. You're right! I will fix the commit message.
https://hg.mozilla.org/mozilla-central/rev/277e60059a10
Assignee: nobody → ehsan
Status: NEW → RESOLVED
Closed: 9 years ago
status-firefox42:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla42
Updated•6 years ago
|
Product: Core → Firefox Build System
Updated•2 years ago
|
Product: Firefox Build System → Developer Infrastructure
You need to log in
before you can comment on or make changes to this bug.
Description
•