Skip Menu |

This queue is for tickets about the Math-GSL CPAN distribution.

Report information
The Basics
Id: 122911
Status: open
Priority: 0/
Queue: Math-GSL

People
Owner: Nobody in particular
Requestors: TONYC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



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
Hi, Tony Show quoted text
> 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.
Not sure if i understood it correctly. Should sp be incremented between calls to EXTEND? If I understood correctly, then EXTEND(sp+1,1) and EXTEND(sp+2,1) would do the trick? (kind of rusty on pointer arithmetic) Show quoted text
> 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.
Mostly sure. But I can try to prepare a patch to swig and submit it (or at least use the fixed templates n Math::GSL). Thank you Alberto