bmatsuo / lmdb-go

Bindings for the LMDB C library
BSD 3-Clause "New" or "Revised" License
158 stars 59 forks source link

PutMulti incorrectly panics when passed an empty page #106

Open bmatsuo opened 7 years ago

bmatsuo commented 7 years ago

The lmdb package has to adjust empty inputs to allow CGO calls to succeed in the general case. But this adjustment causes Cursor.PutMulti to panic when it tries to validate the consistency of its arguments.

Unfortunately, in the current release of LMDB fixing this bug would only cause LMDB to segfault moments later. But once this bug in LMDB is fixed this bug should be addressed.

Note that the plan in #99 is to introduce new function for writing Multiple values. This function will not have the bug. This means that it will probably segfault with a nil-pointer reference until an fix for LMDB is released, or until a fix can be confirmed so much that it can be emulated.

The fix in LMDB will likely trigger an EINVAL error in these cases, which would not be hard to emulate. It is just a matter of making sure the LMDB folks have committed to this.