public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/27006] New: Segmentation fault when using gdb command 'call'
@ 2020-12-03 11:29 1in.lang at seznam dot cz
  2020-12-03 13:35 ` [Bug c++/27006] " simark at simark dot ca
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: 1in.lang at seznam dot cz @ 2020-12-03 11:29 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=27006

            Bug ID: 27006
           Summary: Segmentation fault when using gdb command 'call'
           Product: gdb
           Version: 10.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
          Assignee: unassigned at sourceware dot org
          Reporter: 1in.lang at seznam dot cz
  Target Milestone: ---

When calling object method from gdb command line using the command 'call' the
debugger stops on a Segmentation fault which occurs in the called method.

It seems that the argument 'this' is passed to the method wrongly (see the
example bellow).

The bug is in gdb 10.1 new (in versions 8.2 and 9.1 it worked fine).
The bug is present in both 32-bit and 64-bit versions of gdb 10.1.

The problem can be reproduced e.g. by calling a method over an Eigen matrix,
see the error message from gdb command line when calling method 'col' for the
Eigem matrix 'pom'. (Note: see the value of the parameter 'this')

call pom.col(1)
Thread 33 received signal SIGSEGV, Segmentation fault.
0x1008a494 in Eigen::DenseStorage<double, -1, -1, -1, 0>::rows (this=0x1) at
C:/motion_gmc/SDK/libs/eigen/Eigen/src/Core/DenseStorage.h:394
394         EIGEN_DEVICE_FUNC Index rows(void) const {return m_rows;}
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
(Eigen::DenseBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >::col(long)) will
be abandoned.
When the function is done executing, GDB will silently stop.

--- older versions of gdb return the matrix column correctly.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug c++/27006] Segmentation fault when using gdb command 'call'
  2020-12-03 11:29 [Bug c++/27006] New: Segmentation fault when using gdb command 'call' 1in.lang at seznam dot cz
@ 2020-12-03 13:35 ` simark at simark dot ca
  2020-12-03 16:34 ` ssbssa at sourceware dot org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: simark at simark dot ca @ 2020-12-03 13:35 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=27006

Simon Marchi <simark at simark dot ca> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simark at simark dot ca

--- Comment #1 from Simon Marchi <simark at simark dot ca> ---
Can you add a sample program, so that others can try to reproduce?

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug c++/27006] Segmentation fault when using gdb command 'call'
  2020-12-03 11:29 [Bug c++/27006] New: Segmentation fault when using gdb command 'call' 1in.lang at seznam dot cz
  2020-12-03 13:35 ` [Bug c++/27006] " simark at simark dot ca
@ 2020-12-03 16:34 ` ssbssa at sourceware dot org
  2020-12-04 15:55 ` 1in.lang at seznam dot cz
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ssbssa at sourceware dot org @ 2020-12-03 16:34 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=27006

Hannes Domani <ssbssa at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ssbssa at sourceware dot org

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug c++/27006] Segmentation fault when using gdb command 'call'
  2020-12-03 11:29 [Bug c++/27006] New: Segmentation fault when using gdb command 'call' 1in.lang at seznam dot cz
  2020-12-03 13:35 ` [Bug c++/27006] " simark at simark dot ca
  2020-12-03 16:34 ` ssbssa at sourceware dot org
@ 2020-12-04 15:55 ` 1in.lang at seznam dot cz
  2020-12-07 13:51 ` 1in.lang at seznam dot cz
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: 1in.lang at seznam dot cz @ 2020-12-04 15:55 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=27006

--- Comment #2 from Stanislav Lang <1in.lang at seznam dot cz> ---
I'll try to prepare a minimal reproduction next week,...

---------- Původní e-mail ----------
Od: simark at simark dot ca <sourceware-bugzilla@sourceware.org>
Komu: 1in.lang@seznam.cz
Datum: 3. 12. 2020 14:35:13
Předmět: [Bug c++/27006] Segmentation fault when using gdb command 'call'
"https://sourceware.org/bugzilla/show_bug.cgi?id=27006

Simon Marchi <simark at simark dot ca> changed:

What |Removed |Added
----------------------------------------------------------------------------

CC| |simark at simark dot ca

--- Comment #1 from Simon Marchi <simark at simark dot ca> ---
Can you add a sample program, so that others can try to reproduce?

--
You are receiving this mail because:
You reported the bug."

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug c++/27006] Segmentation fault when using gdb command 'call'
  2020-12-03 11:29 [Bug c++/27006] New: Segmentation fault when using gdb command 'call' 1in.lang at seznam dot cz
                   ` (2 preceding siblings ...)
  2020-12-04 15:55 ` 1in.lang at seznam dot cz
@ 2020-12-07 13:51 ` 1in.lang at seznam dot cz
  2020-12-07 13:52 ` 1in.lang at seznam dot cz
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: 1in.lang at seznam dot cz @ 2020-12-07 13:51 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=27006

--- Comment #3 from Stanislav Lang <1in.lang at seznam dot cz> ---
I've analyzed the problem and in the end there is no bug in 'call' command.

The problem was that the OS ABI was set to 'Windows' instead of 'Cygwin'.
Therefore my library has expected the 'this' argument of methods at stack but
it has obtained the first argument of method instead (because of Windows call
convence).

