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

Current issue with asan #30257

Closed
gengjiawen opened this issue Nov 5, 2019 · 12 comments
Closed

Current issue with asan #30257

gengjiawen opened this issue Nov 5, 2019 · 12 comments
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. help wanted Issues that need assistance from volunteers or PRs that need help to proceed.

Comments

@gengjiawen
Copy link
Member

gengjiawen commented Nov 5, 2019

Current asan failed using the following config

./configure --enable-asan --debug
make -j8
make test-only

due to

node/src/node.cc

Lines 950 to 958 in 31217a8

// These leak memory, because, in the original code of this function, no
// extra allocations were visible. This should be okay because this function
// is only supposed to be called once per process, though.
*exec_argv = Malloc<const char*>(*exec_argc);
for (int i = 0; i < *exec_argc; ++i)
(*exec_argv)[i] = strdup(exec_argv_[i].c_str());
for (int i = 0; i < *argc; ++i)
argv[i] = strdup(argv_[i].c_str());
}

My question is:

  • Is there a way to fix this ?
  • If not, can I make the test go on with those failures ?

cc @addaleax @bnoordhuis @devnexen

Direct leak of 8 byte(s) in 1 object(s) allocated from:
    #0 0x7f6f24a48f1e in __interceptor_realloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10df1e)
    #1 0x55be1f9ceed2 in char const** node::UncheckedRealloc<char const*>(char const**, unsigned long) ../src/util-inl.h:346
    #2 0x55be1f9cdb32 in char const** node::UncheckedMalloc<char const*>(unsigned long) ../src/util-inl.h:361
    #3 0x55be1f9cb8c3 in char const** node::Malloc<char const*>(unsigned long) ../src/util-inl.h:380
    #4 0x55be1f9c77c9 in node::Init(int*, char const**, int*, char const***) ../src/node.cc:953
    #5 0x55be1f81ff9f in NodeTestFixture::SetUpTestCase() ../test/cctest/node_test_fixture.h:79
    #6 0x55be1f7d0d9d in testing::TestSuite::RunSetUpTestSuite() (/root/node/out/Debug/cctest+0x1f87d9d)
    #7 0x55be1f7f27d5 in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::TestSuite, void>(testing::TestSuite*, void (testing::TestSuite::*)(), char const*) (/root/node/out/Debug/cctest+0x1fa97d5)
    #8 0x55be1f7e327f in void testing::internal::HandleExceptionsInMethodIfSupported<testing::TestSuite, void>(testing::TestSuite*, void (testing::TestSuite::*)(), char const*) (/root/node/out/Debug/cctest+0x1f9a27f)
    #9 0x55be1f7973d2 in testing::TestSuite::Run() ../test/cctest/gtest/gtest-all.cc:4289
    #10 0x55be1f7aee33 in testing::internal::UnitTestImpl::RunAllTests() ../test/cctest/gtest/gtest-all.cc:6752
    #11 0x55be1f7f44e1 in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) (/root/node/out/Debug/cctest+0x1fab4e1)
    #12 0x55be1f7e4524 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) (/root/node/out/Debug/cctest+0x1f9b524)
    #13 0x55be1f7abea9 in testing::UnitTest::Run() ../test/cctest/gtest/gtest-all.cc:6340
    #14 0x55be1f81ac55 in RUN_ALL_TESTS() ../test/cctest/gtest/gtest.h:14896
    #15 0x55be1f81ab3b in main ../test/cctest/gtest/gtest_main.cc:45
    #16 0x7f6f243ef1e2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x271e2)

Direct leak of 7 byte(s) in 1 object(s) allocated from:
    #0 0x7f6f249d13dd in strdup (/lib/x86_64-linux-gnu/libasan.so.5+0x963dd)
    #1 0x55be1f9c798e in node::Init(int*, char const**, int*, char const***) ../src/node.cc:957
    #2 0x55be1f81ff9f in NodeTestFixture::SetUpTestCase() ../test/cctest/node_test_fixture.h:79
    #3 0x55be1f7d0d9d in testing::TestSuite::RunSetUpTestSuite() (/root/node/out/Debug/cctest+0x1f87d9d)
    #4 0x55be1f7f27d5 in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::TestSuite, void>(testing::TestSuite*, void (testing::TestSuite::*)(), char const*) (/root/node/out/Debug/cctest+0x1fa97d5)
    #5 0x55be1f7e327f in void testing::internal::HandleExceptionsInMethodIfSupported<testing::TestSuite, void>(testing::TestSuite*, void (testing::TestSuite::*)(), char const*) (/root/node/out/Debug/cctest+0x1f9a27f)
    #6 0x55be1f7973d2 in testing::TestSuite::Run() ../test/cctest/gtest/gtest-all.cc:4289
    #7 0x55be1f7aee33 in testing::internal::UnitTestImpl::RunAllTests() ../test/cctest/gtest/gtest-all.cc:6752
    #8 0x55be1f7f44e1 in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) (/root/node/out/Debug/cctest+0x1fab4e1)
    #9 0x55be1f7e4524 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) (/root/node/out/Debug/cctest+0x1f9b524)
    #10 0x55be1f7abea9 in testing::UnitTest::Run() ../test/cctest/gtest/gtest-all.cc:6340
    #11 0x55be1f81ac55 in RUN_ALL_TESTS() ../test/cctest/gtest/gtest.h:14896
    #12 0x55be1f81ab3b in main ../test/cctest/gtest/gtest_main.cc:45
    #13 0x7f6f243ef1e2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x271e2)
