Re: hangs in flockfile() during fread() or fclose()
Re: hangs in flockfile() during fread() or fclose()
- Subject: Re: hangs in flockfile() during fread() or fclose()
- From: comex <email@hidden>
- Date: Thu, 10 Jul 2014 12:02:25 -0400
On Thu, Jul 10, 2014 at 10:30 AM, Paul Smith <email@hidden> wrote:
> Am I understanding the code correctly, or did I miss something? Should
> I file a bug? If so where's the best place?
Looks like a bug to me. Here is a test case - compiled with clang and
run with MallocScribble=1 (not sure if necessary), it eventually
hangs.
You can file bugs at https://bugreport.apple.com.
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
#include <assert.h>
#include <stdlib.h>
#include <sys/resource.h>
volatile int ready;
static void *thread(void *_) {
ready = 1;
while(1)
fflush(NULL);
}
int main() {
assert(!setrlimit(RLIMIT_NOFILE, (struct rlimit[]) {{9000, 9000}}));
pthread_t pt;
pthread_create(&pt, NULL, thread, NULL);
while(!ready)
;
FILE *fp[8000];
for(int i = 0; i < 8000; i++) {
fp[i] = fopen("/usr/share/dict/words", "r");
assert(fp[i]);
}
for(int i = 0; i < 8000; i++)
fclose(fp[i]);
printf("ok\n");
// try again (in a new process to reset libc structures)
assert(!execl("./fopendl", "./fopendl", NULL));
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden