Segmentation Fault Using Threads


 
Thread Tools Search this Thread
Top Forums Programming Segmentation Fault Using Threads
# 1  
Old 08-02-2003
Lightbulb Segmentation Fault Using Threads

I´m implementing a boss/workers thread system, wich interfaces with TCL clients via socket. The client semms to be ok, but in the server some of the functions raises a segmentation fault. I´ve tried everything i could but i´m just a beginner on threads. Can be a memory allocation problem? or what?
Any help will be wellcomed.
Thanks in advance.
Sebastian.

Please Find Attached the project files. Smilie
# 2  
Old 08-04-2003
All anyone can tell you is that you have an error somewhere in your code. It is possible that you accidently sent yourself that signal. If it came from the kernel, then you attempted to use a memory address in an invalid way.

A reasonable guess might be that you dereferenced a pointer with a screwy value in it. This could be an error related to your use of malloc. But almost any facility can be used incorrectly to cause a segmentation violation.

If you have no other way of finding this, put statements like:
fprintf(stderr, "Got to point 1 \n");
at various places in your code. You should then be able to move them around until you have a single statement surrounded by fprintf's...and you see the output from the first, then the program bombs, and the second is never executed. At that point you know which statement is causing the error.
# 3  
Old 08-04-2003
The problem may be due to not using thread safe programming methods. Not all libraries are thread safe. For example, libraries (such as GTK+) are not set to thread safe mode by default and must be initialized as thread safe.

On the other hand - Segmentation faults are usually caused by attempting to write to memory that shouldn't be written to (i.e. a buffer overflow) so make sure you are not accidently freeing memory in one thread while attempting to write to that same memory via another thread.
# 4  
Old 08-04-2003
MySQL Problem Seems to be Solved

Thanks a lot.
Indeed was a pointer value.
What we did was to initialize every pointer, and now it seems to be ok.

Do you know if the pthread lib is thread safe?

Now we have to implement mutual exclusion on some .txt files.

Shall we use mutexes?
Can you give us any tip or suggestion on that?

Thanks again. Smilie

I send you the updated files.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

C. To segmentation fault or not to segmentation fault, that is the question.

Oddities with gcc, 2.95.3 for the AMIGA and 4.2.1 for MY current OSX 10.14.1... I am creating a basic calculator for the AMIGA ADE *NIX emulator in C as it does not have one. Below are two very condensed snippets of which I have added the results inside the each code section. IMPORTANT!... (11 Replies)
Discussion started by: wisecracker
11 Replies

2. Programming

Using gdb, ignore beginning segmentation fault until reproduce environment segmentation fault

I use a binary name (ie polo) it gets some parameter , so for debugging normally i do this : i wrote script for watchdog my app (polo) and check every second if it's not running then start it , the problem is , if my app , remain in state of segmentation fault for a while (ie 15 ... (6 Replies)
Discussion started by: pooyair
6 Replies

3. UNIX for Dummies Questions & Answers

Segmentation fault

#include<stdio.h> #include<malloc.h> #include<unistd.h> #include<stdlib.h> void *start_1(void *argv) { printf("thread 0x%x\n",(unsigned int)pthread_self()); pthread_exit((void*)1); } void *start_2(void *argv) { printf("thread 0x%x\n",(unsigned int)pthread_self()); return (void*)2; }... (2 Replies)
Discussion started by: vincent__tse
2 Replies

4. UNIX for Advanced & Expert Users

segmentation fault with ps

What does this mean and why is this happening? $ ps -ef | grep ocular Segmentation fault (core dumped) $ ps -ef | grep ocular Segmentation fault (core dumped) $ ps aux | grep ocular Segmentation fault (core dumped) $ ps Segmentation fault (core dumped) $ pkill okular $ ps... (1 Reply)
Discussion started by: cokedude
1 Replies

5. Programming

segmentation fault

What is segmentation fault(core dumped) (1 Reply)
Discussion started by: gokult
1 Replies

6. Programming

segmentation fault

Hi, I am having this segmentation fault not in the following program, bt. in my lab program . My lab program is horrible long so cannot post it here bt. I am using the following logic in my program which is giving the segmentation fault. Bt. if I run this sample program as it is it dosen't give... (3 Replies)
Discussion started by: mind@work
3 Replies

7. Linux

Segmentation fault

Hi, on a linux Red HAT(with Oracle DB 9.2.0.7) I have following error : RMAN> delete obsolete; RMAN retention policy will be applied to the command RMAN retention policy is set to redundancy 2 using channel ORA_DISK_1 Segmentation fault What does it mean ? And the solution ? Many thanks. (0 Replies)
Discussion started by: big123456
0 Replies

8. AIX

Segmentation fault

Hi , During execution a backup binary i get following error "Program error 11 (Segmentation fault), saving core file in '/usr/datatools" Riyaz (2 Replies)
Discussion started by: rshaikh
2 Replies

9. Programming

segmentation fault

ive written my code in C for implementation of a simple lexical analyser using singly linked list hence am making use of dynamic allocation,but when run in linux it gives a segmentation fault is it cause of the malloc function that ive made use of????any suggestions as to what i could do??? thank... (8 Replies)
Discussion started by: rockgal
8 Replies

10. Programming

segmentation fault

sometimes for this code i get a segmentation fault for codes llike this : int main{ int * a= 0; int b; a = (int*)malloc(sizeof(int)); ///some code using these variable but no freeing of a if(a){ free(a); a = 0; } return... (3 Replies)
Discussion started by: wojtyla
3 Replies
Login or Register to Ask a Question