Subject: | several functions fail to extend the stack |
At least the following functions fail to extend the stack before using space on it:
Math::GSL::Randistc::gsl_ran_dir_3d
Math::GSL::Matrixc::gsl_matrix_minmax_index
Math::GSL::Fitc::gsl_fit_linear
Looking at gsl_fit_linear(), it has (generated) code like:
if (SWIG_IsTmpObj(res6)) {
if (argvi >= items) EXTEND(sp,1); ST(argvi) = SWIG_From_double SWIG_PERL_CALL_ARGS_1((*arg6)); argvi++ ;
} else {
int new_flags = SWIG_IsNewObj(res6) ? (SWIG_POINTER_OWN | 0) : 0;
if (argvi >= items) EXTEND(sp,1); ST(argvi) = SWIG_NewPointerObj((void*)(arg6), SWIGTYPE_p_double, new_flags); argvi++ ;
}
if (SWIG_IsTmpObj(res7)) {
if (argvi >= items) EXTEND(sp,1); ST(argvi) = SWIG_From_double SWIG_PERL_CALL_ARGS_1((*arg7)); argvi++ ;
} else {
int new_flags = SWIG_IsNewObj(res7) ? (SWIG_POINTER_OWN | 0) : 0;
if (argvi >= items) EXTEND(sp,1); ST(argvi) = SWIG_NewPointerObj((void*)(arg7), SWIGTYPE_p_double, new_flags); argvi++ ;
}
The EXTEND() macro extends the stack relative to the first argument, but this code does an extend, doesn't adjust sp, then extends by 1 again, against the same base so no extra space is allocated.
This code could potentially be writing beyond the end of an allocated block.
If I understand your build process, unfortunately this looks like a bug in SWIG.
Tony