You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffde0e73700 (LWP 12246)]
jl_enter_handler (eh=eh@entry=0x7ffde0e72300) at /home/centos/buildbot/slave/package_tarball64/build/src/builtins.c:214
214 /home/centos/buildbot/slave/package_tarball64/build/src/builtins.c: No such file or directory.
Here is the part of C Code which calls Julia
#include "julia.h"
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
int counter = 0;
void do_prediction(){
printf("%d\n",counter);
counter++;
int i = 0;
jl_value_t* mod = (jl_value_t*)jl_eval_string("MyModule");
jl_function_t *func = jl_get_function((jl_module_t*)mod,"custom_compute");
jl_value_t *ret = jl_call2(func, (jl_value_t*)1, (jl_value_t*)2);
if (jl_exception_occurred())
printf("%s \n", jl_typeof_str(jl_exception_occurred()));
// jl_atexit_hook(0);
cout << "Returned Value:" << jl_unbox_float64(ret) << endl;
i++;
}
void* test2(){
do_compute();
sleep(10);
}
void* test1(void* p){
test2();
sleep(10);
}
int main(int argc, char *argv[]){
jl_init(JULIA_INIT_DIR);
jl_load("MyModule.jl");
// test1(argv[1], argv[2]);
int i;
pthread_t p_test[10];
for(i =0 ;i <10; i ++){
/* create a second thread which executes inc_x(&x) */
if(pthread_create(&p_test[i], NULL, test1, NULL)) {
fprintf(stderr, "Error creating thread\n");
return 1;
}
}
for(i =0 ;i <10; i ++){
/* wait for the second thread to finish */
if(pthread_join(p_test[i], NULL)) {
fprintf(stderr, "Error joining thread\n");
return 2;
}
}
return 1;
}
Without multi threading it works fine, but with multi threading it fails!
The text was updated successfully, but these errors were encountered:
ravismula
changed the title
Segmentation fault : jl_load
Segmentation fault : Calling Julia from Multi Threaded C Program
Feb 20, 2017
Getting Segmentation Fault in jl_load function.
Here is the part of C Code which calls Julia
Without multi threading it works fine, but with multi threading it fails!
The text was updated successfully, but these errors were encountered: