public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jtc at acorntoolworks dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/18260] New: generated code uses memory beyond allocated stack frame.
Date: Mon, 01 Nov 2004 00:08:00 -0000	[thread overview]
Message-ID: <20041101000818.18260.jtc@acorntoolworks.com> (raw)

A co-worker testing MySQL 4 on NetBSD/amd64 was having trouble with random
crashes.  He tracked the crashes down to mf_radix.c:radixsort_for_str_ptr(), and
handed the problem off to me for further analysis.

I cut down mf_radix.c (attached to this bug report), and looked at the code
generated with "gcc -O2 -S mf_radix.c".  It appears that the memory for local
variables is not accounted for entirely correctly.  There are 1024+ bytes of
local variables, but the stack pointer (%rsp) is only adjusted by 912 bytes. 
And it appears local variable "count" is referenced before the stack pointer
(-120(%rsp)).

I believe, but have not yet confirmed, that the crashes occur because something
in NetBSD's thread/task switch code is overwriting the values below the stack
pointer assuming that it is free for temporary use.  This may also effect other
systems --I've done the same in embedded kernels I've written in the past.

NetBSD 2.0RC4 uses a modified version of gcc 3.3.3, so I have confirmed that the
problem still exists with unmodified gcc 3.3.5.  Linking in versions of
mf_radix.c compiled without optimization or with gcc 3.4 eliminates the crashes. 

My attempts to build MySQL 4 entirely with gcc 3.4.X have not been successful,
but I have not had enough time to investigate why.

-- 
           Summary: generated code uses memory beyond allocated stack frame.
           Product: gcc
           Version: 3.3.5
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jtc at acorntoolworks dot com
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: i386-netbsd
GCC target triplet: amd64-netbsd


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18260


             reply	other threads:[~2004-11-01  0:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-01  0:08 jtc at acorntoolworks dot com [this message]
2004-11-01  0:11 ` [Bug rtl-optimization/18260] " pinskia at gcc dot gnu dot org
2004-11-01  0:21 ` jtc at acorntoolworks dot com
2004-11-01 13:06 ` falk at debian dot org
2004-11-01 22:45 ` jtc at acorntoolworks dot com

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=20041101000818.18260.jtc@acorntoolworks.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: link
Be 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).