Home > pthread join bus > pthread_join bus error

Pthread_join Bus Error

here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Debian pthread_join bus error up vote 0 down vote favorite I am sitting on a Beaglebone Black and having problem with pthread_join, which gives me Bus error. See the following code below. This is taken directly from a Youtube-tutorial on pthreads. #include #include #include void *myfunc (void *myvar); int main(int argc, char* argv[]) { pthread_t thread1, thread2; char *msg1 = "First thread"; char *msg2 = "Second thread"; int ret1, ret2; ret1 = pthread_create(&thread1, NULL, myfunc, (void *) msg1); ret2 = pthread_create(&thread1, NULL, myfunc, (void *) msg2); printf("Main function after pthread_create\n"); pthread_join(thread1, NULL); pthread_join(thread2, NULL); // Bus error on the above pthread_join printf("Here is OK\n"); printf("First thread ret1 = %d\n", ret1); printf("Second thread ret2 = %d\n", ret2); return 0; } void *myfunc (void *myvar) { char *msg; msg = (char *) myvar; int i; for(i=0; i < 10; i++) { printf("%s %d\n", msg, i); sleep(1); } return NULL; } This code works perfectly on my PC running Ubuntu 14.04, although Valgrind shows some "possibly lost" bytes on the pthread_join command. Hence the code is not the problem - I figure it must be something on the Debian running on Beaglebone that's causing it. And yes, I do include the -lpthread library. The output I get on the Beaglebone is: Main function after pthread_create Second thread 0 First thread 0 Second thread 1 First thread 1 Second thread 2 First thread 2 Second th

here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up pthread bus error up vote 2 down vote favorite I'm http://stackoverflow.com/questions/35993054/debian-pthread-join-bus-error/36001571 doing an exercise. The goal is to make a program in C to crack DES encrypted password. Right now I have the following flow of execution: Load dictionary. Dictionary search. Brute force search of the first 4 characters. Dictionary search combined with brute force (searching for combinations). Only dictionary words of 7-6 characters. Brute force search of the first 5 characters. Dictionary search combined with brute force (searching http://stackoverflow.com/questions/8551267/pthread-bus-error for combinations). Only dictionary words of 5-4 characters. Brute force search of up to 8 characters. The program works fine, but I want to improve it by using multiple threads: 1st thread - main 2nd thread - dictionary and dictionary combined with brute force search 3rd thread - brute force search I've started by making a basic dictionary search thread function, but it fails with Bus Error (Mac OS X) where it should start reading words from the dictionary file. Same code works fine in the regular non- thread function... Here is the code: #include #include #include #include #define _XOPEN_SOURCE #define MAXLINE 40 #define MAXPASS 9 /* dictionary search thread function */ void * dictionary(void * argv) { /* initializing SALT */ char salt[3]; // defining salt (length is always 2 chars + "\0") strncpy(salt, argv, 2); // copying the first 2 characters from encrypted password to salt salt[2] = '\0'; // placing null character to make salt a string /* defining and initializing password */ char password[14]; strcpy(password, argv); /* defining candidate */ char candidate[MAXPASS]; /* opening file */ FILE *fp; if ((fp = fopen("/usr/share/dict/words", "r")) == NULL) { printf("Error: Can not open file.\n"); return (void

Things Small and Medium Business Service Providers All Solutions Services Advise, Transform and Manage Financing https://community.hpe.com/t5/System-Administration/Bus-error-in-thread-program/m-p/2641145 and Flexible Capacity IT Support Services Education and Training Services All Services Products Integrated Systems Composable Systems Converged Systems Hyper http://www.verycomputer.com/5_cc6de1b0dd8787d4_1.htm Converged Systems Blade Systems Infrastructure Management Software Application Lifecycle Management Application Delivery Management Big Data Analytics DevOps Enterprise Security Hybrid pthread_join bus and Private Cloud Information Governance Information Management IT Service Management Operations Management Server Management Software as a Service (SaaS) Software-Defined Data Center Storage Management All Software Servers Rack Servers Tower Servers Blade Servers Density Optimized Mission Critical Servers Servers for Cloud Server pthread_join bus error Management All Servers Storage All-flash and Hybrid Storage Midrange and Enterprise Storage Entry Storage Systems Data Availability, Protection and Retention Software Defined Storage Management and Orchestration Storage Networking All Storage Networking Switches Routers Access Points and Controllers Wireless LAN Campus and Branch Networking Data Center Networking Wide Area Network Software Defined Networking Network Functions Virtualization Network Management All Networking About UsSupportClearType to search2086159Solutions Transform to a Hybrid Infrastructure Protect Your Digital Enterprise Empower the Data-Driven Organization Enable Workplace Productivity Cloud Security Big Data Mobility Infrastructure Internet of Things Small and Medium Business Service Providers All Solutions Services Advise, Transform and Manage Financing and Flexible Capacity IT Support Services Education and Training Services All Services Products Integrated Systems Composable Systems Converged Systems Hyper Converg

All is fine until it can't even pass the first pthread_join() and crashes with bus error. I'm testing with this simple program (from http://www.llnl.gov/computing/tutorials/workshops/workshop/pthreads/s... join1.c), and it crashes and dies all the same (right on the "rc = pthread_join(thread[t], (void **)&status);" statement). Unfortunately gdb is ill-configured on the machine I'm working on. Would anyone have any idea how I can find out why it's not working? This program works fine on Linux and Solaris alike. Many thanks. Tina #include #include #define NUM_THREADS 3 void *BusyWork(void *null) { int i; double result=0.0; for (i=0; i<1000000; i++) { result = result + (double)random(); } printf("Thread result = %e\n",result); pthread_exit((void *) 0); Quote:} int main(int argc, char *argv[]) { pthread_t thread[NUM_THREADS]; pthread_attr_t attr; int rc, t, status; /* Initialize and set thread detached attribute */ pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); for(t=0;t I'm writing a multi-threaded program using pthread on an IRIX 6.5 machine. > All is fine until it can't even pass the first pthread_join() and crashes > with bus error. [...] > int rc, t, status; > [...] > // *********BUS ERROR HERE************ // > rc = pthread_join(thread[t], (void **)&status); This may or may not be the cause of your problem, but it is certainly incorrect. `status' is an `int', but pthread_join() tries to store a `void*' there. It may be that on the machine in question `void*' is wider than an `int' or has stricter alignment requirements -- either way, the results are likely to be unpleasant. "If you lie to the compiler,

 

Related content

No related pages.