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]

Re: problem in aio_notify.c in glibc 2.1.92?


On Tue, 15 Aug 2000, Kevin B. Hendricks wrote:

> Date: Tue, 15 Aug 2000 01:26:02 -0400
> From: Kevin B. Hendricks <khendricks@ivey.uwo.ca>
> To: libc-alpha@sourceware.cygnus.com
> Subject: problem in aio_notify.c in glibc 2.1.92? 
> 
> Hi,
> 
> I have tracked down the segfaults in make check in rt/tst-aio5.c in glibc
> 2.1.92 under ppc linux to the sival_ptr having a bad value.
> 
> The callback sival_ptr is passed in rt/aio_notify.c to pthread_create.
> 
> However, I can not find any code in the kernel or glibc that actually sets
> call back sival_ptr anyplace (perhaps ppc is missing some code?).
> 
> This results in a segfault in tst_aio5.c
> 
> Should tst_aio5.c have set the proper value for sival_ptr when it sets up
> the callback block?  Is the bug in tst_aio5.c?

The tst-aio5 program writes to sigev_value.sival_int which is a union
member that overlaps with sival_ptr.  It stores the value MY_SIVAL
there and the callback expects it to be played back. Is
this what is failing?

> Where should the sival_ptr in the callback block be set.  It has to be
> someplace since aio_notify.c uses it.

The sival pointer is just arbitrary context data played back to the
application. It is not used for anything.  It appears that the aio code bends
the type system a little bit; what is stored in the event structure is actually
a union that combines a pointer or integer. The code in aio seems to be passing
the whole union as a void * value, relying on the calling conventions to
make it work, and relying on the pointer member of the union to transparently
record the int value if needed. 

Note that the target callback receives a parameter of type sigval_t, which is a
union, and returns void.  Whereas a proper thread function used by pthread
create has type void *(void *).

The motivation for the trick is understandable, since it eliminates the need
for a bounce function to be passed to pthread create which would process the
argument.  Maybe the type system abuse is not working on the PPC target of the
compiler version you are using?


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