Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-17837

Memory leak when web hook cannot connect to URL

    XMLWordPrintable

    Details

    • Team:
      Team A
    • Sprint:
      Sprint 64 (May 2020), Sprint 65 (Jun 2020)
    • Story Points:
      1

      Description

      Fix:

      diff --git a/src/libs/zbxembed/httprequest.c b/src/libs/zbxembed/httprequest.c
      index 1ee15ef7a5..060ae792a9 100644
      --- a/src/libs/zbxembed/httprequest.c
      +++ b/src/libs/zbxembed/httprequest.c
      @@ -266,6 +266,8 @@ static duk_ret_t    es_httprequest_query(duk_context *ctx, const char *http_request
       
              if (CURLE_OK != (err = curl_easy_perform(request->handle)))
              {
      +               zbx_free(url);  /* free before longjmp()*/
      +               zbx_free(contents);
                      ret = duk_error(ctx, DUK_RET_TYPE_ERROR, "cannot get URL: %s.", curl_easy_strerror(err));
                      goto out;
              }
      

      On media type test:

      ==125726== HEAP SUMMARY:
      ==125726==     in use at exit: 387,097 bytes in 7,656 blocks
      ==125726==   total heap usage: 14,027 allocs, 6,371 frees, 2,107,324 bytes allocated
      ==125726== 
      ==125726== 15 bytes in 1 blocks are definitely lost in loss record 23 of 774
      ==125726==    at 0x483A809: malloc (vg_replace_malloc.c:309)
      ==125726==    by 0x5D8B9E: zbx_malloc2 (misc.c:575)
      ==125726==    by 0x5E1ADB: zbx_cesu8_to_utf8 (str.c:2396)
      ==125726==    by 0x49A96E: es_httprequest_query (httprequest.c:219)
      ==125726==    by 0x49AE0E: es_httprequest_post (httprequest.c:315)
      ==125726==    by 0x4DB0AC: duk__handle_call_raw (duktape.c:64989)
      ==125726==    by 0x4DB444: duk_handle_call_unprotected (duktape.c:65143)
      ==125726==    by 0x4E8039: duk__executor_handle_call (duktape.c:76454)
      ==125726==    by 0x4FA79F: duk__js_execute_bytecode_inner (duktape.c:78544)
      ==125726==    by 0x4E821B: duk_js_execute_bytecode (duktape.c:76729)
      ==125726==    by 0x4DB04D: duk__handle_call_raw (duktape.c:64967)
      ==125726==    by 0x4DB444: duk_handle_call_unprotected (duktape.c:65143)
      ==125726== 
      ==125726== 116 bytes in 1 blocks are definitely lost in loss record 591 of 774
      ==125726==    at 0x483A809: malloc (vg_replace_malloc.c:309)
      ==125726==    by 0x5D8B9E: zbx_malloc2 (misc.c:575)
      ==125726==    by 0x5E1ADB: zbx_cesu8_to_utf8 (str.c:2396)
      ==125726==    by 0x49A9DF: es_httprequest_query (httprequest.c:227)
      ==125726==    by 0x49AE0E: es_httprequest_post (httprequest.c:315)
      ==125726==    by 0x4DB0AC: duk__handle_call_raw (duktape.c:64989)
      ==125726==    by 0x4DB444: duk_handle_call_unprotected (duktape.c:65143)
      ==125726==    by 0x4E8039: duk__executor_handle_call (duktape.c:76454)
      ==125726==    by 0x4FA79F: duk__js_execute_bytecode_inner (duktape.c:78544)
      ==125726==    by 0x4E821B: duk_js_execute_bytecode (duktape.c:76729)
      ==125726==    by 0x4DB04D: duk__handle_call_raw (duktape.c:64967)
      ==125726==    by 0x4DB444: duk_handle_call_unprotected (duktape.c:65143)
      
      

      Happens when there is such error

      Details Media type test failed.
      
          Error: cannot get URL: Couldn't connect to server.
          at [anon] (httprequest.c:269) internal
          at [anon] () native strict preventsyield
          at [anon] (function:7) preventsyield
      
      var req = new CurlHttpRequest();
      req.SetProxy('socks5h://localhost:1080');
      req.AddHeader('Content-Type: application/x-www-form-urlencoded');
       
      Zabbix.Log(4, 'webhook request value='+value);
       
      req.Post('localhost:8080','payload='+value);
       
      Zabbix.Log(4, 'response code: '+req.Status());
       
      return JSON.stringify({
        'tags': {
          'endpoint': 'slack'
        }
      });
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              wiper Andris Zeila
              Reporter:
              vso Vladislavs Sokurenko
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: