Skip to content

Memory leaks in running tests #989

@HuangJian

Description

@HuangJian

Describe the bug
When running the test with ASan enabled, it reports a lot of memory leaks.

To Reproduce
Steps to reproduce the bug:

  1. install clang-20 to build the project as documented in the librime-qjs project.
  2. make clean
  3. make debug CFLAGS="-g -fsanitize=address" LDFLAGS="-fsanitize=address"
  4. cd debug/test
  5. ASAN_OPTIONS=detect_leaks=1 ./rime_test > rime_test.leak.log 2>&1

Expected behavior
There should not be any memory leak issue reported in running the tests.

Log

==87120==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 72 byte(s) in 1 object(s) allocated from:
    #0 0x00010b6c5f9d in _Znwm+0x7d (libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x6af9d)
    #1 0x00010c5e195a in rime_gears_initialize() gears_module.cc:80
    #2 0x00010c47842b in rime::ModuleManager::LoadModule(rime_module_t*) module.cc:32
    #3 0x00010c48d3ce in rime::LoadModules(char const**) setup.cc:37
    #4 0x00010c48d29f in rime::rime_default_initialize() setup.cc:30
    #5 0x00010c47842b in rime::ModuleManager::LoadModule(rime_module_t*) module.cc:32
    #6 0x00010c48d3ce in rime::LoadModules(char const**) setup.cc:37
    #7 0x00010af419a6 in main rime_test_main.cc:15
    #8 0x00011942b52d in start+0x1cd (dyld:x86_64+0x552d)

The full log file: rime_test.leak.log.zip

Package:

  • OS: macOS 12.7.6 (Intel)
  • Version: commit 1c23358 (tag: 1.13.1, origin/master, origin/HEAD, master)

Additional context
With the Squirrel frontend in the same system, it seems the memory leak problem does not happen in the built librime.dylib.
I guess there could be something wrong in the test setup code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions