(Only CodeBlock) of 7.1 bug, openCv cvGEMM(),cvmMul(),cvMatMul() ... #1371

Closed
yty opened this Issue Jul 1, 2012 · 18 comments

Comments

Projects
None yet
6 participants

yty commented Jul 1, 2012

Program runs, it might crash....
In the same test in of7.0 no problem....

of 7.1 run .....

windows messageBox "A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available."

void testApp:: PrintMatrix(CvMat *Matrix,int Rows,int Cols,int Channels)
{
    for(int i=0;i<Rows;i++)
    {
        for(int j=0;j<Cols;j++)
        {
            for(int k=0;k<Channels;k++)
            {
                printf("%.2f ",cvGet2D(Matrix,i,j).val[k]);
            }
        }
        printf("\n");
    }
}
//--------------------------------------------------------------
void testApp::setup(){
    float array1[]={3,1,2,0,1,5};
    float array2[]={4,3,1,1,6,0};
    float array3[]={-10,-2,-20,10};
    CvMat *A=cvCreateMat(2,3,CV_32FC1);
    CvMat *B=cvCreateMat(3,2,CV_32FC1);
    CvMat *C=cvCreateMat(2,2,CV_32FC1);
    CvMat *ResultMatrix=cvCreateMat(2,2,CV_32FC1);

    cvSetData(A,array1,A->step);
    cvSetData(B,array2,B->step);
    cvSetData(C,array3,C->step);

    printf("cvMatMulAdd():\n");
    cvGEMM(A, B, 1., C, 1., ResultMatrix, 0 );   --->>run error!
  //    cvMatMulAdd(A,B,C,ResultMatrix);
    PrintMatrix(ResultMatrix,2,2,1);

    system("pause");
}

:( I'm using win7 + codeblock 10.05 + of 0.71...

Contributor

ofZach commented Jul 1, 2012

can you download the 0071 CB zip that's in the download section and try compiling / running this example again.

We had to swap opencv libs (after we put 0071 up) because of some issues that are similar and I think maybe this problem got fixed in a newer zip. (it's also fixed in the develop branch of github).

yty commented Jul 1, 2012

@ofZach
367f29f
#1300

I just used the latest opencv the lib ...

of 7.1 cvGEMM () became normal. But cvmMul cvMatMul will still crash ...

void testApp::setup(){

    float array1[]={3,1,2,0,1,5};
    float array2[]={4,3,1,1,6,0};

    CvMat *A=cvCreateMat(2,3,CV_32FC1);
    CvMat *B=cvCreateMat(3,2,CV_32FC1);
    CvMat *ResultMatrix=cvCreateMat(2,2,CV_32FC1);

    cvSetData(A,array1,A->step);
    cvSetData(B,array2,B->step);

    printf("cvmMul():\n");
    cvmMul(A,B,ResultMatrix);      --->>run error!
    PrintMatrix(ResultMatrix,2,2,1);

    printf("\ncvMatMul():\n");
    cvMatMul(A,B,ResultMatrix);      --->>run error!
    PrintMatrix(ResultMatrix,2,2,1);

    system("pause");
}

void testApp::PrintMatrix(CvMat *Matrix,int Rows,int Cols,int Channels)
{
    for(int i=0;i<Rows;i++)
    {
        for(int j=0;j<Cols;j++)
        {
            for(int k=0;k<Channels;k++)
            {
                printf("%.2f ",cvGet2D(Matrix,i,j).val[k]);
            }
        }
        printf("\n");
    }
}
Contributor

ofTheo commented Jul 6, 2012

@gameoverhack - could you take a look at this?

yty commented Jul 10, 2012

Test ofxcv calibrationExample I found the same problem.

CalibrationExample.exe has stopped working
"A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available."

And only the codeBlock 10.05 has this issue,, Visual studio 2010 is normal.

@ghost ghost assigned gameoverhack Jul 31, 2012

Contributor

ofTheo commented Aug 5, 2012

@gameoverhack any chance you could see if you can reproduce this?

Contributor

ofTheo commented Aug 26, 2012

Can confirm that the updated example produces a crash on CB 10.05.
Same example in VS2010 runs without issue.

Contributor

ofTheo commented Aug 26, 2012

from reading this: http://eigen.tuxfamily.org/dox/TopicWrongStackAlignment.html
it seems its fixed in GCC 4.5 - going to try new cv libs with Mingw GCC 4.6

Contributor

gameoverhack commented Aug 27, 2012

But won't we then have a clash between libs compiled in 4.5? I had that problem when trzing to recompile libcairo...

I've just tried openCV 2.4.2 but still causes the same error...

Contributor

ofTheo commented Aug 27, 2012

yeah - thats what I ran into. can't use 4.5 or 4.6 libs with C::B 10.05 ( 4.4.1 )

At the moment it seems we have one of two potential solutions:

  1. Host a custom C::B installer package which has newer Mingw than 10.05

  2. Find a way to get default ggc to build a lib that doesn't crash.
    Bonus - 3) Drop C::B and focus on VS :)

  3. potentially would be tricky as there are a lot of existing C::B installs out there, but as this is now a pretty narrowly specific issue maybe it could be a good one?

  • Something worth looking into might be what made the previous OpenCV libs we shipped not crash?
    The Mingw compiler hasn't changed between 007 and now - so what in OpenCV changed? Is it that now the old C api is calling the C++ methods?
Contributor

ofTheo commented Aug 27, 2012

ps: I have a good windows setup now, so I am open to trying things out.

Contributor

ofTheo commented Aug 30, 2012

just saw this: http://tech.groups.yahoo.com/group/OpenCV/message/76601
going to try building it with this gcc: http://forums.codeblocks.org/index.php/topic,12160.0.html

update: doesn't work as its a different gcc version.

Contributor

ofTheo commented Aug 30, 2012

Updating the gcc that comes with C::B might be our best bet.
But I think this means rebuilding all the libraries that come with OF.

I think we should push this to 0073 and then do a gcc update then?
As of now this bug is at least not affecting the core OF cv methods.

It sucks, but I don't know if there is a fix other than to change gcc versions ( which is not a quick fix at this stage ).

Anyone curious Read: http://code.opencv.org/issues/1932#note-7
And: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40838 to get an idea of the problem.

Another option is to drop official C::B support all together, maintaing two compilers for one platform that both require separate libs is a lot of work. Anyway that can be another discussion.

Contributor

ofTheo commented Aug 30, 2012

moved to 0073

Owner

bilderbuchi commented Aug 30, 2012

Yeah, dropping C::B should definitely be a separate issue (could you open one?). From an efficiency standpoint, it would be a better idea to drop visual studio - after all, we can keep gcc (which we use on other platforms, too), and drop the VS compiler only VS uses, right? Also, we would keep the IDE which is usable on all three (?) platforms, and drop the one which is bound to one platform. (Oh I can already hear the screams...:P)

Contributor

kylemcdonald commented Aug 30, 2012

dropping vs would mean no access to the ms kinect sdk, dropping c::b would mean no lightweight windows option. i don't think either are options. we just need to admit that windows development is not a priority, and i need to do a better job finding+encouraging windows devs :)

Owner

bilderbuchi commented Nov 14, 2012

I don't have a proper overview, is this bug still occuring, and can we still not do anything except upgrade C::B gcc?

Owner

bilderbuchi commented Jan 12, 2013

now that we are going to move to C::B 12.10 anyway (and its newer gcc), I guess this issue will go away as soon as we can close #1765, right?

Contributor

ofTheo commented Feb 9, 2013

this is fixed with #1865
It ran the code pasted above without crashing.

@ofTheo ofTheo closed this Feb 9, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment