- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Run-Time Check Failure #2 - Stack around the variable 'ipiv' was corrupted.
The exception is thrown when the method returns, that is after the delete [] wpi call. If the call to sgetrf is removed the method executes and returns without corrupting the stack.
I'm using MKL 10.1.0.018 and Visual Studio 2008.
int _tmain(int argc, char *argv[])
{
const int M = 5;
const int K = 4;
const int N = 3;
float* p = new float[K*N];
float* w = new float[K*N];
float* wp = new float[K*N];
memset((void*)wp,0,(size_t)K*N*sizeof(float));
// ...
Foo(p,w,wp,N,N,K);
// ...
}
void Foo(const float* p,float* w,float* wp,int M,int N,int K){
int ipiv = 0;
int info = 0;
float work = 0;
int lwork = 0;
float* wpi = new float[N*N];
memset((void*)wpi,0,(size_t)N*N*sizeof(float));
cblas_sgemm(CblasRowMajor,CblasTrans,CblasNoTrans,N,N,K,1.0f,p,M,w,N,1.0f,wpi,N);
// if this called is removed, the stack does not become corrupt
sgetrf(&N,&N,wpi,&N,&ipiv,&info);
// ...
delete [] wpi;
}
Thanks in advance!
// olof
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Olof,
At the first glance, the cause of the problem dealt with ipiv:
please look at description of sgetrf: Ipiv == array, dimensional at least max(1,min(m.n)) and etc.
Therefore, replace int ipiv by int ipiv
Please let us know if any further problems.
--Gennady
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Olof,
At the first glance, the cause of the problem dealt with ipiv:
please look at description of sgetrf: Ipiv == array, dimensional at least max(1,min(m.n)) and etc.
Therefore, replace int ipiv by int ipiv
Please let us know if any further problems.
--Gennady
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Olof,
At the first glance, the cause of the problem dealt with ipiv:
please look at description of sgetrf: Ipiv == array, dimensional at least max(1,min(m.n)) and etc.
Therefore, replace int ipiv by int ipiv
Please let us know if any further problems.
--Gennady
Thank you! The stack is now safe and sound=)

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page