Ask Your Question
1

[4.2.0] FileStorage crash on getNodePtr() (Segmentation Fault)

asked 2020-02-05 04:53:23 -0500

jstefanelli gravatar image

Hi! I'm having a big issue with the FileStorage API with this YML file (pastebin). Basically, any time I try to access information on any FileNode, the program segfaults.

At first, I though it was due to my custom OpenCV build on macOS, but after trying with the pre-built OpenCV 4.2.0 Windows binaries, the problem persists.

Messing around in LLDB i figured that the crash happens in cv::FileStorage::Impl::getNodePtr(unsigned long, unsigned long)

The relevant code segment is:

cv::FileStorage fs;
try{
    fs = cv::FileStorage(filePath, cv::FileStorage::READ);
}catch(cv::Exception ex)
{
    return 1;
}

cv::FileNode node = fs.root();

std::cout << "Got root node" << std::endl;
std::cout << "Root node is type: " << node.type() << std::endl; //Crash here

I'm really at a loss... any help is appreciated.

edit retag flag offensive close merge delete

Comments

really weird, problem goes away, if you write it as:

cv::FileStorage fs = cv::FileStorage(filePath, cv::FileStorage::READ);
berak gravatar imageberak ( 2020-02-06 04:04:00 -0500 )edit
1

Holy * you're right! Any idea why that is?

jstefanelli gravatar imagejstefanelli ( 2020-02-06 04:14:10 -0500 )edit

still digging ;)

if we don't find out: https://github.com/opencv/opencv/issu...

hmm, no copy ctor or assignment operator for cv::FileStorage

berak gravatar imageberak ( 2020-02-06 04:24:52 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2020-02-06 04:37:01 -0500

jstefanelli gravatar image

Thanks for the help! Right now i fixed it like this:

cv::FileStorage fs;
try{
    fs.open(filePath, cv::FileStorage::READ);
}catch(cv::Exception ex)
{
    return 1;
}
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2020-02-05 04:53:23 -0500

Seen: 93 times

Last updated: Feb 05