Danny_501 2 Junior Poster

Hi all,

I'm making a miltithreaded program that uses the pthreads library. One of the threads monitors the users input. my problem is when I enter a close command I get the following error:
9 [sig]...: *** fatal error - called with threadlist_ix -1
make: *** [run] Hangup

I know it only happens when I free some memory I have allocated at the start of the program.
Here is the problem code:

//lock to protect buffer
			pthread_mutex_lock(&mutex);
			//free memory
			for(int i = 0; i < ST_SIZE; ++i) {
				free(st.buffer[i]);
			}
			//unlock
			pthread_mutex_unlock(&mutex);

Any hints?
thanks.