Skip to content
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

Fix crash on exception 'msgpack::v1::insufficient_bytes' #42

Merged
merged 4 commits into from
Sep 1, 2021

Conversation

rohit-px2
Copy link
Owner

@rohit-px2 rohit-px2 commented Aug 31, 2021

Fixes #40, #41, #23
In the current message unpacking strategy, if the data to be unpacked is in a bad format, it throws an exception of 'msgpack::v1::insufficient_bytes' and then terminates.
The desired solution would be able to handle this bad data and smoothly continue on.

Going by https://github.com/msgpack/msgpack-c/wiki/v2_0_cpp_unpacker,
it looks like msgpack::unpacker should just return false and break the
loop if there's insufficient data (insufficient bytes).
@rohit-px2
Copy link
Owner Author

Right now msgpack::unpacker gets its space consumed by each message and the program crashes when there is no more space (read()-s into an invalid ptr address, hence the 'bad address' error).
To fix this we'll keep the original buffer object with a size of buffer_maxsize, and when we read into that buffer, we'll create the unpacker and memcpy the data into it (size will be the number of bytes read in, not the max message size) so that we don't have to allocate buffer_maxsize bytes on each loop.

This prevents the buffer from getting "full" from unpacking too much
data.
Nvim::eval() is pretty badly written and should probably be removed.
Linux build fails with atomic_wait
@rohit-px2 rohit-px2 changed the title [WIP] Fix crash on exception 'msgpack::v1::insufficient_bytes' Fix crash on exception 'msgpack::v1::insufficient_bytes' Aug 31, 2021
@rohit-px2 rohit-px2 merged commit 99610f2 into main Sep 1, 2021
@rohit-px2 rohit-px2 deleted the exception_insufficient_bytes branch October 31, 2021 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant