Fix a segfault in gemv when MAX_STACK_ALLOC is set

* stack_alloc_size is needed after the implementation call
but it may be overwritten if it's optimized to a register,
because some gemv implementation (ex: dgemv_n.S) do not
restore all register (ex: r10).
* do the same in ger.c for the same reasons even if the bug
has not been observed.
This commit is contained in:
Jerome Robert 2015-01-29 09:55:57 +01:00
parent 63c6fcfa0a
commit b17ccb4c5c
2 changed files with 4 additions and 2 deletions

View File

@ -209,7 +209,9 @@ void CNAME(enum CBLAS_ORDER order,
if (incy < 0) y -= (leny - 1) * incy;
#ifdef MAX_STACK_ALLOC
int stack_alloc_size = m + n;
// make it volatile because some gemv implementation (ex: dgemv_n.S)
// do not restore all register
volatile int stack_alloc_size = m + n;
if(stack_alloc_size < 128)
//dgemv_n.S require a 128 bytes buffer
stack_alloc_size = 128;

View File

@ -172,7 +172,7 @@ void CNAME(enum CBLAS_ORDER order,
if (incx < 0) x -= (m - 1) * incx;
#ifdef MAX_STACK_ALLOC
int stack_alloc_size = m;
volatile int stack_alloc_size = m;
if(stack_alloc_size > MAX_STACK_ALLOC / sizeof(FLOAT))
stack_alloc_size = 0;
FLOAT stack_buffer[stack_alloc_size];