#990309 gdbserver: i386 (-m32) program on amd64 crashes while being debbugged

Package:
gdbserver
Source:
gdb
Description:
GNU Debugger (remote server)
Submitter:
Simon McVittie
Date:
2022-05-24 11:21:07 UTC
Severity:
important
Tags:
#990309#5
Date:
2021-06-25 10:27:10 UTC
From:
To:
When testing an i386 (-m32) program on an x86_64 host using gdbserver,
the program under test crashes with a segmentation fault.

Steps to reproduce:

$ cat > test.c
int main (void) { return 0; }
$ gcc -m32 -otest32 test.c
$ gdbserver localhost:12345 ./test32

and in another terminal

$ gdb -batch -q -ex "target remote localhost:12345" -ex continue

Expected result: test32 runs to completion

Actual result:

Program received signal SIGSEGV, Segmentation fault.
0xf7ddf3f7 in __ctype_init () from target:/lib/i386-linux-gnu/libc.so.6

This seems to be a known bug, fixed in
<https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff_plain;h=037e8112b9794a633248e5aa5943f3be273e0a20>,
as applied in e.g. Arch Linux's version of gdb 10.2. I'm waiting for a
backport of that change to compile locally so I can try it.

Thanks,
    smcv

#990309#10
Date:
2021-06-25 11:17:36 UTC
From:
To:
I confirm that the attached cherry-picks resolve this. Patch 0001
(whitespace change, originally part of a much larger commit) is just to
make patch 0002 apply cleanly; they could be turned into a single patch
if preferred.

    smcv

#990309#15
Date:
2021-06-25 17:50:11 UTC
From:
To:
Hello Simon,
I guess #982049 is about the same issue.
At least function name and address offset is equal.

Kind regards,
Bernhard

#990309#20
Date:
2022-05-24 11:10:37 UTC
From:
To:
Version: 11.2-1

Confirmed fixed in 11.2-1.

    smcv