-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
heap-buffer-overflow when using nlohmann/json, ASAN, and gtest #2107
Comments
Hm. This seems unrelated to the library. At least the stack trace does not contain library code. |
I think you're correct. I find it strange that it seems to be (at least in part) specifically tied to the And you can see the definition of If I'm being honest that's all I really have to go on in terms of anything related to the issue pointing to this library. Thanks for taking a look anyway, and feel free to close this if you feel confident that it's not something in this library that could be the root cause. |
I'm not using Google Test myself, so I am not that familiar in setting up everything. Would be interesting to step through the code. |
Just in case you are interested in stepping through the code then the repo I created that reproduces the issue is self-contained. You can get it up and running and reproduce with the following:
|
I think I've isolated this down to the line that's causing the issue for me. If I comment out this line in the single include json/single_include/nlohmann/json.hpp Line 3404 in bcf4f3c
I really don't understand why that's problematic, especially seeing as if I comment out that line and instead print out json ints_json = {1, 2, 3};
std::vector<int> fetched_ints = ints_json.get<std::vector<int>>(); If you've got any ideas as to what might be going on that would be great! |
I now believe this to be an ASAN bug and have therefore created an issue there: google/sanitizers#1251 Feel free to close this if you're happy with that theory! |
Update: It was a known false positive that can occur if not compiling everything (in my case Sorry for the noise and thanks for the library 😊 |
Thanks for checking back! And deep down in my memory, I think I also had that problem once, but totally forgot about it. Good that this could be closed! |
I'll preface this by saying that I've also created an issue on the googletest repo. I'm not sure what the root cause of the issue is and so I figured I'd also create an issue here, in case you can shed some light.
I have a project uses CMake to build a library,
FooBug
, and atests
executable, which uses of googletest.There appears to be an issue with an interaction between:
making use of nlohmann/json, specifically creating a
nlohmann::json
objectand then trying to extract the value using the
get<std::vector<int>>()
syntax, for example:
compiling the
tests
executable, which linksgtest_main
with the followingASAN-related flag:
-fsanitize=address
defining at least 5 tests
At the linking stage I get a heap-buffer-overflow reported by ASAN.
Error output
I've created a repo that reproduces the issue.
The relevant code is in
FooTest.cpp
:I can compile and link the executable and run it successfully without a heap-buffer-overflow.
A heap-buffer-overflow reported by ASAN.
AppleClang 11.0.3.11030032
macOS 10.15.4 (19E287)
develop
branch?The version with tag
v3.7.3
from the fetchcontent fork/mirror repoThe same issue occurs with the latest commit on
develop
though.N/A
The text was updated successfully, but these errors were encountered: