public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* c++/2473: Program under debugg receives SIGSEGV when passing obj by value
@ 2008-07-08  2:48 drazen
  0 siblings, 0 replies; 2+ messages in thread
From: drazen @ 2008-07-08  2:48 UTC (permalink / raw)
  To: gdb-gnats


>Number:         2473
>Category:       c++
>Synopsis:       Program under debugg receives SIGSEGV when passing obj by value
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jul 08 02:48:01 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     drazen@gmail.com
>Release:        6.3
>Organization:
>Environment:
uname -a
Linux belgrade 2.4.21-50.ELsmp #1 SMP Tue May 8 17:10:20 EDT 2007
x86_64 x86_64 x86_64 GNU/Linux
compiler: g++ 3.4.6
>Description:
Hi,
I bring the following code into the debugger:
 0  //-------------------------------------------------
 1  class F {
 2  public:
 3     int m_F;
 4     //-------
 5     F(int x)  : m_F(x) // constructor
 6     { }
 7     F(const F& f) :  m_F(f.m_F) // copy constructor
 8     { }
 9  };
10  //NOTE: object is passed, not reference
11  int  getMember(F f)     // 
12  {
13     return f.m_F;
14  }
15
16  int main()
17  {
18    F f1(3);
19    int i = getMember(f1);
20    return 0;
21  }
22
23  //----------------------------------------------


As I step through main, line 19 executes correctly, and 
"i" contains 3 as expected.
Then I invoke "getMember()"  from the debugger, and the program under the debugger receives SIGSEGV:

(gdb)  print   getMember(f1)
Program received signal SIGSEGV, Segmentation fault.
getMember (f1=Cannot access memory at address 0x3) at f.cc:15
The program being debugged was signaled while in a function called
from GDB.
GDB remains in the frame where the signal was received.
To change this behavior use "set unwindonsignal on"
Evaluation of the expression containing the function (getMember(F))
will be abandoned.
------------------------------------------------------------------------------
1. If "getMember()" takes reference to F, everything is 
fine when "getMember()" is called from within gdb.
2. If I use C instead of C++, and struct, again everything
is fine.
3. I tried using gdb 6.3 and 6.8 (the newest), and both 
behave identically.

Thanks, Drazen 
>How-To-Repeat:
Compile and run the above program in the debugger.

>Fix:
No known fix.
>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: c++/2473: Program under debugg receives SIGSEGV when passing obj by value
@ 2008-07-08 14:08 Aleksandar Ristovski
  0 siblings, 0 replies; 2+ messages in thread
From: Aleksandar Ristovski @ 2008-07-08 14:08 UTC (permalink / raw)
  To: nobody; +Cc: gdb-prs

The following reply was made to PR c++/2473; it has been noted by GNATS.

From: Aleksandar Ristovski <aristovski@qnx.com>
To: gdb-gnats@sources.redhat.com
Cc:  
Subject: Re: c++/2473: Program under debugg receives SIGSEGV when passing
 obj by value
Date: Tue, 08 Jul 2008 09:59:55 -0400

 drazen@gmail.com wrote:
 > Hi,
 > I bring the following code into the debugger:
 >  0  //-------------------------------------------------
 >  1  class F {
 >  2  public:
 >  3     int m_F;
 >  4     //-------
 >  5     F(int x)  : m_F(x) // constructor
 >  6     { }
 >  7     F(const F& f) :  m_F(f.m_F) // copy constructor
 >  8     { }
 >  9  };
 > 10  //NOTE: object is passed, not reference
 > 11  int  getMember(F f)     // 
 > 12  {
 > 13     return f.m_F;
 > 14  }
 > 15
 > 16  int main()
 > 17  {
 > 18    F f1(3);
 > 19    int i = getMember(f1);
 > 20    return 0;
 > 21  }
 > 22
 > 23  //----------------------------------------------
 > 
 > 
 
 It looks like it's compiler version related. When compiled with 4.1.2, it seems to work fine (tried gdb 6.7.1 and HEAD):
 
 gcc -v
 Using built-in specs.
 Target: i686-pc-linux-gnu
 Configured with: /var/tmp/portage/sys-devel/gcc-4.1.2/work/gcc-4.1.2/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.1.2 --includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.2 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.2/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.2/info --with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include/g++-v4 --host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec  --enable-nls --without-included-gettext --with-system-zlib --disable-checking --disable-werror --enable-secureplt --disable-libunwind-exceptions --disable-multilib --enable-libmudflap --disable-libssp --disable-libgcj --with-arch=i686 --enable-languages=c,c++,treelang,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
 Thread model: posix
 gcc version 4.1.2 (Gentoo 4.1.2 p1.0.2)
 
 
 (gdb) show version
 GNU gdb 6.7.1
 Copyright (C) 2007 Free Software Foundation, Inc.
 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
 This is free software: you are free to change and redistribute it.
 There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
 and "show warranty" for details.
 This GDB was configured as "i686-pc-linux-gnu".
 (gdb) b main
 During symbol reading, Location list used without specifying the CU base address..
 Breakpoint 1 at 0x804843b: file /tmp/gdb2473/main.cpp, line 18.
 (gdb) r
 Starting program: /tmp/gdb2473/main
 
 Breakpoint 1, main () at /tmp/gdb2473/main.cpp:18
 18        F f1(3);
 (gdb) n
 During symbol reading, incomplete CFI data; unspecified registers (e.g., eax) at 0x8048438.
 19        int i = getMember(f1);
 (gdb) print getMember(f1)
 $1 = 3
 (gdb)
 
 
 
 HEAD:
 (gdb) show version
 GNU gdb (GDB) 6.8.50.20080708-cvs
 Copyright (C) 2008 Free Software Foundation, Inc.
 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
 This is free software: you are free to change and redistribute it.
 There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
 and "show warranty" for details.
 This GDB was configured as "i686-pc-linux-gnu".
 For bug reporting instructions, please see:
 <http://www.gnu.org/software/gdb/bugs/>.
 (gdb) b main
 During symbol reading, Location list used without specifying the CU base address..
 Breakpoint 1 at 0x804843b: file /tmp/gdb2473/main.cpp, line 18.
 (gdb) r
 Starting program: /tmp/gdb2473/main
 
 Breakpoint 1, main () at /tmp/gdb2473/main.cpp:18
 18        F f1(3);
 (gdb) n
 During symbol reading, incomplete CFI data; unspecified registers (e.g., eax) at 0x8048438.
 19        int i = getMember(f1);
 (gdb) print getMember(f1)
 $1 = 3
 
 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-07-08 14:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-08  2:48 c++/2473: Program under debugg receives SIGSEGV when passing obj by value drazen
2008-07-08 14:08 Aleksandar Ristovski

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).