Torsten Schoenfeld
2013-09-25 18:50:06 UTC
I recently tracked down a difficult bug that occured only when one of my
XS modules was used in conjunction with certain other XS modules (e.g.,
XML::Parser or String::Approx). It turned out to be due to the
incorrect assumption that PL_na will always be zero. Specifically, we used
newSVpv (string, PL_na) // do not do this
when we didn't have the string's length. This breaks if some other XS
module writes to PL_na (via SvPV, most likely). So always use an
explicit zero instead:
newSVpv (string, 0)
XS modules was used in conjunction with certain other XS modules (e.g.,
XML::Parser or String::Approx). It turned out to be due to the
incorrect assumption that PL_na will always be zero. Specifically, we used
newSVpv (string, PL_na) // do not do this
when we didn't have the string's length. This breaks if some other XS
module writes to PL_na (via SvPV, most likely). So always use an
explicit zero instead:
newSVpv (string, 0)