funkadelic
funkadelic

Reputation: 321

Segmentation fault in multithreaded application

I have a Segmentation fault in my multithreaded application that is becoming a headache. It looks like the problem is being generated in a usleep call. I tried to replace it with nanosleep but it persists. It also appears near to a sem_timedwait call.

I compile with gcc and -lpthread option.

Might this be the cause of the segmentation fault? What could be the reason?

Upvotes: 0

Views: 2405

Answers (1)

David Heffernan
David Heffernan

Reputation: 612993

Segmentation fault means that you are accessing memory which you don't have rights to. It is usually due to a bounds error on an array or a stale pointer, e.g. access after free. Calling sleep seems exceedingly unlikely to be related to this unless you are using sleep as a synchronization tool! You could use valgrind to track down your error.

Upvotes: 3

Related Questions