Skip to content Skip to sidebar Skip to footer

Python Libsvm Core Dump

I have Python code that works fine on my development environment (Ubuntu 12.04) but dumps core on my production environment (a Linode running CentOS). *** glibc detected *** python

Solution 1:

The cause of the error is an uninitialized pointer in svm_load_model, and an unchecked call to free. Here's a patch:

misha@misha-diginnos:~$ diff libsvm-3.16/svm.cpp.original libsvm-3.16/svm.cpp -p
*** libsvm-3.16/svm.cpp.original        2013-03-17 17:34:00.235661297 +0900--- libsvm-3.16/svm.cpp 2013-03-17 17:39:29.677294903 +0900
*************** svm_model *svm_load_model(const char *mo
*** 2747,2752 ****--- 2747,2753 ----
        model->probB = NULL;
        model->label = NULL;
        model->nSV = NULL;
+     model->sv_indices = NULL;

        char cmd[81];
        while(1)
*************** void svm_free_model_content(svm_model* m
*** 2973,2980 ****
        free(model_ptr->probB);
        model_ptr->probB= NULL;

!       free(model_ptr->sv_indices);!       model_ptr->sv_indices = NULL;

        free(model_ptr->nSV);
        model_ptr->nSV = NULL;
--- 2974,2984 ----
        free(model_ptr->probB);
        model_ptr->probB= NULL;

!     if (model_ptr->sv_indices)!     {!         free(model_ptr->sv_indices);!         model_ptr->sv_indices = NULL;!     }

        free(model_ptr->nSV);
        model_ptr->nSV = NULL;

I've notified the authors. They're aware of the problem and will address it in the next version.

Post a Comment for "Python Libsvm Core Dump"