Skip to content

Memory leak #5

Description

@lathakris

Hi,

I am using the rest client library to make an SSL connection to a HTTP server and make REST calls. I am using the release with the pthread fix. (1.0.2). I initiate the SSL connection and then keep doing the REST calls over the same connection until it returns error in which case I reconnect.

I am seeing that there seems to be a memory leak, the program is eventually running out of memory. I typically create the request, add the RestFilter_execute_curl_request in the filter chain and do RestClient_execute_request. At the end of the function, I free the filter, destroy the request and response.

I also set RestClient_add_curl_config_handler(&rcHandle, rest_disable_ssl_cert_check); to trust the cert.
The RestClient handle I keep reusing all the time.

Could you please let me know what went wrong here. Am I missing any other cleanup ? Thanks in advance for your response.

I used valgrind to debug and here is the sample of the trace. (there is more trace if you need)

==1041== 8 bytes in 1 blocks are still reachable in loss record 1 of 637
==1041== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==1041== by 0x5727DB2: CRYPTO_malloc (in /lib/libcrypto.so.1.0.0)
==1041== by 0x57A4D62: BUF_strndup (in /lib/libcrypto.so.1.0.0)
==1041== by 0x57FA5A6: ??? (in /lib/libcrypto.so.1.0.0)
==1041== by 0x57FAC63: CONF_module_add (in /lib/libcrypto.so.1.0.0)
==1041== by 0x57FAFED: OPENSSL_load_builtin_modules (in /lib/libcrypto.so.1.0.0)
==1041== by 0x54B3388: Curl_ossl_init (in /usr/lib/libcurl.so.4)
==1041== by 0x549BEC4: global_init (in /usr/lib/libcurl.so.4)
==1041== by 0x549C157: curl_easy_init (in /usr/lib/libcurl.so.4)
==1041== by 0x438852: RestFilter_execute_curl_request (rest_client.c:545)
==1041== by 0x409712: doAuth (restapi.c:191)
==1041== by 0x408172: checkFile (main.c:73)
==1041==
==1041== 8 bytes in 1 blocks are still reachable in loss record 2 of 637
==1041== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==1041== by 0x5727DB2: CRYPTO_malloc (in /lib/libcrypto.so.1.0.0)
==1041== by 0x579EEA3: ??? (in /lib/libcrypto.so.1.0.0)
==1041== by 0x579F478: ENGINE_add (in /lib/libcrypto.so.1.0.0)
==1041== by 0x57A47D0: ENGINE_load_rsax (in /lib/libcrypto.so.1.0.0)
==1041== by 0x57A12DD: ENGINE_load_builtin_engines (in /lib/libcrypto.so.1.0.0)
==1041== by 0x54B338D: Curl_ossl_init (in /usr/lib/libcurl.so.4)
==1041== by 0x549BEC4: global_init (in /usr/lib/libcurl.so.4)
==1041== by 0x549C157: curl_easy_init (in /usr/lib/libcurl.so.4)
==1041== by 0x438852: RestFilter_execute_curl_request (rest_client.c:545)
==1041== by 0x409712: doAuth (restapi.c:191)
==1041== by 0x408172: checkFile (main.c:73)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions