hintjens/filemq — pull request #2 by vperron (2012-12-06 08:26:25+00:00)
Title: Fixes memory corruption bug on server_destroy()

Valgrind backtrace about that:

==10696== 1 errors in context 1 of 1:
==10696== Invalid free() / delete / delete[] / realloc()
==10696== at 0x4C2A82E: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==10696== by 0x503D71C: s_item_destroy (zhash.c:157)
==10696== by 0x503D861: zhash_destroy (zhash.c:199)
==10696== by 0x5C97ED6: sub_destroy (fmq_server.c:281)
==10696== by 0x5C985A3: mount_sub_purge (fmq_server.c:466)
==10696== by 0x5C99083: terminate_the_client (fmq_server.c:719)
==10696== by 0x5C99ECE: server_client_execute (fmq_server.c:1017)
==10696== by 0x5C988AA: client_ping (fmq_server.c:552)
==10696== by 0x503E0CE: zhash_foreach (zhash.c:441)
==10696== by 0x5C9A533: server_thread (fmq_server.c:1164)
==10696== by 0x5046AE2: s_thread_shim (zthread.c:92)
==10696== by 0x5A6FE99: start_thread (pthread_create.c:308)
==10696== by 0x5340CBC: clone (clone.S:112)
==10696== Address 0x694e0e0 is 0 bytes inside a block of size 7 free'd
==10696== at 0x4C2A82E: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==10696== by 0x5C97103: fmq_patch_destroy (fmq_patch.c:76)
==10696== by 0x5C982FB: mount_refresh (fmq_server.c:403)
==10696== by 0x5C9949F: monitor_the_server (fmq_server.c:798)
==10696== by 0x5C9A556: server_thread (fmq_server.c:1168)
==10696== by 0x5046AE2: s_thread_shim (zthread.c:92)
==10696== by 0x5A6FE99: start_thread (pthread_create.c:308)
==10696== by 0x5340CBC: clone (clone.S:112)

On server _destroy, the latest zhash_destroy() deletes a values that had been already freed in fmq_patch_destroy(); it had been copied in the cache but not strdupped().