-
-
Notifications
You must be signed in to change notification settings - Fork 499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nng_msg_insert: munmap_chunk(): invalid pointer #1808
Comments
My initial attempts at reproduction did not succeed. I'm on a mac though, with m1. This could differ on 32-bit vs 64-bit cpus as well. Having said all that, munmap_chunk is not inside NNG itself, and we don't have this This feels like some data corruption somewhere or a problem with your C library perhaps? If there is a bug in nng here it is most likely in I'm going to play with this some more because it should be possible to verify this with just doing trial allocations, inserts, and frees. Stay tuned. |
Ok, I've confirmed it, and have a fix. Stay tuned. |
With specific message sizes, we the shuffle of data for msg insert can calculate the wrong value, leading to heap corruption. This includes a stress test for msg insert to hopefully exercise every reasonable edge case.
Fixed in master. I'll probably cut a release soon. |
Describe the bug
I'm facing a bug when sending a message with a specific number of bytes (if any) from the request to the response socket.
Expected behavior
The message is sent without any errors.
Actual Behavior
I was studying the nng lib to create a request/response socket with IPC protocol. In my testing, I faced a case when sending a specific "string" through the nng_sendmsg function. The explanation and code below will further specify the context:
I allocate a message with
nng_msg_alloc
, insert the string at the beginning of the message body usingnng_msg_insert
, and when I callnng_sendmsg
themunmap_chunk(): invalid pointer
error is thrown.To get around this, I change
nng_msg_insert
tonng_msg_append
, and no more errors occur.The
funnyfact is that with a string lower or higher length than the string specified in the code, the message is sent correctly. I don't know if there is some kind of undefined memory allocation behavior withnng_msg_insert
, but it's strange!Environment Details
To Reproduce
client.cpp
server.cpp
To compile:
g++ client.cpp -o client -lnng
g++ server.cpp -o server -lnng
To run:
First run the
server
and then run theclient
.The text was updated successfully, but these errors were encountered: