[go: nahoru, domu]

Bug 31128 - gdb crashes when trying to print a global variable stub without a running inferior
Summary: gdb crashes when trying to print a global variable stub without a running inf...
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: c++ (show other bugs)
Version: 14.1
: P2 normal
Target Milestone: 14.2
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 31226 31560 (view as bug list)
Depends on:
Blocks:
 
Reported: 2023-12-08 18:03 UTC by Hannes Domani
Modified: 2024-03-29 08:00 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hannes Domani 2023-12-08 18:03:34 UTC
It can be reproduced with this source:
```
struct S
{
  S (int);
  virtual ~S ();

  int m_i;
};

S s (5);

int main ()
{
  return 0;
}
```

And then just debugging the compiled object file:
```
$ g++ -g -c print-global-stub.cc
$ gdb -q print-global-stub.o
Reading symbols from print-global-stub.o...
(gdb) p s

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
```
Comment 1 Sourceware Commits 2023-12-08 18:08:18 UTC
The master branch has been updated by Hannes Domani <ssbssa@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=576745e26c0ec76a53ba45b20af464628a50b3e4

commit 576745e26c0ec76a53ba45b20af464628a50b3e4
Author: Hannes Domani <ssbssa@yahoo.de>
Date:   Fri Dec 8 19:06:14 2023 +0100

    Fix printing of global variable stubs if no inferior is running
    
    Since 3c45e9f915ae4aeab7312d6fc55a947859057572 gdb crashes when trying
    to print a global variable stub without a running inferior, because of
    a missing nullptr-check (the block_scope function took care of that
    check before it was converted to a method).
    
    With this check it works again:
    ```
    (gdb) print s
    $1 = <incomplete type>
    ```
    
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31128
    Approved-By: Tom Tromey <tom@tromey.com>
Comment 2 Sourceware Commits 2023-12-08 18:10:23 UTC
The gdb-14-branch branch has been updated by Hannes Domani <ssbssa@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=bc23ea51f8a83e9524dfb553baa8baacb29e68a9

commit bc23ea51f8a83e9524dfb553baa8baacb29e68a9
Author: Hannes Domani <ssbssa@yahoo.de>
Date:   Fri Dec 8 19:06:14 2023 +0100

    Fix printing of global variable stubs if no inferior is running
    
    Since 3c45e9f915ae4aeab7312d6fc55a947859057572 gdb crashes when trying
    to print a global variable stub without a running inferior, because of
    a missing nullptr-check (the block_scope function took care of that
    check before it was converted to a method).
    
    With this check it works again:
    ```
    (gdb) print s
    $1 = <incomplete type>
    ```
    
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31128
    Approved-By: Tom Tromey <tom@tromey.com>
    (cherry picked from commit 576745e26c0ec76a53ba45b20af464628a50b3e4)
Comment 3 Hannes Domani 2023-12-08 18:11:03 UTC
Fixed.
Comment 4 Hannes Domani 2024-01-10 14:54:20 UTC
*** Bug 31226 has been marked as a duplicate of this bug. ***
Comment 5 Andy Wingo 2024-03-29 08:00:42 UTC
*** Bug 31560 has been marked as a duplicate of this bug. ***