@devsnek
Copy link
Member

devsnek commented Nov 5, 2019

That entire function is due to be deprecated/removed at some point, maybe v14? Also in the short term, you can mark the function with __attribute__((no_sanitize_address)).

@devsnek devsnek added the c++ Issues and PRs that require attention from people who are familiar with C++. label Nov 5, 2019
@gengjiawen
Copy link
Member Author

Is it possible we remove this in master branch ? @addaleax

@addaleax
Copy link
Member

addaleax commented Nov 5, 2019

I’m assuming this is happening because of the cctest and not the main binary? I’ll think about a good way around this…

@gengjiawen
Copy link
Member Author

gengjiawen commented Nov 7, 2019

I got some progress using ninja build. Looks like there are some leaks on master.

I am using docker image gengjiawen/node-build to test this.

./configure --debug --enable-asan --ninja
ninja -C out/Debug
python3 tools/test.py -J --mode=debug

Full log:
https://gist.github.com/gengjiawen/734b674e277b61c1a8998c6b57bffc75

@gengjiawen
Copy link
Member Author

Also there is a heap-use-after-free when testing parallel/test-fs-opendir.
cc @Fishrock123

@gengjiawen
Copy link
Member Author

gengjiawen commented Dec 5, 2019

Looks like there is some issue with wasi too. cc @nodejs/wasi

Full log:
https://app.circleci.com/jobs/github/gengjiawen/node-play/15/parallel-runs/0/steps/0-102

Another thing is asan on macOS not showing stacktrace, I am not sure why
https://github.com/gengjiawen/node/blob/ci/asan/.github/workflows/CI.yml

./configure --debug --enable-asan && make -j4 && python3 tools/test.py -J --mode=debug

@cjihrig
Copy link
Contributor

cjihrig commented Dec 5, 2019

@gengjiawen the CircleCI link is a 404 for me.

@gengjiawen
Copy link
Member Author

I can use that link, maybe CircleCI has bug in it's new design website.

Can you visit this: https://circleci.com/gh/gengjiawen/node-play/15?pipelines-ui-opt-out ?

@cjihrig
Copy link
Contributor

cjihrig commented Dec 5, 2019

Thanks, I can see it now. I'll be sending a fix.

@gengjiawen
Copy link
Member Author

gengjiawen commented Dec 7, 2019

Also there is some issues related to worker cc @nodejs/workers

https://circleci.com/gh/gengjiawen/node-play/15?pipelines-ui-opt-out

Trott pushed a commit that referenced this issue Dec 7, 2019
PR-URL: #30809
Refs: #30257
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Trott pushed a commit that referenced this issue Dec 7, 2019
PR-URL: #30809
Refs: #30257
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
targos pushed a commit that referenced this issue Dec 9, 2019
PR-URL: #30809
Refs: #30257
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
targos pushed a commit that referenced this issue Dec 9, 2019
PR-URL: #30809
Refs: #30257
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
@gengjiawen
Copy link
Member Author

I am thinking make this an github action, for our tracing memory issue.

Hopefully this will bring more people involved on this and make Node.js stablility to next level.

targos pushed a commit that referenced this issue Jan 14, 2020
PR-URL: #30809
Refs: #30257
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
targos pushed a commit that referenced this issue Jan 14, 2020
PR-URL: #30809
Refs: #30257
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
BethGriggs pushed a commit that referenced this issue Feb 6, 2020
PR-URL: #30809
Refs: #30257
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
BethGriggs pushed a commit that referenced this issue Feb 6, 2020
PR-URL: #30809
Refs: #30257
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
@gengjiawen gengjiawen added the help wanted Issues that need assistance from volunteers or PRs that need help to proceed. label Feb 28, 2020
addaleax added a commit to addaleax/node that referenced this issue Mar 21, 2020
@addaleax
Copy link
Member

#32406 should fix this (finally 🙂)

addaleax added a commit to addaleax/node that referenced this issue Sep 23, 2020
Refs: nodejs@d7f1107
Fixes: nodejs#30257

PR-URL: nodejs#32406
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
addaleax added a commit that referenced this issue Sep 23, 2020
Refs: d7f1107
Fixes: #30257

Backport-PR-URL: #35241
PR-URL: #32406
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. help wanted Issues that need assistance from volunteers or PRs that need help to proceed.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants