Bug 20501 - Creating NSString convenience variable crashes GDB
Summary: Creating NSString convenience variable crashes GDB
Status: UNCONFIRMED
Alias: None
Product: gdb
Classification: Unclassified
Component: objc (show other bugs)
Version: 7.11.1
: P1 critical
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-22 10:19 UTC by Giah de Barag
Modified: 2016-09-13 21:35 UTC (History)
1 user (show)

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


Attachments
source and makefile, backtrace, and GNUstep install instructions (3.96 KB, application/zip)
2016-08-22 10:19 UTC, Giah de Barag
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Giah de Barag 2016-08-22 10:19:12 UTC
Created attachment 9466 [details]
source and makefile, backtrace, and GNUstep install instructions

Component: GDB (7.11.1)
OS: Windows Server (2008 R2) + MINGW32 (20160205)
Language: Objective C + GNUstep

Summary:
Creating an NSString convenience variable crashes GDB.
Creating a C string convenience variable causes an error.

Steps to Reproduce:
Create the simplest imaginable GNUstep tool and build it and gdb it.
(gdb) b main
(gdb) r
(gdb) p $a = "foo"            # char * convenience var
$3 = <error reading variable> # unexpected, instead of "foo"
(gdb) set $b = @"bar"         # NSString convenience var
Segmentation fault            # unexpected, instead of @"bar"
Debugger exited abnormally with code 5

Observation: strdata=0, len=99243256 at memcpy in write_exp_string at parse.c:372

Attachments: backtrace.txt, mytool.m, GNUmakefile, gnustep-install.txt
Comment 1 Giah de Barag 2016-08-22 10:32:27 UTC
IMPORTANT:

Just realized: you do not need GNUstep to reproduce the problem.

Steps to Reproduce:

% gdb -nx
(gdb) set lang objective-c
(gdb) p "foo"
$1 = <error reading variable> # error reading a c string
(gdb) p @"foo"                # crash reading an NSString
Comment 2 Giah de Barag 2016-08-22 10:40:26 UTC
I just confirmed that this bug is also in 64bit GDB 7.6.1 on Linux:

% gdb -nx
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-80.el7
Copyright (C) 2013 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 "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) set lang objective-c 
(gdb) p "foo"
$1 = <error reading variable>
(gdb) p @"foo"
Segmentation fault (core dumped)
Comment 3 Giah de Barag 2016-08-22 11:25:58 UTC
GNU gdb 6.8 i686-pc-mingw32 .................... does not have the bug
GNU gdb 7.3.1 mingw32 .......................... does not have the bug
GNU gdb 7.6.1-80.el7 x86_64-redhat-linux-gnu ... has the bug
GNU gdb 7.11.1 i686-w64-mingw32 ................ has the bug
GNU gdb 7.11.1 x86_64-w64-mingw32 .............. has the bug
Comment 4 Giah de Barag 2016-09-13 21:35:48 UTC
This bug has been completely fixed by this patch:

https://sourceware.org/ml/gdb-patches/2016-09/msg00100.html