For a while now, the test cases that come with libapr1 have been bombing with this message:
*** fatal error - NtCreateEvent(lock): 0xC0000035 I finally took some time to investigate and have extracted a STC that demonstrates the problem. It's been a decade since I did any C programming, so I'm not really sure that the STC is valid. However, it does work on my Debian box. (I know that doesn't really mean anything, but it's the best I can do.) I've tried this on my Win7-64 box running the 20110822 snapshot and on a WinXP VM running 1.7.9. I get the same results in both places. Regards, David -- David Rothenberger ---- daver...@acm.org The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet. -- Michael Jackson
/*********************************************************************** * This is a STC that causes the following error on my test machine: * NtCreateEvent(lock): 0xC0000035 * * It tries to use flock() for file locking. It creates a temporary * file, the uses fork to spawn a number of children. Each child opens * the file, then repeatedly uses flock to lock and unlock it. * * This test was extracted from the APR test suite. * * Compile: gcc -Wall -o stc-flock-fork stc-flock-fork.c ***********************************************************************/ #include <sys/types.h> #include <sys/file.h> #include <sys/wait.h> #include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <unistd.h> #include <errno.h> #define MAX_ITER 2000 #define CHILDREN 6 /* A temporary file used for flock. */ char tmpfilename[] = "/tmp/flocktstXXXXXX"; /* Fork and use flock to lock and unlock the file repeatedly in the child. */ void make_child(int trylock, pid_t *pid) { if ((*pid = fork()) < 0) { perror("fork failed"); exit(1); } else if (*pid == 0) { int fd2 = open(tmpfilename, O_RDONLY); if (fd2 < 0) { perror("child open"); exit(1); } int rc; int i; for (i=0; i<MAX_ITER; ++i) { do { rc = flock(fd2, LOCK_EX); } while (rc < 0 && errno == EINTR); if (rc < 0) { perror("lock"); exit(1); } do { rc = flock(fd2, LOCK_UN); } while (rc < 0 && errno == EINTR); if (rc < 0) { perror("unlock"); exit(1); } } exit(0); } } /* Wait for the child to finish. */ void await_child(pid_t pid) { pid_t pstatus; int exit_int; do { pstatus = waitpid(pid, &exit_int, WUNTRACED); } while (pstatus < 0 && errno == EINTR); } int main(int argc, const char * const * argv, const char * const *env) { pid_t child[CHILDREN]; int n; int fd; /* Create the temporary file. */ fd = mkstemp(tmpfilename); if (fd < 0) { perror("open failed"); exit(1); } close(fd); /* Create the children. */ for (n = 0; n < CHILDREN; n++) make_child(0, &child[n]); /* Wait for them to finish. */ for (n = 0; n < CHILDREN; n++) await_child(child[n]); /* Clean up. */ unlink(tmpfilename); return 0; }
-- 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