[KinoSearch] Seg fault on trunk r3834
Marvin Humphrey
marvin at rectangular.com
Sun Sep 7 14:02:58 PDT 2008
On Sep 7, 2008, at 11:39 AM, Dan wrote:
> ==414== Invalid read of size 4
> ==414== at 0x457AB6C: kino_DocReader_fetch_doc (DocReader.c:54)
Thanks to the Valgrind output, this was easy to track down.
DocReader, recently refactored, was freaking when it encountered a
field value of "". Somehow the test suite had managed to avoid
presenting DocReader with such a value up till now.
The segfault occurred at the SvPVX(value_sv) directive in the
following code from xs/KinoSearch/DocReader.c. SvPVX is a macro for
accessing an SV's string pointer directly -- it doesn't check first
whether the SV holds a valid string.
/* Read the field value. */
value_len = Kino_InStream_Read_C32(ds_in);
- value_sv = newSV(value_len);
+ value_sv = newSV((value_len ? value_len : 1));
Kino_InStream_Read_Bytes(ds_in, SvPVX(value_sv), value_len);
The solution was to guarantee that the SV contains a string by always
providing newSV() with a non-zero length.
Repository revision 3841 should resolve your issue.
Thanks for the report,
Marvin Humphrey
Rectangular Research
http://www.rectangular.com/
More information about the kinosearch
mailing list