-
Notifications
You must be signed in to change notification settings - Fork 9
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 for reading zero-length values using RawRead #26
base: master
Are you sure you want to change the base?
Conversation
@missinglink - how to separate Nil from empty []byte{} ? Does MDBX support both? |
LMDB doesn't seem to have a distinction between nil and empty 🤷 |
The C value |
But reading either form prior to this PR (in combination with |
I think it must be EmptyByteSlice, not nil. Because we using Nil as indicator of “end of iteration over dbi”. If you insert key of len 0 - it will be sorted in the beginning of dbi, not in the end. So, it behave as empty byte slice inside db, then it must be returned as empty byte slice. What official C++ bindings return in this case? |
@missinglink answer from mdbx maintainer https://t.me/libmdbx/3882 |
I'm happy to change it to I'll update this PR as I'd like to get something merged which avoids the panic. |
Reading zero-length values using `RawRead` (ie. `nil`) the `getBytes()` function triggers a fatal `SIGBUS` error. We can avoid this by detecting the case where `val.mv_size == 0` and avoiding attempts to access that memory.
updated via rebase |
Out of curiosity, what does edit: agh it's called a "Full slice expression" and explicitly sets the capacity too, I learned something new today. |
when iterating over DupSort DBI - we using nil-check of value - to indicate end of sub-DBI. |
@missinglink - just double-confirm. You wan't merge this PR to |
Correct, for lmdb not mdbx |
When reading zero-length values using
RawRead
(ie.nil
,empty
) thegetBytes()
function triggers a fatalSIGBUS
error.We can avoid this by detecting the case where
val.mv_size == 0
and avoiding attempts to access that memory.resolves #25
ref: https://github.com/ledgerwatch/lmdb-go/blob/master/lmdb/lmdb.h#L255