From: "Mahmood Naderan via gdb" <gdb@sourceware.org>
To: "gdb@sourceware.org" <gdb@sourceware.org>,
Pedro Alves <palves@redhat.com>
Subject: Re: Viewing the address of an array in gdb
Date: Fri, 06 Jul 2018 13:08:00 -0000 [thread overview]
Message-ID: <1883587662.54335.1530882474281@mail.yahoo.com> (raw)
In-Reply-To: <e6892311-f2ca-4673-4f91-23f44a34fba3@redhat.com>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=UTF-8, Size: 22009 bytes --]
Yes you are right. It picked the glibc symbol name "buffer".
No matters. I will change the name. I thought there is something wrong with the buffer I defined.
Thank you very much.
Regards,
Mahmood
On Friday, July 6, 2018, 4:36:41 PM GMT+4:30, Pedro Alves <palves@redhat.com> wrote:
If you can't change the program, you can work around this by
unloading the shared library symbols, so that gdb sees the
program's symbol again. E.g.:
(gdb) start
Temporary breakpoint 1 at 0x40048b
Starting program: /home/pedro/tmp/buffer
Temporary breakpoint 1, 0x000000000040048b in main ()
(gdb) info symbol &buffer
buffer in section .bss of /lib64/libc.so.6
(gdb) nosharedlibrary
(gdb) info symbol &buffer
buffer in section .bss
(gdb) x /30x &buffer
0x601040 <buffer>:Â Â Â 0x00000000Â Â Â 0x00000000Â Â Â 0x00000000Â Â Â 0x00000000
0x601050 <buffer+16>:Â 0x00000000Â Â Â 0x00000000Â Â Â 0x00000000Â Â Â 0x00000000
0x601060 <buffer+32>:Â 0x00000000Â Â Â 0x00000000Â Â Â 0x00000000Â Â Â 0x00000000
0x601070 <buffer+48>:Â 0x00000000Â Â Â 0x00000000Â Â Â 0x00000000Â Â Â 0x00000000
0x601080 <buffer+64>:Â 0x00000000Â Â Â 0x00000000Â Â Â 0x00000000Â Â Â 0x00000000
0x601090 <buffer+80>:Â 0x00000000Â Â Â 0x00000000Â Â Â 0x00000000Â Â Â 0x00000000
0x6010a0 <buffer+96>:Â 0x00000000Â Â Â 0x00000000Â Â Â 0x00000000Â Â Â 0x00000000
0x6010b0:Â Â Â 0x00000000Â Â Â 0x00000000
(gdb)
Thanks,
Pedro Alves
From gdb-return-46510-listarch-gdb=sources.redhat.com@sourceware.org Fri Jul 06 13:08:51 2018
Return-Path: <gdb-return-46510-listarch-gdb=sources.redhat.com@sourceware.org>
Delivered-To: listarch-gdb@sources.redhat.com
Received: (qmail 127911 invoked by alias); 6 Jul 2018 13:08:51 -0000
Mailing-List: contact gdb-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <gdb.sourceware.org>
List-Subscribe: <mailto:gdb-subscribe@sourceware.org>
List-Archive: <http://sourceware.org/ml/gdb/>
List-Post: <mailto:gdb@sourceware.org>
List-Help: <mailto:gdb-help@sourceware.org>, <http://sourceware.org/ml/#faqs>
Sender: gdb-owner@sourceware.org
Delivered-To: mailing list gdb@sourceware.org
Received: (qmail 127897 invoked by uid 89); 6 Jul 2018 13:08:51 -0000
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=H*c:PHrt, H*c:alternative, H*x:5.0, H*c:HHHHH
X-HELO: sonic301-3.consmr.mail.bf2.yahoo.com
Received: from sonic301-3.consmr.mail.bf2.yahoo.com (HELO sonic301-3.consmr.mail.bf2.yahoo.com) (74.6.129.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 06 Jul 2018 13:08:50 +0000
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t\x1530882528; bh=G2ZoKKb+xKZcJ5aa+WJ/3GRCMo2FSKj66wOZNOQXhrM=; hÚte:From:Reply-To:To:In-Reply-To:References:Subject:From:Subject; b=YD6TOIK/ZHQKX8DD7zAH0bvwaMKknthMbZP+sGHxNlVzdMYpUS+0Ef9O87Uev0IeVFkXrnFJFxPxFP/Uk/rEkU8f/RzulCIif5ULqzuyuuk2pLbrNtdeBRLcZvQmeVp3Sij88jC5RoV8K/lHYA4DzdN+i5OQ/KZFK3p/7mtaH6TLL/KlzAcOSxI17KEDvpLyJrin8gWtOVL+eCUS6YURVl6U1FIIrBPOatit3X+O/fvjQn+IyWwTjkzKbj1Nqc4YBAquE2oN5pzaWdxRrcik4iL8+TdvjPb7U3iu1eFs1Xn9clLxTac6ErOb0a07QXu1kBg43Gzjlu3j9yVW/7FP0g=Received: from sonic.gate.mail.ne1.yahoo.com by sonic301.consmr.mail.bf2.yahoo.com with HTTP; Fri, 6 Jul 2018 13:08:48 +0000
Date: Fri, 06 Jul 2018 13:08:00 -0000
From: "Mahmood Naderan via gdb" <gdb@sourceware.org>
Reply-To: Mahmood Naderan <nt_mahmood@yahoo.com>
Reply-To: Mahmood Naderan <nt_mahmood@yahoo.com>
To: "gdb@sourceware.org" <gdb@sourceware.org>, Pedro Alves <palves@redhat.com>
Message-ID: <1251589382.60449.1530882523908@mail.yahoo.com>
In-Reply-To: <cc4b1273-31f1-27e6-f6dd-39cb34c84691@redhat.com>
References: <1839186466.17059.1530875705518.ref@mail.yahoo.com> <1839186466.17059.1530875705518@mail.yahoo.com> <111043354.25205.1530876761267@mail.yahoo.com> <cc4b1273-31f1-27e6-f6dd-39cb34c84691@redhat.com>
Subject: Re: debugging a callq command
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-IsSubscribed: yes
X-SW-Source: 2018-07/txt/msg00022.txt.bz2
Content-length: 614
Right. Something happened in callq.
Thank you very much.
Regards,
Mahmood
On Friday, July 6, 2018, 4:18:39 PM GMT+4:30, Pedro Alves <palves@redhat.com> wrote:
On 07/06/2018 12:32 PM, Mahmood Naderan via gdb wrote:
something else while the program receives seg fault.
Are you maybe confusing stepi with nexti? nexti steps over the call
instruction, and then it sounds like something crashes within the
called routine at 0x7fffffffde70. Try "stepi" to follow the full
instruction flow instead, and it will probably crash at the same
instruction.
Thanks,
Pedro Alves
From gdb-return-46511-listarch-gdb=sources.redhat.com@sourceware.org Sat Jul 07 16:15:58 2018
Return-Path: <gdb-return-46511-listarch-gdb=sources.redhat.com@sourceware.org>
Delivered-To: listarch-gdb@sources.redhat.com
Received: (qmail 25674 invoked by alias); 7 Jul 2018 16:15:32 -0000
Mailing-List: contact gdb-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <gdb.sourceware.org>
List-Subscribe: <mailto:gdb-subscribe@sourceware.org>
List-Archive: <http://sourceware.org/ml/gdb/>
List-Post: <mailto:gdb@sourceware.org>
List-Help: <mailto:gdb-help@sourceware.org>, <http://sourceware.org/ml/#faqs>
Sender: gdb-owner@sourceware.org
Delivered-To: mailing list gdb@sourceware.org
Received: (qmail 25438 invoked by uid 89); 7 Jul 2018 16:15:04 -0000
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=0.0 required=5.0 tests=AWL,BAYES_40,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy5, SIGSEGV, crashes, H*c:PHrt
X-HELO: sonic316-13.consmr.mail.bf2.yahoo.com
Received: from sonic316-13.consmr.mail.bf2.yahoo.com (HELO sonic316-13.consmr.mail.bf2.yahoo.com) (74.6.130.123) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 07 Jul 2018 16:15:03 +0000
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t\x1530980101; bh=CY313Hbk2DQbJK4TKttzHT2vvSls6qYI/Sjwh9RtMYA=; hÚte:From:Reply-To:To:Subject:References:From:Subject; b=AWZBZV69A/Vc7MQfnLzZ78CJhmPSVoetJgP4I+NdiYUq0qVYO82X50SFLzxuMgwKtqx35+KixAjLxTdf10+WFYzZJO/pWn/NGF+1bzHF6dEryu4zkJ+Ng9LJqu1MXpGbTJKqEveaA0yslDXgBePjqyPRigkgEchthpCa0lEP59wK3rwZVFFrKSM2doW6Ywipa3tkSNoliLoUQzbB1cBOr6s313YwE/9iW/AAjz2SFw4FGJWO6g4ACrZiltE85O1iFTHJsSd8Cl5KzsgFdyFdtSk4FHD9TbrnEQ1UwHNU1Nn2r54UzxFyiptqKEJB7FewhS5DGuMpNNPyg27BRbZ4Mw=Received: from sonic.gate.mail.ne1.yahoo.com by sonic316.consmr.mail.bf2.yahoo.com with HTTP; Sat, 7 Jul 2018 16:15:01 +0000
Date: Sat, 07 Jul 2018 16:15:00 -0000
From: "Mahmood Naderan via gdb" <gdb@sourceware.org>
Reply-To: Mahmood Naderan <nt_mahmood@yahoo.com>
Reply-To: Mahmood Naderan <nt_mahmood@yahoo.com>
To: "gdb@sourceware.org" <gdb@sourceware.org>
Message-ID: <1810093935.481654.1530980099373@mail.yahoo.com>
Subject: Debugging issue with -m32 program
MIME-Version: 1.0
References: <1810093935.481654.1530980099373.ref@mail.yahoo.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-IsSubscribed: yes
X-SW-Source: 2018-07/txt/msg00023.txt.bz2
Content-length: 2295
Hello,
I have compiled a simple c program with -m32 option. Thing is that when I want to copy some data into an array, it crashes
Breakpoint 1, main (argc=1, argv=0xffffd154) at vuln.c:35
35Â Â Â Â strcpy( dest, buffer );
(gdb) p &buffer[0]
$1 = 0xffffcfb5 '\220' <repeats 50 times>, "\061\300Ph//shh/bin\211\343P\211\342S\211\341\260\vÍ", '\220' <repeats 37 times>, "P\336\377\377\377\177"
(gdb) p &dest[0]
$2 = 0xffffd02c "\020\334\377", <incomplete sequence \367>
(gdb) x/100x 0xffffcfb5
0xffffcfb5:Â Â Â 0x90909090Â Â Â 0x90909090Â Â Â 0x90909090Â Â Â 0x90909090
0xffffcfc5:Â Â Â 0x90909090Â Â Â 0x90909090Â Â Â 0x90909090Â Â Â 0x90909090
0xffffcfd5:Â Â Â 0x90909090Â Â Â 0x90909090Â Â Â 0x90909090Â Â Â 0x90909090
0xffffcfe5:Â Â Â 0xc0319090Â Â Â 0x2f2f6850Â Â Â 0x2f686873Â Â Â 0x896e6962
0xffffcff5:   0xe28950e3   0xb0e18953   0x9080cd0b   0x90909090
0xffffd005:Â Â Â 0x90909090Â Â Â 0x90909090Â Â Â 0x90909090Â Â Â 0x90909090
0xffffd015:Â Â Â 0x90909090Â Â Â 0x90909090Â Â Â 0x90909090Â Â Â 0x90909090
0xffffd025:   0xffffde50   0x10007fff   0x00f7ffdc   0x5cf7ffca
0xffffd035:Â Â Â 0xe0ffffd1Â Â Â 0xb7000000Â Â Â 0xe0f7f047Â Â Â 0x90f7ffdd
0xffffd045:Â Â Â 0x00ffffd0Â Â Â 0x00000000Â Â Â 0x00000000Â Â Â 0x2c000000
(gdb) next
Program received signal SIGSEGV, Segmentation fault.
0x56555655 in main (argc=<error reading variable: Cannot access memory at address 0x90909090>,
   argv=<error reading variable: Cannot access memory at address 0x90909094>) at vuln.c:37
37Â Â Â }
Without specifying -m32, there is no problem. I wonder why it tries to access 0x90909090. There is some problem with 32/64 bit data.
Regards,
Mahmood
From gdb-return-46512-listarch-gdb=sources.redhat.com@sourceware.org Mon Jul 09 07:19:15 2018
Return-Path: <gdb-return-46512-listarch-gdb=sources.redhat.com@sourceware.org>
Delivered-To: listarch-gdb@sources.redhat.com
Received: (qmail 53954 invoked by alias); 9 Jul 2018 07:19:14 -0000
Mailing-List: contact gdb-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <gdb.sourceware.org>
List-Subscribe: <mailto:gdb-subscribe@sourceware.org>
List-Archive: <http://sourceware.org/ml/gdb/>
List-Post: <mailto:gdb@sourceware.org>
List-Help: <mailto:gdb-help@sourceware.org>, <http://sourceware.org/ml/#faqs>
Sender: gdb-owner@sourceware.org
Delivered-To: mailing list gdb@sourceware.org
Received: (qmail 53933 invoked by uid 89); 9 Jul 2018 07:19:13 -0000
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=0.7 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=segmentation, strcpy, 37, H*c:PHrt
X-HELO: sonic316-15.consmr.mail.bf2.yahoo.com
Received: from sonic316-15.consmr.mail.bf2.yahoo.com (HELO sonic316-15.consmr.mail.bf2.yahoo.com) (74.6.130.125) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 09 Jul 2018 07:19:12 +0000
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t\x1531120750; bh=gVOs3t+88yOPq7Wt4VD+KOWVMxcPTM8gTjZUlkozW7w=; hÚte:From:Reply-To:To:In-Reply-To:References:Subject:From:Subject; b=iz4+pkblroiJIclJORoAOOsyJaW3RzX1cLRUqaGQlQZvCZfD6M3B4VmiKC/r5n2R72nBDfqrkt6Uc7Km+gk8rVKAb6yq4IwcUpcx6ilBKU0kHV7YRR77LP2NZG9hkE/wAgwEFNe9i5SQjzbIimAPRUXq97A84vBF8wWoiS5XyKL24Fw/oWYP8DcfxGw7u8J8Gm9sHeZKA8/CrVeKipGG7mRk0+wkY4eu5NvuevyPFNBqEY95MepABRLcwHBpPnfu+J2XqZHzP8YFMf+Lu9cwrCKl2hrAbeBOxkNALTx38jw3Yf1cZsfddn03RlEXKDxmPxjS32YO4kUvwyE024z2tQ=Received: from sonic.gate.mail.ne1.yahoo.com by sonic316.consmr.mail.bf2.yahoo.com with HTTP; Mon, 9 Jul 2018 07:19:10 +0000
Date: Mon, 09 Jul 2018 07:19:00 -0000
From: "Mahmood Naderan via gdb" <gdb@sourceware.org>
Reply-To: Mahmood Naderan <nt_mahmood@yahoo.com>
Reply-To: Mahmood Naderan <nt_mahmood@yahoo.com>
To: "gdb@sourceware.org" <gdb@sourceware.org>
Message-ID: <1899779916.938872.1531120747010@mail.yahoo.com>
In-Reply-To: <1810093935.481654.1530980099373@mail.yahoo.com>
References: <1810093935.481654.1530980099373.ref@mail.yahoo.com> <1810093935.481654.1530980099373@mail.yahoo.com>
Subject: Re: Debugging issue with -m32 program
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-IsSubscribed: yes
X-SW-Source: 2018-07/txt/msg00024.txt.bz2
Content-length: 2450
No idea?
Regards,
Mahmood
On Saturday, July 7, 2018, 8:46:01 PM GMT+4:30, Mahmood Naderan via gdb <gdb@sourceware.org> wrote:
Hello,
I have compiled a simple c program with -m32 option. Thing is that when I want to copy some data into an array, it crashes
Breakpoint 1, main (argc=1, argv=0xffffd154) at vuln.c:35
35Â Â Â Â strcpy( dest, buffer );
(gdb) p &buffer[0]
$1 = 0xffffcfb5 '\220' <repeats 50 times>, "\061\300Ph//shh/bin\211\343P\211\342S\211\341\260\vÍ", '\220' <repeats 37 times>, "P\336\377\377\377\177"
(gdb) p &dest[0]
$2 = 0xffffd02c "\020\334\377", <incomplete sequence \367>
(gdb) x/100x 0xffffcfb5
0xffffcfb5:Â Â Â 0x90909090Â Â Â 0x90909090Â Â Â 0x90909090Â Â Â 0x90909090
0xffffcfc5:Â Â Â 0x90909090Â Â Â 0x90909090Â Â Â 0x90909090Â Â Â 0x90909090
0xffffcfd5:Â Â Â 0x90909090Â Â Â 0x90909090Â Â Â 0x90909090Â Â Â 0x90909090
0xffffcfe5:Â Â Â 0xc0319090Â Â Â 0x2f2f6850Â Â Â 0x2f686873Â Â Â 0x896e6962
0xffffcff5:   0xe28950e3   0xb0e18953   0x9080cd0b   0x90909090
0xffffd005:Â Â Â 0x90909090Â Â Â 0x90909090Â Â Â 0x90909090Â Â Â 0x90909090
0xffffd015:Â Â Â 0x90909090Â Â Â 0x90909090Â Â Â 0x90909090Â Â Â 0x90909090
0xffffd025:   0xffffde50   0x10007fff   0x00f7ffdc   0x5cf7ffca
0xffffd035:Â Â Â 0xe0ffffd1Â Â Â 0xb7000000Â Â Â 0xe0f7f047Â Â Â 0x90f7ffdd
0xffffd045:Â Â Â 0x00ffffd0Â Â Â 0x00000000Â Â Â 0x00000000Â Â Â 0x2c000000
(gdb) next
Program received signal SIGSEGV, Segmentation fault.
0x56555655 in main (argc=<error reading variable: Cannot access memory at address 0x90909090>,
   argv=<error reading variable: Cannot access memory at address 0x90909094>) at vuln.c:37
