public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "1319 at bot dot ru" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug optimization/14863] [3.4/3.5 regression] unit-at-a-time causes miscompilation Date: Sun, 11 Apr 2004 01:06:00 -0000 [thread overview] Message-ID: <20040410221622.17153.qmail@sources.redhat.com> (raw) In-Reply-To: <20040406114325.14863.rguenth@tat.physik.uni-tuebingen.de> ------- Additional Comments From 1319 at bot dot ru 2004-04-10 22:16 ------- I have just figured out that delete() segfaults because new() returned wrong pointer; it can be shown using overloaded operators new() and delete(). This happens because there is a memory corruption somewhere... To figure out where I used custom new() and memprotect(): (put this code before main(), and add #include <sys/mman.h>) void *pool; int last = 1; #define NMAX 0x80 #define NSIZ 0x10000 void* operator new(size_t size) { void *p; if (!pool) { // allocate page aligned NMAX*NSIZ bytes of memory // (assume pagesize = 0x1000) pool = (void *) (0xFFFFF000 & ((long) calloc (1, NMAX*NSIZ) + 0xFFF)); mprotect (pool, NMAX*NSIZ, PROT_NONE); } if (last >= (NMAX-1)) { fprintf (stderr, "out of memory"); abort (); } // (1) guards access below returned pointer //p = (void *) ((long) pool + (last++)*NSIZ); // (2) guards access above returned pointer p = (void *) ((long) pool + (last++)*NSIZ - ((size + 3) & 0xFFFFFFFC)); mprotect ((void *) ((long) p & 0xFFFFF000), size, PROT_READ|PROT_WRITE); // test of (1) //*((char *) p - 1) = 0; /* segfault */ // test of (2) //*((char *) p + size + 3) = 0; /* segfault */ fprintf (stderr, "new: size = %lu, p = %p\n", size, p); return p; //return calloc (1, size); } void operator delete(void* p) { fprintf (stderr, "delete: %p\n", p); //free (p); } This new() returns pointer to memory block surrounded by pages with no access. Alas protection can be set only for entire page, so there is two versions: (1) places block at beginning of page with rw acces, and (2) at end of it. (1) does not work, it seems that there is no wrong memory references below allocated blocks. But (2) works as expected, with -O1 -funit-at-a-time --param large-function-insns=1000 program gets segfault in new place: Program received signal SIGSEGV, Segmentation fault. 0x08056d6e in Engine<1, int, Dynamic>::performDestroy<IntervalIterator> (this=0x4042cfec, killBegin=@0x9, killEnd=@0x9) at pr14863.cc:4196 4196 return tmp; (gdb) where #0 0x08056d6e in Engine<1, int, Dynamic>::performDestroy<IntervalIterator> (this=0x4042cfec, killBegin=@0x9, killEnd=@0x9) at pr14863.cc:4196 #1 0x08056f35 in Engine<1, int, Dynamic>::performDestroy<Interval<1> > (this=0x9, killList=@0xbffff530, offsetFlag=false) at pr14863.cc:12135 #2 0x08056f71 in Engine<1, int, Dynamic>::destroy<Interval<1> > (this=0x9, killList=@0x9) at pr14863.cc:4513 #3 0x080571f0 in Particles<MPDynamicUniform>::performDestroy (this=0xbffff7b0, pid=-1073744704, renum=true) at pr14863.cc:11218 #4 0x0804fb35 in main (argc=1, argv=0xbffff994) at pr14863.cc:14496 (gdb) list 14496 P.performDestroy(); 14497 DynamicArray < Vector < 2, int >, MultiPatch < DynamicTag, Dynamic > >a3; 14498 Interval < 1 > empty; 14499 DynamicLayout layout(empty, 1); 14500 a3.initialize(layout); 14501 a3.create(20); 14502 } (gdb) list 4196 4191 return tmp; 4192 } 4193 This_t operator--(int) { 4194 This_t tmp(*this); 4195 RCBPtr_t::operator--(); 4196 return tmp; 4197 } 4198 This_t operator+(ptrdiff_t i) const { 4199 This_t ret(*this); 4200 ret += i; (gdb) q -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14863
next prev parent reply other threads:[~2004-04-10 22:16 UTC|newest] Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top 2004-04-06 11:43 [Bug optimization/14863] New: [3.4 " rguenth at tat dot physik dot uni-tuebingen dot de 2004-04-06 11:45 ` [Bug optimization/14863] " rguenth at tat dot physik dot uni-tuebingen dot de 2004-04-06 11:49 ` rguenth at tat dot physik dot uni-tuebingen dot de 2004-04-06 12:36 ` pinskia at gcc dot gnu dot org 2004-04-06 23:48 ` 1319 at bot dot ru 2004-04-07 7:59 ` rguenth at tat dot physik dot uni-tuebingen dot de 2004-04-07 8:00 ` rguenth at tat dot physik dot uni-tuebingen dot de 2004-04-07 8:04 ` rguenth at tat dot physik dot uni-tuebingen dot de 2004-04-07 10:25 ` 1319 at bot dot ru 2004-04-07 11:56 ` 1319 at bot dot ru 2004-04-07 12:04 ` rguenth at tat dot physik dot uni-tuebingen dot de 2004-04-07 13:07 ` [Bug optimization/14863] [3.4/3.5 " pinskia at gcc dot gnu dot org 2004-04-07 13:26 ` rguenth at tat dot physik dot uni-tuebingen dot de 2004-04-07 13:37 ` rguenth at tat dot physik dot uni-tuebingen dot de 2004-04-07 13:44 ` giovannibajo at libero dot it 2004-04-07 16:08 ` pinskia at gcc dot gnu dot org 2004-04-07 20:55 ` pinskia at gcc dot gnu dot org 2004-04-08 11:57 ` rguenth at tat dot physik dot uni-tuebingen dot de 2004-04-08 11:58 ` rguenth at tat dot physik dot uni-tuebingen dot de 2004-04-09 13:09 ` pinskia at gcc dot gnu dot org 2004-04-09 13:12 ` pinskia at gcc dot gnu dot org 2004-04-09 13:35 ` pinskia at gcc dot gnu dot org 2004-04-10 15:27 ` rguenth at tat dot physik dot uni-tuebingen dot de 2004-04-11 1:06 ` 1319 at bot dot ru [this message] 2004-06-02 0:08 ` [Bug rtl-optimization/14863] " belyshev at lubercy dot com 2004-06-02 0:19 ` [Bug rtl-optimization/14863] [3.4 " pinskia at gcc dot gnu dot org 2004-06-02 6:47 ` belyshev at lubercy dot com 2004-06-02 7:38 ` rguenth at tat dot physik dot uni-tuebingen dot de 2004-06-02 8:50 ` belyshev at lubercy dot com 2004-06-02 10:18 ` giovannibajo at libero dot it 2004-06-02 10:51 ` rguenth at tat dot physik dot uni-tuebingen dot de 2004-06-02 10:57 ` giovannibajo at libero dot it 2004-06-02 11:07 ` rguenth at tat dot physik dot uni-tuebingen dot de 2004-06-02 11:14 ` giovannibajo at libero dot it 2004-06-02 11:15 ` belyshev at lubercy dot com 2004-06-02 11:54 ` rguenth at tat dot physik dot uni-tuebingen dot de 2004-06-02 12:05 ` rguenth at tat dot physik dot uni-tuebingen dot de 2004-06-02 22:30 ` pinskia at gcc dot gnu dot org 2004-06-03 1:01 ` [Bug rtl-optimization/14863] [3.4/3.5 " giovannibajo at libero dot it 2004-06-03 1:08 ` pinskia at gcc dot gnu dot org 2004-06-03 1:12 ` pinskia at gcc dot gnu dot org 2004-06-03 1:25 ` giovannibajo at libero dot it 2004-06-04 20:47 ` giovannibajo at libero dot it
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20040410221622.17153.qmail@sources.redhat.com \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).