Own interp creation argv strings in InterpreterInfo#1049
Open
aaronj0 wants to merge 1 commit into
Open
Conversation
CreateInterpreter built ClingArgv from pointers of function-local strings (main executable path, extracted resource dir, libc++ include dir, CPPINTEROP_EXTRA_INTERPRETER_ARGS). But the interpreter keeps the raw argv pointers for its whole lifetime (cling::CompilerOptions, analagous for clang-repl), so asan reports accesses to them after CreateInterpreter returns. Fix: Collect owned copies of every argument and store it as a part of per-interpreter info, so it is released when DeleteInterpreter is called
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1049 +/- ##
==========================================
+ Coverage 86.73% 86.75% +0.02%
==========================================
Files 23 23
Lines 5970 5973 +3
==========================================
+ Hits 5178 5182 +4
+ Misses 792 791 -1
🚀 New features to boost your workflow:
|
| ClingArgv.insert(ClingArgv.begin(), {"-resource-dir", ResourceDir.c_str()}); | ||
| ClingArgv.insert(ClingArgv.begin(), MainExecutableName.c_str()); | ||
| if (!ResourceDir.empty()) { | ||
| ArgvStorage.push_back("-resource-dir"); |
Contributor
There was a problem hiding this comment.
warning: use emplace_back instead of push_back [modernize-use-emplace]
Suggested change
| ArgvStorage.push_back("-resource-dir"); | |
| mpty()) {emplace_back( |
| ArgvStorage.push_back("-resource-dir"); | ||
| ArgvStorage.push_back(ResourceDir); | ||
| } | ||
| ArgvStorage.push_back("-std=c++14"); |
Contributor
There was a problem hiding this comment.
warning: use emplace_back instead of push_back [modernize-use-emplace]
Suggested change
| ArgvStorage.push_back("-std=c++14"); | |
| Dir);emplace_back( |
Contributor
|
Why our infra did not catch this? |
Collaborator
Author
I don't know. Are we running asan in gcc or clang? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CreateInterpreterbuiltClingArgvfrom pointers of function-local strings, currently the executable path, extracted resource dir, libc++ include dir, and anyCPPINTEROP_EXTRA_INTERPRETER_ARGS. But the interpreter keeps the raw const char* pointers for its whole lifetime (cling::CompilerOptionsand the analagous one for clang-repl), so asan reports accesses to them afterCreateInterpreterreturns:This patch fixes this by collecting owned copies of every argument and store it as a part of per-interpreter info, so it is released when
DeleteInterpreteris called