From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: GC and stack marking Date: Thu, 22 May 2014 20:03:49 +0300 Message-ID: <837g5dn3t6.fsf@gnu.org> References: <83sio2nb4s.fsf@gnu.org> <83r43mmt25.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1400778243 21155 80.91.229.3 (22 May 2014 17:04:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 22 May 2014 17:04:03 +0000 (UTC) Cc: emacs-devel@gnu.org To: Barry OReilly Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu May 22 19:03:55 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WnWPK-00045f-Iv for ged-emacs-devel@m.gmane.org; Thu, 22 May 2014 19:03:54 +0200 Original-Received: from localhost ([::1]:38929 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WnWPK-0002jq-5N for ged-emacs-devel@m.gmane.org; Thu, 22 May 2014 13:03:54 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35567) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WnWPA-0002eW-TX for emacs-devel@gnu.org; Thu, 22 May 2014 13:03:51 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WnWP4-0002C4-CC for emacs-devel@gnu.org; Thu, 22 May 2014 13:03:44 -0400 Original-Received: from mtaout27.012.net.il ([80.179.55.183]:55060) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WnWP4-0002Bo-0k for emacs-devel@gnu.org; Thu, 22 May 2014 13:03:38 -0400 Original-Received: from conversion-daemon.mtaout27.012.net.il by mtaout27.012.net.il (HyperSendmail v2007.08) id <0N5Z00N00J6G4J00@mtaout27.012.net.il> for emacs-devel@gnu.org; Thu, 22 May 2014 20:00:22 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by mtaout27.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0N5Z00MDAJ8M8M10@mtaout27.012.net.il>; Thu, 22 May 2014 20:00:22 +0300 (IDT) In-reply-to: X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 80.179.55.183 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:172034 Archived-At: > Date: Thu, 22 May 2014 10:59:00 -0400 > From: Barry OReilly > 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.