Ask Your Question

[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;
    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


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

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:

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

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{, cv::FileStorage::READ);
}catch(cv::Exception ex)
    return 1;
edit flag offensive delete link more

Question Tools

1 follower


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

Seen: 535 times

Last updated: Feb 05 '20