X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:in-reply-to:message-id :references:mime-version:content-type; q=dns; s=default; b=JoPhs hDRUjVNw1fzi4bdLaSQ9B/TiVm1P9Ave/euLkTf71VPmYWjIOVVTj8nQjpDUJQ3W /u4meimtbYxAFACefWbvBZFXQMaUNP1gVZ5VS19D4f99iImuOQaK6hgBqvxqUiJQ oSXiU/QRCkcrPg1NW8Uyod6rqJ24MsixUWT354= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:in-reply-to:message-id :references:mime-version:content-type; s=default; bh=4motQGKP/j1 EqlP7Tc0iK1wIyx4=; b=mdjP3InCpUrHtU+pV/Gb1ppPhd/2pceiv/2yMVEVUQF 4TLNbVGbszuY+/KZdYfqxNb3dLgxyO7Xun7TKVYUxezNWBD1LdKn0HkIKD7nFuvc D+426Ux1apboALH8gN5bH9t7WYLU5tU66boH6niop5N77JZDH5GelDEbNA3ZAzfk = Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: artax.karlin.mff.cuni.cz Date: Wed, 19 Nov 2014 18:28:47 +0100 (CET) From: Mikulas Patocka To: cygwin AT cygwin DOT com Subject: Re: Instability with signals and threads In-Reply-To: Message-ID: References: User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) X-Personality-Disorder: Schizoid MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Wed, 19 Nov 2014, Mikulas Patocka wrote: > Hi > > I have a program that sets a repetitive timer with setitimer and spawns > several threads. > > The program is very unstable on cygwin, it locks up in few minutes. This is a simplified example that triggers the lockup very quicky. When I change remove_tls so that it always acquires the lock, it reduces the probability of the lockup, but doesn't eliminate it entirely - so there must be some other bug. Mikulas #include #include #include #include #include #include static volatile sig_atomic_t events; static void signal_handler(int sig) { events++; } static void *thread_func(void *ptr) { return NULL; } #define N_THREADS 12 static pthread_t threads[N_THREADS]; int main(void) { int i, r; struct sigaction sa; struct itimerval timer; memset(&sa, 0, sizeof sa); sa.sa_handler = signal_handler; sigemptyset(&sa.sa_mask); sa.sa_flags |= SA_RESTART; r = sigaction(SIGALRM, &sa, NULL); if (r) perror("sigaction"), exit(1); timer.it_interval.tv_sec = 0; timer.it_interval.tv_usec = 1000; timer.it_value = timer.it_interval; r = setitimer(ITIMER_REAL, &timer, NULL); if (r) perror("setitimer"), exit(1); while (1) { for (i = 0; i < N_THREADS; i++) { r = pthread_create(&threads[i], NULL, thread_func, NULL); if (r) fprintf(stderr, "pthread_create: %s", strerror(r)); } for (i = 0; i < N_THREADS; i++) { r = pthread_join(threads[i], NULL); if (r) fprintf(stderr, "pthread_create: %s", strerror(r)); } printf("events: %d\n", events); } } -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple