From: Eli Zaretskii <eliz@gnu.org>
To: Barry OReilly <gundaetiapo@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: GC and stack marking
Date: Thu, 22 May 2014 20:03:49 +0300 [thread overview]
Message-ID: <837g5dn3t6.fsf@gnu.org> (raw)
In-Reply-To: <CAFM41H2MX7ZV2t1iK7Zh_-KRLXXXdyN=cj3cqWdtcESugwZe2Q@mail.gmail.com>
> Date: Thu, 22 May 2014 10:59:00 -0400
> From: Barry OReilly <gundaetiapo@gmail.com>
> Cc: emacs-devel@gnu.org
>
> > Yes. I looked at all the local variables in that stack frame, and
> > their addresses on the stack are different from the one that
> > triggers the problem.
>
> [I assume you mean "void* values on the stack" rather than "addresses
> on the stack".]
No, I meant addresses on the stack. Like this:
(gdb) info locals
foo = 0xbaadf00d
bar = 191919191
baz = 0 '\000'
(gdb) p/x &foo
$1 = 0x12345678
(gdb) p/x &bar
$2 = 0x23456789
(gdb) p/x &baz
$3 = 0x87654321
I compared these addresses with the value the 'pp' variable had in
mark_memory, here:
for (pp = start; (void *) pp < end; pp++)
for (i = 0; i < sizeof *pp; i += GC_POINTER_ALIGNMENT)
{
void *p = *(void **) ((char *) pp + i);
mark_maybe_pointer (p);
if (POINTERS_MIGHT_HIDE_IN_OBJECTS)
mark_maybe_object (XIL ((intptr_t) p));
}
when the value of 'p' was the address of the hash-table struct that
was passed to mark_maybe_pointer.
> So when you printed the value of a one byte variable like
> stack_top_variable, you printed it with any alignment padding there
> might be?
I didn't print any values, just the addresses, see above. That's
because I already knew the address of the stack slot where the
offending value was stored, so I didn't need to look for it. That
address was the value of 'pp' above.
> And you accounted for the compiler reordering stack variables, eg to
> more optimally align data?
Yes, in a way: I looked at the disassembly of the offending function,
and reviewed every reference to a stack slot via $ebp and $esp. Since
I knew the values of $ebp and $esp of that function when mark_stack
was called, and I also knew the address of the stack slot where the
offending value was stored, it was simple to calculate the offsets
from $ebp and $esp corresponding to that stack slot. I looked for
those offsets in the disassembly, but they weren't there.
> I confirmed for example that stack_top_variable and message_p are
> allocated next to each other on the stack in my build, with the i
> variable not between them in memory.
Again, I checked all the locals in that function, and I also checked
all the references to the stack in the disassembly, thus accounting
for temporary values that have no C variables in the source. I think
this covers all the possibilities, and isn't affected by how the
compiler allocates the variables on the stack.
next prev parent reply other threads:[~2014-05-22 17:03 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-21 19:31 GC and stack marking Barry OReilly
2014-05-21 20:13 ` Eli Zaretskii
2014-05-21 20:49 ` Barry OReilly
2014-05-22 2:43 ` Eli Zaretskii
2014-05-22 3:12 ` Daniel Colascione
2014-05-22 5:37 ` David Kastrup
2014-05-22 13:57 ` Stefan Monnier
2014-05-22 15:49 ` Eli Zaretskii
2014-05-22 14:59 ` Barry OReilly
2014-05-22 17:03 ` Eli Zaretskii [this message]
-- strict thread matches above, loose matches on Subject: below --
2014-05-19 16:31 Eli Zaretskii
2014-05-19 18:47 ` Paul Eggert
2014-05-19 19:14 ` Eli Zaretskii
2014-05-19 19:58 ` Paul Eggert
2014-05-19 20:03 ` Eli Zaretskii
2014-05-19 20:17 ` Paul Eggert
2014-05-20 16:37 ` Eli Zaretskii
2014-05-20 13:44 ` Stefan Monnier
2014-05-20 16:57 ` Eli Zaretskii
2014-05-20 17:54 ` Stefan Monnier
2014-05-20 19:28 ` Eli Zaretskii
2014-05-20 22:01 ` Stefan Monnier
2014-05-21 2:48 ` Eli Zaretskii
2014-05-21 3:01 ` Stefan Monnier
2014-05-21 15:39 ` Eli Zaretskii
2014-05-21 15:57 ` Dmitry Antipov
2014-05-21 16:06 ` Dmitry Antipov
2014-05-21 16:55 ` Eli Zaretskii
2014-05-21 16:53 ` Eli Zaretskii
2014-05-21 17:40 ` Stefan Monnier
2014-05-21 17:58 ` Eli Zaretskii
2014-05-22 15:20 ` Eli Zaretskii
2014-05-22 16:14 ` Stefan Monnier
2014-05-24 12:03 ` Eli Zaretskii
2014-05-20 19:12 ` Daniel Colascione
2014-05-20 19:43 ` Eli Zaretskii
2014-05-20 22:03 ` Stefan Monnier
2014-05-21 2:51 ` Eli Zaretskii
2014-05-31 6:31 ` Florian Weimer
2014-05-31 14:24 ` Stefan Monnier
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=837g5dn3t6.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=gundaetiapo@gmail.com \
/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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.