I have programed the node.js plug-in(add-on) code, which called c++/OpenCV’s cv::FileStorage to open the XML file.
And it is compiled successfully, but ran an error at cv::FileStorage.open(), prompting a message “Segmentation fault (core dumped)”.
As a side note, all my OpenCV’s functional codes except the cv::FileStorage.open() are compiled and run successfully.
Please tell me the reason for cv::FileStorage.open()'s “Segmentation fault"?
And please tell me a good solution for this error.
My environment:
OS: Ubuntu18.04
OpenCV: version4.5.3
Node.js: version node@14.17.6, node-gyp@8.2.0
@Bonsuke , imo there are 3 cases here, to be checked seperately:
file not found: fs.open() should retur false (and that’s it)
file is there, but no valid filestorage object inside: should throw an exception
file is valid: fs.open() returns true
and unfortunately, i cant reproduce the segfault (4.5.5;win10 4.4.0;ubu18)
are you able to debug it, and maybe get a backtrace ?
also, slightly improved testcode:
Thank you for your suggestion.
I have tried these. As a result,
1.
In the cas of with wrong file name(namely file not exists), program process has reached to “puts(ok?“ok”:“fail”);” with response “fail”.
But not reached to “catch(cv::Exception ex)”.
2.
In the case of with correct file name(namely file exists), program process has reached to “puts(“Doing fs.open() at try{}.”);”
and has failed at fs.open(). That is, never reach to “puts(ok?“ok”:“fail”);” and also never to “catch(cv::Exception ex)”.
By the way, a certain Post(*1) pointed out the version differences of Node.js about these “cv::FileStorage Segmentation fault”.
That is, running in node V12.18.2 is ok, but has an error in node V14.19.0.
So I have upgraded Node.js version to Node.js v16.15.1(LTS), But as usual I have error “Segmentation fault”.