ZMQ – Invalid free() / delete / delete[] / realloc() / __libc_freeres error in Valgrind

Below is some simple code with ZMQ.

zmq:context_t context(1);
zmq::socket_t MPC1Socket(context, ZMQ_DEALER);
MPC1Socket.setsockopt(ZMQ_IDENTITY,”test”, 5);
MPC1Socket.connect(“tcp://localhost:8001);
If (MPC1Socket != NULL) MPC1Socket.close();
If (context != NULL) context.close();

Strangely enough, I got the following error when profiling it in valgrind.

# valgrind --leak-check=full --suppressions=./valgrind.supp ./MasterInterface

 

==11063== Invalid free() / delete / delete[] / realloc()
==11063==    at 0x4C2AD17: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==11063==    by 0x5C25A8B: __libc_freeres (in /usr/lib64/libc-2.17.so)
==11063==    by 0x4A246B4: _vgnU_freeres (in /usr/lib64/valgrind/vgpreload_core-amd64-linux.so)
==11063==    by 0x5AFAE0A: __run_exit_handlers (in /usr/lib64/libc-2.17.so)
==11063==    by 0x5AFAE94: exit (in /usr/lib64/libc-2.17.so)
==11063==    by 0x5AE3AFB: (below main) (in /usr/lib64/libc-2.17.so)
==11063==  Address 0x5e7c3d0 is 0 bytes inside data symbol "noai6ai_cached"

 

Solution?

Change localhost to 127.0.0.1. (don’t ask me why)

MPC1Socket.connect(“tcp://localhost:8001);

to

MPC1Socket.connect(“tcp://127.0.0.1:8001);

Not saying that this is definitely the issue when you encounter the freeres problem. But you could give it a try.

Advertisements

One thought on “ZMQ – Invalid free() / delete / delete[] / realloc() / __libc_freeres error in Valgrind

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s