Skip to content

napi mem leak test on valgrind #44518

Description

@jinfeihan57

Version

v16.16.0

Platform

x86_64

Subsystem

Ubuntu20.04

What steps will reproduce the bug?

run this project node-addon-examples helloworld

How often does it reproduce? Is there a required condition?

Every time.

What is the expected behavior?

mem leak.
==3277602== LEAK SUMMARY:
==3277602==    definitely lost: 64 bytes in 1 blocks
==3277602==    indirectly lost: 0 bytes in 0 blocks
==3277602==      possibly lost: 304 bytes in 1 blocks
==3277602==    still reachable: 9,603 bytes in 30 blocks
==3277602==         suppressed: 0 bytes in 0 blocks
==3277602== Reachable blocks (those to which a pointer was found) are not shown.
==3277602== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==3277602==
==3277602== For lists of detected and suppressed errors, rerun with: -s
==3277602== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)

What do you see instead?

ohos@ubuntu20:/node-addon-examples/1_hello_world/napi$ npm install --debug

> hello_world@0.0.0 install
> node-gyp rebuild

gyp info it worked if it ends with ok
gyp info using node-gyp@9.0.0
gyp info using node@16.16.0 | linux | x64
gyp info find Python using Python version 3.8.10 found at "/usr/bin/python3"
gyp info spawn /usr/bin/python3
gyp info spawn args [
gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/home/ohos/node-addon-examples/1_hello_world/napi/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/ohos/.cache/node-gyp/16.16.0/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/home/ohos/.cache/node-gyp/16.16.0',
gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/home/ohos/.cache/node-gyp/16.16.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/home/ohos/node-addon-examples/1_hello_world/napi',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Debug', '-C', 'build' ]
make: Entering directory '/home/ohos/node-addon-examples/1_hello_world/napi/build'
  CC(target) Debug/obj.target/hello/hello.o
  SOLINK_MODULE(target) Debug/obj.target/hello.node
  COPY Debug/hello.node
make: Leaving directory '/home/ohos/node-addon-examples/1_hello_world/napi/build'
gyp info ok

added 1 package in 4s
ohos@ubuntu20:/node-addon-examples/1_hello_world/napi$ ls
binding.gyp  build  hello.c  hello.js  node_modules  package.json  package-lock.json  testvalgrind.c
ohos@ubuntu20:/node-addon-examples/1_hello_world/napi$ valgrind --leak-check=full node hello.js
==3277602== Memcheck, a memory error detector
==3277602== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==3277602== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==3277602== Command: node hello.js
==3277602==
world
==3277602==
==3277602== HEAP SUMMARY:
==3277602==     in use at exit: 9,971 bytes in 32 blocks
==3277602==   total heap usage: 16,532 allocs, 16,500 frees, 15,121,778 bytes allocated
==3277602==
==3277602== 64 bytes in 1 blocks are definitely lost in loss record 13 of 32
==3277602==    at 0x4858E76: operator new(unsigned long) (vg_replace_malloc.c:344)
==3277602==    by 0xAD21C5: napi_module_register (in /usr/local/bin/node)
==3277602==    by 0x4A0D2F6: _register_hello (hello.c:23)
==3277602==    by 0x482EB99: call_init.part.0 (dl-init.c:72)
==3277602==    by 0x482ECA0: call_init (dl-init.c:30)
==3277602==    by 0x482ECA0: _dl_init (dl-init.c:119)
==3277602==    by 0x559F984: _dl_catch_exception (dl-error-skeleton.c:182)
==3277602==    by 0x48330CE: dl_open_worker (dl-open.c:758)
==3277602==    by 0x559F927: _dl_catch_exception (dl-error-skeleton.c:208)
==3277602==    by 0x4832609: _dl_open (dl-open.c:837)
==3277602==    by 0x487534B: dlopen_doit (dlopen.c:66)
==3277602==    by 0x559F927: _dl_catch_exception (dl-error-skeleton.c:208)
==3277602==    by 0x559F9F2: _dl_catch_error (dl-error-skeleton.c:227)
==3277602==
==3277602== 304 bytes in 1 blocks are possibly lost in loss record 25 of 32
==3277602==    at 0x485AB0A: calloc (vg_replace_malloc.c:762)
==3277602==    by 0x48319DA: allocate_dtv (dl-tls.c:286)
==3277602==    by 0x48319DA: _dl_allocate_tls (dl-tls.c:532)
==3277602==    by 0x49ED322: allocate_stack (allocatestack.c:622)
==3277602==    by 0x49ED322: pthread_create@@GLIBC_2.2.5 (pthread_create.c:660)
==3277602==    by 0xC11EE0: node::inspector::Agent::Start(std::string const&, node::DebugOptions const&, std::shared_ptr<node::ExclusiveAccess<node::HostPort, node::MutexBase<node::LibuvMutexTraits> > >, bool) (in /usr/local/bin/node)
==3277602==    by 0xACA168: node::Environment::InitializeInspector(std::unique_ptr<node::inspector::ParentInspectorHandle, std::default_delete<node::inspector::ParentInspectorHandle> >) (in /usr/local/bin/node)
==3277602==    by 0xB4C7B7: node::NodeMainInstance::CreateMainEnvironment(int*, node::EnvSerializeInfo const*) (in /usr/local/bin/node)
==3277602==    by 0xB4C8D6: node::NodeMainInstance::Run(node::EnvSerializeInfo const*) (in /usr/local/bin/node)
==3277602==    by 0xACE5A1: node::Start(int, char**) (in /usr/local/bin/node)
==3277602==    by 0x5463082: (below main) (libc-start.c:308)
==3277602==
==3277602== LEAK SUMMARY:
==3277602==    definitely lost: 64 bytes in 1 blocks
==3277602==    indirectly lost: 0 bytes in 0 blocks
==3277602==      possibly lost: 304 bytes in 1 blocks
==3277602==    still reachable: 9,603 bytes in 30 blocks
==3277602==         suppressed: 0 bytes in 0 blocks
==3277602== Reachable blocks (those to which a pointer was found) are not shown.
==3277602== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==3277602==
==3277602== For lists of detected and suppressed errors, rerun with: -s
==3277602== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
ohos@ubuntu20:/node-addon-examples/1_hello_world/napi$ node --version
v16.16.0

Additional information

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    node-apiIssues and PRs related to Node-API.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions