Skip to content

Commit

Permalink
Lock the mex file to avoid Matlab crashes.
Browse files Browse the repository at this point in the history
Commands like "clear all" and "clear function" causes segmentation faults or errors like these (especially after an 'init'):
 libprotobuf ERROR google/protobuf/descriptor_database.cc:57] File already exists in database: caffe/proto/caffe.proto
 libprotobuf FATAL google/protobuf/descriptor.cc:862] CHECK failed: generated_database_->Add(encoded_file_descriptor, size):
 [libprotobuf ERROR google/protobuf/message.cc:333] Type appears to be in generated pool but wasn't registered: caffe.LayerParameter
 Attempt to restart MATLAB?
To avoid these, lock the the mex file.
  • Loading branch information
gcinbis committed Aug 20, 2014
1 parent 78eea24 commit 1b5ef74
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions matlab/caffe/matcaffe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ static handler_registry handlers[] = {
** matlab entry point: caffe(api_command, arg1, arg2, ...)
**/
void mexFunction(MEX_ARGS) {
mexLock(); // Avoid clearing the mex file.
if (nrhs == 0) {
LOG(ERROR) << "No API command given";
mexErrMsgTxt("An API command is requires");
Expand Down

0 comments on commit 1b5ef74

Please sign in to comment.