Skip to content

gemv no check on internal buffer size #173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
juliantaylor opened this issue Dec 19, 2012 · 7 comments
Closed

gemv no check on internal buffer size #173

juliantaylor opened this issue Dec 19, 2012 · 7 comments
Assignees
Labels
Milestone

Comments

@juliantaylor
Copy link

following script exceeds the internal buffer (16MB on x86, 32MB on x86_64) and just segfaults on x86 and x86_64
there is no check if the number of rows exceeds the internal buffer in interface/gemv.c

#include <math.h>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
typedef long blasint;
void sgemv_(char *, blasint *, blasint *, float *, float *, blasint *,  
            float *, blasint *, float *, float *, blasint *); 


int main(int argc, const char *argv[])
{   
    // increase here to exceed your archs buffer
    blasint row = 17*1024*1024/sizeof(float);
    blasint col = 1;
    blasint stride1 = 1;
    float al2 = 1;
    float bl2 = 0;
    float * a2 = malloc(row*col*sizeof(float));
    float * b2 = malloc(row*sizeof(float));
    float * v2 = malloc(row*sizeof(float));
    assert(a2);
    assert(b2);
    assert(v2);
    for (int i = 0; i < row*col; i++)
        a2[i] = 1;
    for (int i = 0; i < row; i++) {
        b2[i] = 1;
        v2[i] = 0;
    }   
    printf("%d %gMB\n", row*sizeof(float), row*sizeof(float)/1024./1024.);
    sgemv_("T", &row, &col, &al2, a2, &row,  
            b2, &stride1, &bl2, v2, &stride1); 
    printf("%g\n",v2[0] - (float)row*col);
    return 0;
}   
@juliantaylor
Copy link
Author

seems to be similar to gh-154

@juliantaylor
Copy link
Author

on x86_64 only seems to crash when threads are used (in kernel/x86_64/sgemv_t.S)
on 32bit x86 it crashes with and without threads in kernel/x86/gemv_t_sse.S

@xianyi
Copy link
Collaborator

xianyi commented Dec 23, 2012

Hi @juliantaylor ,

Could you test it ?

Thank you

Xianyi

@juliantaylor
Copy link
Author

64bit seems to work now but 32 bit still crashes with a segmentation fault in kernel/x86/gemv_t_sse.S:214

@xianyi
Copy link
Collaborator

xianyi commented Dec 25, 2012

Hi @juliantaylor ,

We fixed sgemv_t bug on x86. Now, it can pass your codes. Meanwhile, we also fixed the similar bug in gemv_n

XIanyi

@juliantaylor
Copy link
Author

thanks, it now also works in 32bit

@juliantaylor
Copy link
Author

see gh-154 for a testcase that still crashes on i386

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants