-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Instrumenting nodejs with AddressSanitizer fails resulting of memory leaks #32835
Comments
--- a/tools/code_cache/mkcodecache.cc
+++ b/tools/code_cache/mkcodecache.cc
@@ -49,8 +49,8 @@ int main(int argc, char* argv[]) {
// Create a new Isolate and make it the current one.
Isolate::CreateParams create_params;
- create_params.array_buffer_allocator =
- ArrayBuffer::Allocator::NewDefaultAllocator();
+ create_params.array_buffer_allocator_shared.reset(
+ ArrayBuffer::Allocator::NewDefaultAllocator());
Isolate* isolate = Isolate::New(create_params);
{
Isolate::Scope isolate_scope(isolate);
@@ -65,6 +65,7 @@ int main(int argc, char* argv[]) {
out << cache;
out.close();
}
+ isolate->Dispose();
v8::V8::ShutdownPlatform();
return 0; Does this help? If yes, feel free to open a PR with it. |
Thank you for your timely reply. Let me have a try. |
@addaleax Your patch works well! |
Interesting. We recently introduced ASAN checks on our CI (https://github.com/nodejs/node/actions?query=workflow%3Atest-asan), and so far it hasn't failed. It's worth noting we use |
@addaleax The patch does work well on the master branch. But I found that in v12.16.0, 'CreateParams' has no member of 'array_buffer_allocator_shared'. |
@mmarchini I tried to build v12.16.0 in your way and succeeded. |
Ok, so something is different when building with the flag and setting things up manually, or maybe there's a compiler's difference. Either way, this looks like something our CI should've flagged, nice catch! |
@zyscoder Right, on older release lines you may have to manually keep the reference to the Anyway, I’ve opened #32850 with the patch from above. |
@zyscoder which clang version did you use? |
clang-8.0.0 |
Fixes: #32835 PR-URL: #32850 Reviewed-By: Matheus Marchini <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Jiawen Geng <[email protected]>
Fixes: nodejs#32835 PR-URL: nodejs#32850 Reviewed-By: Matheus Marchini <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Jiawen Geng <[email protected]>
Fixes: #32835 PR-URL: #32850 Backport-PR-URL: #33128 Reviewed-By: Matheus Marchini <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Jiawen Geng <[email protected]>
Fixes: #32835 PR-URL: #32850 Backport-PR-URL: #33128 Reviewed-By: Matheus Marchini <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Jiawen Geng <[email protected]>
I tried building node JS with ASAN on Linux. I used Please find the error message below:
|
What steps will reproduce the bug?
When building nodejs with AddressSanitizer,
the following command will be run, and memory leaks occur:
How often does it reproduce? Is there a required condition?
No. This potential bug can always be reproduced.
What is the expected behavior?
The executable of 'mkcodecache' tries to generate the file of 'node_code_cache.cc' when building nodejs, and the building process fails due to memory leaks of 'mkcodecache'. This problem should be handled otherwise a nodejs instrumented by Address Sanitizer cannot be built successfully.
What do you see instead?
Multiple stack dumps of memory leaks:
Additional information
The text was updated successfully, but these errors were encountered: