From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29554 invoked by alias); 26 Jan 2009 16:51:16 -0000 Received: (qmail 29544 invoked by uid 22791); 26 Jan 2009 16:51:15 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.45.13) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 26 Jan 2009 16:51:10 +0000 Received: from wpaz24.hot.corp.google.com (wpaz24.hot.corp.google.com [172.24.198.88]) by smtp-out.google.com with ESMTP id n0QGp8GB029449 for ; Mon, 26 Jan 2009 08:51:08 -0800 Received: from wf-out-1314.google.com (wfg24.prod.google.com [10.142.7.24]) by wpaz24.hot.corp.google.com with ESMTP id n0QGoPup008512 for ; Mon, 26 Jan 2009 08:51:06 -0800 Received: by wf-out-1314.google.com with SMTP id 24so6408066wfg.7 for ; Mon, 26 Jan 2009 08:51:05 -0800 (PST) MIME-Version: 1.0 Received: by 10.143.163.10 with SMTP id q10mr1951613wfo.324.1232988665399; Mon, 26 Jan 2009 08:51:05 -0800 (PST) In-Reply-To: <20090126154138.GA14406@caradoc.them.org> References: <74fef6df0901260724p188c5507x2cfa3a4283f6fd41@mail.gmail.com> <20090126154138.GA14406@caradoc.them.org> Date: Mon, 26 Jan 2009 16:51:00 -0000 Message-ID: <8ac60eac0901260851o2a93a13di8a6b8c9cd4f8c15f@mail.gmail.com> Subject: Re: baffling assembly-level weirdness From: Paul Pluzhnikov To: Mathieu Lacage , gdb@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2009-01/txt/msg00173.txt.bz2 On Mon, Jan 26, 2009 at 7:41 AM, Daniel Jacobowitz wrote: > On Mon, Jan 26, 2009 at 04:24:40PM +0100, Mathieu Lacage wrote: >> hi, >> >> The following gdb session baffles me completely: %edx is reset to zero >> by the mov at address 0x0804ad62 instead of being set to the constant >> 0x804ad62. Of course, this code segfaults at $pc = 0x804ad68 when zero >> is dereferenced... >> >> Version: GNU gdb 6.8 >> >> (gdb) disas $pc $pc+10 >> Dump of assembler code from 0x804ad62 to 0x804ad6c: >> 0x0804ad62 : mov 0x805e3c0,%edx > > This is a load from memory at address 0x805e3c0, in x86 syntax. Additional clues: (gdb) p/a 0x805e3c0 will likely print "stdout". If you break in main, and do (gbd) x/a 0x805e3c0 it will likely print something like: 0x8053ac0 : 0x4dcdb5e0 <_IO_2_1_stdout_> It sounds like your program is corrupting stdout somewhere. The fastest way to find out where that happens: (gdb) watch *(int **)0x8053ac0 Cheers, -- Paul Pluzhnikov