This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

AIO: Core Dump in handle_fildes_io


Hi All, Please find below a testcase which upon running dumps core at handle_fildes_io() in aio_misc.c. The consistency of reproducing this problem is around 1 in 5 times of running. The output of GDB is also pasted below.

Please note that in the given testcase , if i un-comment the line which invokes aio_suspend(), then the coredump does not occur.

Please let me know as to what might have gone wrong. Kindly Cc me.

Regards,
Bourne.

/* Start of Test Case */
#include <stdio.h>
#include <fcntl.h>
#include <pthread.h>
#include <aio.h>

int flag;
void foo(void* a)
{
int fd;
struct aiocb mycb;
struct aiocb* list[1];
char ch = 'R';
char buf[10];
struct timespec timeout;
timeout.tv_sec = 2;
timeout.tv_nsec = 0;
puts("thread");
fd = open("cli",O_RDWR);
if(fd == -1)
perror("Open:"),exit(1);

/* Fill up the Structure*/
memset(&mycb,0,sizeof(mycb));
mycb.aio_fildes = fd;
mycb.aio_offset=0;
mycb.aio_buf=buf;
mycb.aio_nbytes = 1;
mycb.aio_reqprio = 0;
mycb.aio_sigevent.sigev_notify = SIGEV_NONE;
mycb.aio_sigevent.sigev_signo = 0;
mycb.aio_sigevent.sigev_value.sival_ptr = 0;
/* Done */
aio_read(&mycb);
list[0] = &mycb;
/* Uncomment below line to avoid core dump */
//aio_suspend(list,1,&timeout);
puts("thread over");
putchar(buf[0]);
flag = 12;
}
int main()
{
pthread_t tid;
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
pthread_create(&tid,&attr,foo,NULL);
while(flag != 12){}
puts("Main exiting");
}
/* End of Testcase */

---------------GDB OUTPUT----------------
GNU gdb Red Hat Linux (5.1.90CVS-5)
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux"...
Core was generated by `./aioread'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /lib/i686/libpthread.so.0...done.
Loaded symbols for /lib/i686/libpthread.so.0
Reading symbols from /lib/librt.so.1...done.
Loaded symbols for /lib/librt.so.1
Reading symbols from /lib/i686/libc.so.6...done.
Loaded symbols for /lib/i686/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
#0 0x4003f261 in handle_fildes_io () from /lib/librt.so.1
(gdb) where
#0 0x4003f261 in handle_fildes_io () from /lib/librt.so.1
#1 0x4002dfef in pthread_start_thread () from /lib/i686/libpthread.so.0
(gdb)
----------------------END OF GDB OUTPUT----------------------




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]