X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Message-ID: <4FC9391B.3040104@etr-usa.com> Date: Fri, 01 Jun 2012 15:50:19 -0600 From: Warren Young User-Agent: Mozilla/5.0 (Windows NT 6.0; WOW64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: Cygwin-L Subject: Re: How to "bisect" Cygwin? References: <20120531210143 DOT GA11744 AT localhost DOT localdomain> <20120601174610 DOT GD25227 AT localhost DOT localdomain> <20120601181852 DOT GF28506 AT calimero DOT vinschen DOT de> <20120601184041 DOT GE25227 AT localhost DOT localdomain> <20120601185906 DOT GG28506 AT calimero DOT vinschen DOT de> <20120601195107 DOT GF25227 AT localhost DOT localdomain> In-Reply-To: <20120601195107.GF25227@localhost.localdomain> Content-Type: multipart/mixed; boundary="------------060800020005040508010307" X-IsSubscribed: yes 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 --------------060800020005040508010307 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 6/1/2012 1:51 PM, Ryan C. Underwood wrote: > On Fri, Jun 01, 2012 at 08:59:06PM +0200, Corinna Vinschen wrote: > >> If you can press a long story into a short testcase in plain C with the >> bare minimum of code to reproduce the behaviour, it would be much >> appreciated. > > The basic issue is that sem_wait() is being kicked out with EINTR > extremely frequently (9 out of 10 times or more), Does the attached program vaguely resemble what your program is trying to do? It does get EINTR, but only because I'm using alarm(2) to add a timeout to the sem_wait() call. You should just get an infinite series of "Child timed out normally waiting for the semaphore." messages from it after initialization, one per second. --------------060800020005040508010307 Content-Type: text/plain; charset=windows-1252; name="semtest.c" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="semtest.c" #include #include #include #include #include #include #include static int timed_out = 0; void timeout(int sig) { timed_out = 1; } int main() { static const char* sem_name = "/myhappysemaphore"; sem_t* ps = sem_open(sem_name, O_RDWR); if (ps) sem_close(ps); // clean up old semaphore; we probably crashed ps = sem_open(sem_name, O_CREAT, 0600, 0); if (ps == SEM_FAILED) { perror("sem_open"); return 1; } puts("Created semamphore."); pid_t pid = fork(); switch (pid) { case -1: // error perror("fork"); return 2; case 0: // child signal(SIGALRM, timeout); while (1) { alarm(1); int ret = sem_wait(ps); if (ret == -1) { if (timed_out) { if (errno == EINTR) { puts("Child timed out normally waiting " "for the semaphore."); timed_out = 0; } else { puts("Child timed out ABNORMALLY waiting " "for the semaphore!"); exit(99); } } else { perror("sem_wait"); exit(69); } } else { puts("Child got the semaphore! " "How the spit did that happen?"); exit(42); } } break; default: { // parent puts("Created child. Posting the deathwatch."); int status; while (1) { pid_t ret = waitpid(pid, &status, 0); if (ret > 0) { if (WIFEXITED(status)) { printf("Child %d died peacefully, code %d.\n", ret, WEXITSTATUS(status)); break; } else { printf("Child %d died screaming, status 0x%08X.\n", ret, status); return 3; } } else { perror("waitpid"); return 4; } } } } return 0; } --------------060800020005040508010307 Content-Type: text/plain; charset=us-ascii -- 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 --------------060800020005040508010307--