Skip to content

CDRIVER-3008 fix possible leak in run_json_general_test #1347

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

Merged
merged 2 commits into from
Jul 20, 2023

Conversation

kevinAlbs
Copy link
Collaborator

Summary

  • fix possible leak in run_json_general_test
  • document example use of MONGOC_JSON_SUBTEST

Background & Motivation

CDRIVER-3008 includes the reported leak discovered by Coverity. The leak can be reproduced with:

export MONGOC_JSON_SUBTEST="Aggregate with deterministic encryption"
./cmake-build/src/libmongoc/test-libmongoc -d --no-fork -l "/client_side_encryption/legacy/aggregate"

LSan reports:

==52500==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 40 byte(s) in 1 object(s) allocated from:
    #0 0x102f515b0 in wrap_malloc+0x8c (libclang_rt.asan_osx_dynamic.dylib:arm64+0x515b0) (BuildId: 2d3005610c2a36e7a5269cbe22ab009f32000000200000000100000000000b00)
    #1 0x100fb4c90 in bson_malloc bson-memory.c:100
    #2 0x100fd6508 in bson_strdup bson-string.c:331
    #3 0x10087c818 in _mongoc_getenv mongoc-util.c:683
    #4 0x100a13f08 in test_framework_getenv test-libmongoc.c:264
    #5 0x1009e4890 in run_json_general_test json-test.c:1819
    #6 0x100f18840 in test_client_side_encryption_cb test-mongoc-client-side-encryption.c:108
    #7 0x100eb3e7c in TestSuite_RunTest TestSuite.c:648
    #8 0x100eb19dc in TestSuite_RunAll TestSuite.c:1094
    #9 0x100eb0888 in TestSuite_Run TestSuite.c:1139
    #10 0x100607680 in main test-libmongoc-main.c:157
    #11 0x101df1088 in start+0x204 (dyld:arm64+0x5088) (BuildId: a2ee361189123e1dbf8bfed54862d4c932000000200000000100000000060c00)
    #12 0x902efffffffffffc  (<unknown module>)

@kevinAlbs kevinAlbs marked this pull request as ready for review July 18, 2023 19:53
@kevinAlbs kevinAlbs requested a review from joshbsiegel July 18, 2023 19:53
Copy link
Contributor

@joshbsiegel joshbsiegel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kevinAlbs kevinAlbs merged commit d5dfc9f into mongodb:master Jul 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants