fix(agent): Fix nr_header_create_distributed_trace_map mem leak when hashmap is destroyed #1017
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This function created a new hashmap, but didn's pass the string dtor in so any strdupped values were not being freed when the hashmap was destroyed.
valgrind output from a multiverse run showed:
==220== by 0x6AA4680: nr_strdup (util_memory.c:156)
==220== by 0x6A83BD3: nr_header_create_distributed_trace_map (nr_header.c:60)
==220== by 0x6A45D28: nr_php_amqplib_retrieve_dt_headers (lib_php_amqplib.c:503)
==220== by 0x6A45D28: nr_rabbitmq_basic_get (lib_php_amqplib.c:742)
==220== by 0x6A74993: nr_zend_call_orig_execute_special (php_user_instrument.c:105)
==220== by 0x6A52EAA: nr_php_instrument_func_end (php_execute.c:2086)
==220== by 0x6A54D5B: nr_php_observer_fcall_end (php_execute.c:2188)
==220== by 0x71D7ED: zend_observer_fcall_end (in /usr/local/bin/php)
==220== by 0x6E79FF: execute_ex (in /usr/local/bin/php)
==220== by 0x6F0B42: zend_execute (in /usr/local/bin/php)
==220== by 0x67C06F: zend_execute_scripts (in /usr/local/bin/php)
==220== by 0x60FA3D: php_execute_script (in /usr/local/bin/php)
after applying the fix, valgrind had no issues.