This forum has been archived. All content is frozen. Please use KDE Discuss instead.

umfpack bug?

Tags: None
(comma "," separated)
zoharl
Registered Member
Posts
55
Karma
0
OS

umfpack bug?

Fri Jul 13, 2012 7:01 pm
Any idea why this code crashes (debug mode):

Code: Select all
#include "stdafx.h"
 
#include <Eigen/Sparse>
#include <umfpack.h>
#include <Eigen/src/UmfPackSupport/UmfPackSupport.h>
 
using namespace Eigen;
 
#include <vector>
 
#pragma comment(lib, "libumfpack.lib")
#pragma comment(lib, "libamd.lib")
#pragma comment(lib, "blas.lib")
 
int _tmain(int argc, _TCHAR* argv[])
{
   SparseMatrix<double> L2(24,24);
   L2.coeffRef(1,1) = 1;
   L2.finalize();
   L2.makeCompressed();
   UmfPackLU<SparseMatrix<double> > solver;
   solver.compute(L2);
 
   std::vector<MatrixXd> HPsi;
 
   return 0;
}


while commenting the line

Code: Select all
// std::vector<MatrixXd> HPsi;


fixes it?

I'm using eigen 3.1.0, latest SuiteSparse and vs2010.

Thanks
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: umfpack bug?

Fri Jul 13, 2012 10:00 pm
please, could you paste a backtrace.

(Note that your matrix is singular, and it cannot be used for solving, so umfpack should report an error)
zoharl
Registered Member
Posts
55
Karma
0
OS

Re: umfpack bug?

Fri Jul 13, 2012 10:27 pm
I believe umfpack can usually solve a singular system without a problem. In this case that's not my point, and you can assign any matrix (besides zeros) that you want. There's something wrong here with the compilation or linkage when I add the matrix vector. It took me hours to find this bug, and the matrix vector was actually defined in a separate module.

Here is the error and the stack trace,

For the old SuiteSparse version 3.4.0:

Code: Select all
HEAP[test1.exe]: Invalid address specified to RtlValidateHeap( 001C0000, 004D4C20 )

    test1.exe!_umfpack_di_symbolic()  + 0x4a bytes   
   test1.exe!Eigen::umfpack_symbolic(int n_row, int n_col, const int * Ap, const int * Ai, const double * Ax, void * * Symbolic, const double * Control, double * Info)  Line 50 + 0x25 bytes   C++
    test1.exe!Eigen::UmfPackLU<Eigen::SparseMatrix<double,0,int> >::analyzePattern(const Eigen::SparseMatrix<double,0,int> & matrix)  Line 259 + 0x3f bytes   C++
    test1.exe!Eigen::UmfPackLU<Eigen::SparseMatrix<double,0,int> >::compute(const Eigen::SparseMatrix<double,0,int> & matrix)  Line 213   C++
    test1.exe!wmain(int argc, wchar_t * * argv)  Line 25   C++
    test1.exe!__tmainCRTStartup()  Line 552 + 0x19 bytes   C
    test1.exe!wmainCRTStartup()  Line 371   C


The new SuiteSparse version 4.0.1 which needs also:

Code: Select all
#pragma comment(lib, "libcolamd.lib")
#pragma comment(lib, "libcholmod.lib")
#pragma comment(lib, "libsuitesparseconfig.lib")


gives:

Code: Select all
 Invalid address specified to RtlValidateHeap( 00280000, 002F4C20 )

    ntdll.dll!779604e4()    
    [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]   
    ntdll.dll!77922a2a()    
    ntdll.dll!778f1cd7()    
    ntdll.dll!7791a71a()    
    KernelBase.dll!75354bf9()    
>   msvcr100d.dll!_CrtIsValidHeapPointer(const void * pUserData)  Line 2036   C++
    msvcr100d.dll!_free_dbg_nolock(void * pUserData, int nBlockUse)  Line 1322 + 0x9 bytes   C++
    msvcr100d.dll!_free_dbg(void * pUserData, int nBlockUse)  Line 1265 + 0xd bytes   C++
    msvcr100d.dll!free(void * pUserData)  Line 49 + 0xb bytes   C++
    test1.exe!_umf_i_free()  + 0x14 bytes   
    test1.exe!_umf_i_free()  + 0x190d bytes   
    test1.exe!Eigen::CwiseNullaryOp<Eigen::internal::scalar_constant_op<int>,Eigen::Matrix<int,-1,1,0,-1,1> >::cols()  Line 82 + 0x28 bytes   C++



I wonder, does this code run well on your computer?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: umfpack bug?

Sat Jul 14, 2012 7:12 am
very strange, there is clearly a linking issue. I cannot reproduce the error with gcc or clang, and cannot try it with MSVC (no windows around). What's "stdafx.h" btw? Something specific to MSVC? What if you remove it? What if you link to umfpack libs the standard way?
zoharl
Registered Member
Posts
55
Karma
0
OS

Re: umfpack bug?

Sat Jul 14, 2012 3:27 pm
XXXXing A! >:(

Pardon my French. The stdafx.h is just some MS nonsense called precompiled header, which I just removed.

But linking the libraries manually did the trick!
Hours spent and I would never have thought about it. How did you even come up with the idea?
zoharl
Registered Member
Posts
55
Karma
0
OS

Re: umfpack bug?

Mon Jul 16, 2012 9:36 am
First I would like to thank @ggael for the inspired solution.

Second I am still pursuing the reason for the problem and how the solution resolved it. Currently for me adding the libraries as an input to the linker explicitly through the project options instead of through #pragma lib as a solution, is the same as someone would have told me to run visual studio from the link in the start menu instead of the link on the desktop, and it would have resolved the problem.

An info that my be relevant:

1. The libraries were build with mingw gcc.
2. I wrote the code on the 13th of this month, almost in a full moon... ;)
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: umfpack bug?

Tue Jul 17, 2012 11:54 am
no clue, you should ask on a MSVC forum.
zoharl
Registered Member
Posts
55
Karma
0
OS
zoharl
Registered Member
Posts
55
Karma
0
OS

Re: umfpack bug?

Sun Jul 22, 2012 7:47 am
I'm afraid that salvation won't come from the VC++ forum. Just look at the link above, I think that the forum has been run by experiments of AI bots.

Anyway I have something even more annoying. I can't reproduce the bug. Suddenly everything is fine when I use the pragma lib, and I have no idea why or what changed. Maybe it's related to restarting windows (which would be even more annoying), although I think that in my desperation I did try this one.


Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], Google [Bot]