real-logic / aeron

Efficient reliable UDP unicast, UDP multicast, and IPC message transport
Apache License 2.0
7.37k stars 888 forks source link

[C] Allocate a buffer for client name. #1637

Closed amoskvin closed 2 months ago

amoskvin commented 2 months ago

Setting the client name with the C library causes a crash when closing the context because it tries to free a pointer that hasn't been heap-allocated. I fixed it by copying the name to a new buffer.

The issue can be reproduced with sample binaries:

$ AERON_CLIENT_NAME=oops ./binaries/cpong 
Subscribing Ping at channel aeron:udp?endpoint=localhost:20123 on Stream ID 1002
Publishing Pong at channel aeron:udp?endpoint=localhost:20124 on Stream ID 1003
Subscription channel status 1
Publication channel status 1
^Cmunmap_chunk(): invalid pointer
Aborted (core dumped)

Another option would be to just not free, but I think holding it in a new buffer is more robust and consistent with aeron_context_set_dir().

mikeb01 commented 2 months ago

This should be fixed in 9b3e7cb.