37Â Â Â }
Without specifying -m32, there is no problem. I wonder why it tries to access 0x90909090. There is some problem with 32/64 bit data.
Regards,
Mahmood
From gdb-return-46513-listarch-gdb=sources.redhat.com@sourceware.org Mon Jul 09 12:14:25 2018
Return-Path: <gdb-return-46513-listarch-gdb=sources.redhat.com@sourceware.org>
Delivered-To: listarch-gdb@sources.redhat.com
Received: (qmail 45415 invoked by alias); 9 Jul 2018 12:14:24 -0000
Mailing-List: contact gdb-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <gdb.sourceware.org>
List-Subscribe: <mailto:gdb-subscribe@sourceware.org>
List-Archive: <http://sourceware.org/ml/gdb/>
List-Post: <mailto:gdb@sourceware.org>
List-Help: <mailto:gdb-help@sourceware.org>, <http://sourceware.org/ml/#faqs>
Sender: gdb-owner@sourceware.org
Delivered-To: mailing list gdb@sourceware.org
Received: (qmail 45397 invoked by uid 89); 9 Jul 2018 12:14:23 -0000
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=onward, segv, gdbsourcewareorg, H*r:192.168.10
X-HELO: resqmta-po-12v.sys.comcast.net
Received: from resqmta-po-12v.sys.comcast.net (HELO resqmta-po-12v.sys.comcast.net) (96.114.154.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 09 Jul 2018 12:14:22 +0000
Received: from resomta-po-01v.sys.comcast.net ([96.114.154.225]) by resqmta-po-12v.sys.comcast.net with ESMTP id cUmJfeqOOVNwlcV3bffmIR; Mon, 09 Jul 2018 12:14:19 +0000
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20161114; t\x1531138459; bh=xxk7+kWRbuVEziEU7ONymGMmK84VqH8wAJuNePKjRpE=; h=Received:Received:From:Content-Type:Mime-Version:Subject:Date:To: Message-Id; bølplggcr4jBS8Hq2uTXb34r35Jl9LLKE6euwkj7v8lkHYJcwe4vGStgaRFJcj8te brPCg59rX8WuAhqSM35t77fa0j84OM70XBrB0DeghaOIwFZoKdbfBcvL3Yplo9uPwa LEC6LdueJVOvIWZoAT/jKojJL8rscsWYKBkbOXVcyFyjTfbfpmkCcgJj2Doout2Cdx pSza3mUqo9c4h5yEqHZNyElzOoqYOpfqE+AxI8HEWtioBLY8DpRdV2eMFWvDbh+zib IgiJg72drjtYmuI28Laey70VdHgdlrk+EBNfcU2Y+vLsrPSN4pGrVdGOZ3Gp+BLKvW PtREsAeCMUldw=Received: from [192.168.10.125] ([73.60.223.101]) by resomta-po-01v.sys.comcast.net with ESMTPA id cV3afpkdYVGSOcV3bfcR2s; Mon, 09 Jul 2018 12:14:19 +0000
From: Paul Koning <paulkoning@comcast.net>
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Mime-Version: 1.0 (Mac OS X Mail 11.4 \(3445.8.2\))
Subject: Re: Debugging issue with -m32 program
Date: Mon, 09 Jul 2018 12:14:00 -0000
References: <1810093935.481654.1530980099373.ref@mail.yahoo.com> <1810093935.481654.1530980099373@mail.yahoo.com> <1899779916.938872.1531120747010@mail.yahoo.com>
To: Mahmood Naderan <nt_mahmood@yahoo.com>, "gdb@sourceware.org" <gdb@sourceware.org>
In-Reply-To: <1899779916.938872.1531120747010@mail.yahoo.com>
Message-Id: <2E370BA9-E695-4557-AE57-20E68561ACCE@comcast.net>
X-SW-Source: 2018-07/txt/msg00025.txt.bz2
Content-length: 2179
> On Jul 9, 2018, at 3:19 AM, Mahmood Naderan via gdb <gdb@sourceware.org> wrote:
>
> ...
> Hello,
> I have compiled a simple c program with -m32 option. Thing is that when I want to copy some data into an array, it crashes
>
>
> Breakpoint 1, main (argc=1, argv=0xffffd154) at vuln.c:35
> 35 strcpy( dest, buffer );
> (gdb) p &buffer[0]
> $1 = 0xffffcfb5 '\220' <repeats 50 times>, "\061\300Ph//shh/bin\211\343P\211\342S\211\341\260\vÍ", '\220' <repeats 37 times>, "P\336\377\377\377\177"
> (gdb) p &dest[0]
> $2 = 0xffffd02c "\020\334\377", <incomplete sequence \367>
> (gdb) x/100x 0xffffcfb5
> 0xffffcfb5: 0x90909090 0x90909090 0x90909090 0x90909090
> 0xffffcfc5: 0x90909090 0x90909090 0x90909090 0x90909090
> 0xffffcfd5: 0x90909090 0x90909090 0x90909090 0x90909090
> 0xffffcfe5: 0xc0319090 0x2f2f6850 0x2f686873 0x896e6962
> 0xffffcff5: 0xe28950e3 0xb0e18953 0x9080cd0b 0x90909090
> 0xffffd005: 0x90909090 0x90909090 0x90909090 0x90909090
> 0xffffd015: 0x90909090 0x90909090 0x90909090 0x90909090
> 0xffffd025: 0xffffde50 0x10007fff 0x00f7ffdc 0x5cf7ffca
> 0xffffd035: 0xe0ffffd1 0xb7000000 0xe0f7f047 0x90f7ffdd
> 0xffffd045: 0x00ffffd0 0x00000000 0x00000000 0x2c000000
> (gdb) next
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x56555655 in main (argc=<error reading variable: Cannot access memory at address 0x90909090>,
> argv=<error reading variable: Cannot access memory at address 0x90909094>) at vuln.c:37
> 37 }
>
>
>
>
> Without specifying -m32, there is no problem. I wonder why it tries to access 0x90909090. There is some problem with 32/64 bit data.
If "argc" is not used in "main" -- or at least not from this point onward -- then the compiler can reuse that register for other purposes. That is probably what is happening here. Note that this explains the messages in the traceback, but that isn't the reason for the SEGV. The SEGV is an issue in your program. Did you overwrite memory by strcpy to an output that's too small?
paul
From gdb-return-46514-listarch-gdb=sources.redhat.com@sourceware.org Mon Jul 09 19:43:01 2018
Return-Path: <gdb-return-46514-listarch-gdb=sources.redhat.com@sourceware.org>
Delivered-To: listarch-gdb@sources.redhat.com
Received: (qmail 124700 invoked by alias); 9 Jul 2018 19:43:01 -0000
Mailing-List: contact gdb-help@sourceware.org; run by ezmlm
Precedence: bulk
List-Id: <gdb.sourceware.org>
List-Subscribe: <mailto:gdb-subscribe@sourceware.org>
List-Archive: <http://sourceware.org/ml/gdb/>
List-Post: <mailto:gdb@sourceware.org>
List-Help: <mailto:gdb-help@sourceware.org>, <http://sourceware.org/ml/#faqs>
Sender: gdb-owner@sourceware.org
Delivered-To: mailing list gdb@sourceware.org
Received: (qmail 124229 invoked by uid 89); 9 Jul 2018 19:43:00 -0000
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL,BAYES_05,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=H*c:HHHHHHH, HTo:D*comcast.net, H*c:PHrt, Hx-languages-length:678
X-HELO: sonic311-14.consmr.mail.bf2.yahoo.com
Received: from sonic311-14.consmr.mail.bf2.yahoo.com (HELO sonic311-14.consmr.mail.bf2.yahoo.com) (74.6.131.124) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 09 Jul 2018 19:42:59 +0000
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t\x1531165378; bh=f+CLTdvUYf/3UJbxUqlYcUYyjYNIXwYFIb4ovLMkNRo=; hÚte:From:Reply-To:To:In-Reply-To:References:Subject:From:Subject; b=q58Iurj6E70YXPDgLT18buajDFADbNdTRWMINH4PhYm7qnjugCee4UTXHniBdpzjfsdoNf6YkceRVBK3MLEvOd79LDqYIvF9wDYbbQdsJVUpmqRoc9Vw5r4di3pbihHH90n7+8VgDSc0efCOyN8/xNXscLhIvtOh/zzgWUDt8xAEmJfuEEyzgjln5TyI4QfYZSvTkF0n6SUDyeEf/B1Mm7XqPTgET6E460P7KliK2lNQ0MqqqGh69qE/zuT57BQkQIku5zb5q2l7rGkqJkTQi2BGItIZ1TO7vWBJLANSsKLVclvPd+G4I3tVB34Lb8gryXuQ1TThXWcDgbSTLjxBzg=Received: from sonic.gate.mail.ne1.yahoo.com by sonic311.consmr.mail.bf2.yahoo.com with HTTP; Mon, 9 Jul 2018 19:42:58 +0000
Date: Mon, 09 Jul 2018 19:43:00 -0000
From: "Mahmood Naderan via gdb" <gdb@sourceware.org>
Reply-To: Mahmood Naderan <nt_mahmood@yahoo.com>
Reply-To: Mahmood Naderan <nt_mahmood@yahoo.com>
To: "gdb@sourceware.org" <gdb@sourceware.org>, Paul Koning <paulkoning@comcast.net>
Message-ID: <1134645069.1279850.1531165376015@mail.yahoo.com>
In-Reply-To: <2E370BA9-E695-4557-AE57-20E68561ACCE@comcast.net>
References: <1810093935.481654.1530980099373.ref@mail.yahoo.com> <1810093935.481654.1530980099373@mail.yahoo.com> <1899779916.938872.1531120747010@mail.yahoo.com> <2E370BA9-E695-4557-AE57-20E68561ACCE@comcast.net>
Subject: Re: Debugging issue with -m32 program
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-IsSubscribed: yes
X-SW-Source: 2018-07/txt/msg00026.txt.bz2
Content-length: 321
>Did you overwrite memory by strcpy to an output that's too small?
Indeed yes. But not too small. The buffer is more than 100 characters while dest is 100 characters. The question is why the same program, without specifying -m32, works actually?!
Which one is correct behavior? Crash or not crash?!
Regards,
Mahmood
prev parent reply other threads:[~2018-07-06 13:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1377359320.54438.1530847991768.ref@mail.yahoo.com>
2018-07-06 3:33 ` Mahmood Naderan via gdb
2018-07-06 11:51 ` Pedro Alves
2018-07-06 12:00 ` Pedro Alves
2018-07-06 12:06 ` Pedro Alves
2018-07-06 13:08 ` Mahmood Naderan via gdb [this message]
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=1883587662.54335.1530882474281@mail.yahoo.com \
--to=gdb@sourceware.org \
--cc=nt_mahmood@yahoo.com \
--cc=palves@redhat.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox