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

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


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

[PATCH] Fix tst-chk{2,3}.c


Hi!

On some arches (namely ia64 and s390 (31-bit)) tst-chk{2,3} fails with exit
code 1, although it prints no failure messages.
The problem is that ret is a local variable whose address is not taken
and GCC when seeing say __memcpy_chk (....); ret = 1; reorders ret setting
before the __memcpy_chk call (but __memcpy_chk is not supposed to return,
but __chk_fail()ed).
Fix below (plus I have removed redundant ret = 1; setting in CHK_FAIL_END
- FAIL () macro already sets ret = 1).

2004-11-02  Jakub Jelinek  <jakub@redhat.com>

	* debug/tst-chk1.c (ret): New volatile variable.
	(CHK_FAIL_END): Remove redundant ret setting.
	(do_test): Remote ret variable.

--- libc/debug/tst-chk1.c.jj	2004-11-02 22:21:48.000000000 +0100
+++ libc/debug/tst-chk1.c	2004-11-02 22:22:17.037902927 +0100
@@ -50,7 +50,7 @@ do_prepare (void)
     }
 }
 
-volatile int chk_fail_ok;
+volatile int chk_fail_ok, ret;
 jmp_buf chk_fail_buf;
 
 static void
@@ -86,7 +86,6 @@ int num2 = 987654;
 #define CHK_FAIL_END \
       chk_fail_ok = 0;				\
       FAIL ();					\
-      ret = 1;					\
     }
 #if __USE_FORTIFY_LEVEL >= 2
 #define CHK_FAIL2_START CHK_FAIL_START
@@ -99,7 +98,6 @@ int num2 = 987654;
 static int
 do_test (void)
 {
-  int ret = 0;
   struct sigaction sa;
   sa.sa_handler = handler;
   sa.sa_flags = 0;

	Jakub


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