Prevent Matlab on OS X from crashing on error#1406
Conversation
Replace CHECK() and LOG(FATAL) with LOG(ERROR) and mexErrMsgTxt A failed CHECK() or LOG(FATAL) causes Matlab to crash on OS X 10.9 with Matlab 2014a.
|
A disadvantage of decomposing the error messaging into its own function is that you lose information about the source line in the |
|
Look at matcaffe2 #501 for a possible solution. Sergio 2014-11-05 17:56 GMT-08:00 Daniel Golden notifications@github.com:
|
|
@sguada, thanks for the tip. Help me understand your preprocessor macros a little more. For example, in this one, does the error message have to be a string literal? #define CHECK_EQ_3(a, b, m) do { \
if ( (a) != (b) ) { \
fprintf(stderr, "%s:%d: Check failed because %s != %s\n", \
__FILE__, __LINE__, #a, #b); \
fprintf(stderr, "%s:%d: %s\n", \
__FILE__, __LINE__, #m); \
mexErrMsgTxt(#m); \
} \
} while (0);Is there a way to adapt that to accept a stream like how glog's |
|
Yeah I think needs to be a string. But I guess you could build the string Sergio 2014-11-05 21:21 GMT-08:00 Daniel Golden notifications@github.com:
|
|
But I think So if I say: std::string msg_var = "The error message";
CHECK_EQ_3(0, 1, msg_var) ;this would return an error of I'll ponder this a little more, but my inclination is to suggest not doing much more work on this PR and merging as-is, since it's already better than the status quo and it will (hopefully) soon be replaced by #501 anyway. |
|
Merging to stop the unreasonable crashes as a similar choice was made for common errors in pycaffe. Of course, matcaffe 2 #501 will improve many aspects of the MATLAB wrapper. @sguada any chance to look at the last changes from review and finish it up? @drdan14 there's nothing specific to OS X here, no? |
Prevent Matlab on OS X from crashing on error
|
I'm sure I've tested it on OS X, and I think I also tested it on Ubuntu 14.04, but I don't remember. The code should all be system independent. |
On my system, when using Matcaffe, if I encounter an error in the matcaffe mex file, Matlab crashes. This is ridiculous, and I figured out that the problem is in the
LOG(FATAL)andCHECK()macros. WhenLOG(FATAL)is hit or aCHECK()fails, this crashes Matlab. My fix is to replace all instances ofLOG(FATAL)andCHECK()with an inline function that callsLOG(ERROR)andmexErrMsgTxt. This returns control to Matlab with a proper error message instead of crashing.My system: