Date: Thu, 12 Jun 2003 18:29:44 +1000 From: Tim Robbins <tjr@FreeBSD.ORG> To: current@freebsd.org Subject: Apparent i386 alloca.S bug (was: adsl/pppoe no longer connecting on 5.1) Message-ID: <20030612182944.A62729@dilbert.robbins.dropbear.id.au>
next in thread | raw e-mail | index | archive | help
Here's a test program for the i386 alloca() bug. Compile with -std=gnu89 (or no -std option) and it works fine. Compile with -std=c99 or -std=c89 and it breaks like this: corruption: 05 should be 0xcc at offset 0 corruption: 00 should be 0xcc at offset 1 corruption: 00 should be 0xcc at offset 2 corruption: 00 should be 0xcc at offset 3 Interestingly, gcc -std=c89 on FreeBSD 4.8 doesn't trigger the bug. #include <assert.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define NUMBYTES 511 static void somefunc(int a, int b, int c, int d, int e) { } int main(int argc, char *argv[]) { char *s; int i; int failed; s = alloca(NUMBYTES); memset(s, 0xcc, NUMBYTES); somefunc(1, 2, 3, 4, 5); failed = 0; for (i = 0; i < NUMBYTES; i++) { if ((unsigned char)s[i] != 0xcc) { printf("corruption: %02x should be 0xcc at offset %d\n", (unsigned char)s[i], i); failed = 1; } } exit(failed); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030612182944.A62729>