My scenario is a bit complicated, I write a library for embedded target (in
Cygwin) but debug it in an advanced simulator (which is a Windows app).

The only question is why the OS ABI was detected in older versions of GDB
(probably from my binaries or as default value) as 'Cygwin' and now it is
detected (probably from the simulator app or as default value) as 'Windows'.

May be the behavior is intended and right... I don't know.

In any case the explicit setting of OS ABI in initgdb has helped.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug c++/27006] Segmentation fault when using gdb command 'call'
  2020-12-03 11:29 [Bug c++/27006] New: Segmentation fault when using gdb command 'call' 1in.lang at seznam dot cz
                   ` (3 preceding siblings ...)
  2020-12-07 13:51 ` 1in.lang at seznam dot cz
@ 2020-12-07 13:52 ` 1in.lang at seznam dot cz
  2020-12-07 14:17 ` simark at simark dot ca
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: 1in.lang at seznam dot cz @ 2020-12-07 13:52 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=27006

Stanislav Lang <1in.lang at seznam dot cz> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |minor

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug c++/27006] Segmentation fault when using gdb command 'call'
  2020-12-03 11:29 [Bug c++/27006] New: Segmentation fault when using gdb command 'call' 1in.lang at seznam dot cz
                   ` (4 preceding siblings ...)
  2020-12-07 13:52 ` 1in.lang at seznam dot cz
@ 2020-12-07 14:17 ` simark at simark dot ca
  2020-12-07 14:43 ` 1in.lang at seznam dot cz
  2020-12-07 14:48 ` simark at simark dot ca
  7 siblings, 0 replies; 9+ messages in thread
From: simark at simark dot ca @ 2020-12-07 14:17 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=27006

--- Comment #4 from Simon Marchi <simark at simark dot ca> ---
Hi Stanislav,

Ok, this is mostly related to this patch series that was merged earlier this
year:

https://sourceware.org/pipermail/gdb-patches/2020-March/166678.html

Before, there wasn't any distinction between a cygwin binary and a pure Windows
binary compiled with mingw.  That was problematic, because the "long" type size
is different on the two, and GDB needs to know which one it is.

The decision of choosing the windows vs cygwin osabi happens here (assuming you
are on x86-64):

https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdb/amd64-windows-tdep.c;h=a6563cc9e1203fbd83090a6c0f38d9de18f9153c;hb=HEAD#l1355

We check if the binary is linked with the cygwin dll, using this function here:

https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdb/windows-tdep.c;h=a7cab7bc6570e6b2ad1edf0bd64475f5ae958d9d;hb=HEAD#l995

So, if you load a non-cygwin binary in GDB, it's probably expected that it is
recognized as "Windows" and not "Cygwin".

When you debug using your simulator, do you use the remote target ("target
remote ..." or "target extended-remote ...")?  If so, I think it's possible for
the remote target to tell which osabi to use.

Simon

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug c++/27006] Segmentation fault when using gdb command 'call'
  2020-12-03 11:29 [Bug c++/27006] New: Segmentation fault when using gdb command 'call' 1in.lang at seznam dot cz
                   ` (5 preceding siblings ...)
  2020-12-07 14:17 ` simark at simark dot ca
@ 2020-12-07 14:43 ` 1in.lang at seznam dot cz
  2020-12-07 14:48 ` simark at simark dot ca
  7 siblings, 0 replies; 9+ messages in thread
From: 1in.lang at seznam dot cz @ 2020-12-07 14:43 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=27006

--- Comment #5 from Stanislav Lang <1in.lang at seznam dot cz> ---
The simulator is a kind of adapter/wrapper over the library (for embedded
target) which adopt to make it run run on Windows. Therefore I attach directly
to the simulator (not to the gdb server). 

Anyway the explicit setting of the OS ABI using the command 'set osabi Cygwin'
has definitly helped.

Your explanation does make sense and from my point of view the bug entry could
be closed/canceled.

Stanislav

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug c++/27006] Segmentation fault when using gdb command 'call'
  2020-12-03 11:29 [Bug c++/27006] New: Segmentation fault when using gdb command 'call' 1in.lang at seznam dot cz
                   ` (6 preceding siblings ...)
  2020-12-07 14:43 ` 1in.lang at seznam dot cz
@ 2020-12-07 14:48 ` simark at simark dot ca
  7 siblings, 0 replies; 9+ messages in thread
From: simark at simark dot ca @ 2020-12-07 14:48 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=27006

Simon Marchi <simark at simark dot ca> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |NOTABUG
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #6 from Simon Marchi <simark at simark dot ca> ---
Ok, thanks.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

end of thread, other threads:[~2020-12-07 14:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-03 11:29 [Bug c++/27006] New: Segmentation fault when using gdb command 'call' 1in.lang at seznam dot cz
2020-12-03 13:35 ` [Bug c++/27006] " simark at simark dot ca
2020-12-03 16:34 ` ssbssa at sourceware dot org
2020-12-04 15:55 ` 1in.lang at seznam dot cz
2020-12-07 13:51 ` 1in.lang at seznam dot cz
2020-12-07 13:52 ` 1in.lang at seznam dot cz
2020-12-07 14:17 ` simark at simark dot ca
2020-12-07 14:43 ` 1in.lang at seznam dot cz
2020-12-07 14:48 ` simark at simark dot ca

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