This is the mail archive of the glibc-bugs@sourceware.org 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]

[Bug libc/2414] New: bug in stdlib/tst-setcontext.c


Hi, 

there is a bug in testsuite, in testing of makecontext().
Prototype is  void makecontext(ucontext_t *ucp, void (*func)(),  int argc, ...);
As func() in testing is used function
static void f1 (long a0, long a1, long a2, long a3)

The actual call is 
 makecontext (&ctx[1], (void (*) (void)) f1, 4, 1, 2, 3, -4);

This is wrong, because standard C convention for parameter expanding are used,
i.e. all numbers are passed as ints not as longs.

Please fix it by either:

A) change prototype of f1() to use int
-------------------------------------------------

--- tst-setcontext.c    2006-03-02 22:37:00.000000000 +0100
+++ tst-setcontext.c     2006-03-02 22:14:41.000000000 +0100
@@ -30,7 +30,7 @@
 static char st2[32768];
 
 static void
-f1 (long a0, long a1, long a2, long a3)
+f1 (int a0, int a1, int a2, int a3)
 {
   printf ("start f1(a0=%lx,a1=%lx,a2=%lx,a3=%lx)\n", a0, a1, a2, a3);
 

B) pass long when calling makecontext
----------------------------------------------------

--- tst-setcontext.c    2006-03-02 22:37:00.000000000 +0100
+++ tst-setcontext.c     2006-03-02 22:15:13.000000000 +0100
@@ -158,7 +158,7 @@
   ctx[1].uc_link = &ctx[0];
   {
     ucontext_t tempctx = ctx[1];
-    makecontext (&ctx[1], (void (*) (void)) f1, 4, 1, 2, 3, -4);
+    makecontext (&ctx[1], (void (*) (void)) f1, 4, 1L, 2L, 3L, -4L);
 
     /* Without this check, a stub makecontext can make us spin forever.  */
     if (memcmp (&tempctx, &ctx[1], sizeof ctx[1]) == 0)

C) properly extend the test
-----------------------------------
test can be easily changed to test passing arguments of type int, long and pointer 

Option A) conform to current standard, it  requires only arguments of type int
to work,
from http://www.opengroup.org/onlinepubs/009695399/functions/makecontext.html
"The application shall ensure that the value of argc matches the number of
arguments of type int passed to func; otherwise, the behavior is undefined."

Option C) would test makecontext() against all reasonable passed argument types
Clarification of "int only" have beed added to IEEE Std 1003.1 in Issue 6,
previously there was no such restriction.

Petr

-- 
           Summary: bug in stdlib/tst-setcontext.c
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: Petr dot Salinger at seznam dot cz
                CC: glibc-bugs at sources dot redhat dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=2414

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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