Re: [PATCH 1/4] Add sniffer for Cygwin x86_64 core dumps

Simon Marchi
2020-08-20T22:20:11Z

On 2020-08-12 3:18 p.m., Jon Turney wrote:
> Similarly to existing i386_cygwin_core_osabi_sniffer()
>
> gdb/ChangeLog:
>
> 2020-07-01 Jon Turney <jon.turney@dronecode.org.uk>
>
> * amd64-windows-tdep.c (amd64_cygwin_core_osabi_sniffer): New.
> (_initialize_amd64_windows_tdep): Register amd64_cygwin_core_osabi_sniffer.

Hi Jon,

I am trying to test this using these steps:

1. Write a dummy C program that just sleeps in Cygwin, compile it (gcc test.c -g3 -O0) and run it
2. Run "dumper" on it
3. Load it in GDB (back on my amd64 Linux host)

I get this in step 3:

$ ./gdb --data-directory=data-directory -nx -q ~/a.exe
Reading symbols from /home/simark/a.exe...
(gdb) core ~/core.core
BFD: BFD (GNU Binutils) 2.35.50.20200820 internal error, aborting at /home/simark/src/binutils-gdb/bfd/bfd.c:1311 in _bfd_doprnt_scan

BFD: Please report this bug.

This happens while BFD encounters an error and tries to print this format string:

"%pB: win32pstatus NOTE_INFO_MODULE of size %lu is too small to contain a name of size %zu"

_bfd_doprnt_scan aborts because it doesn't like the z length modifier:

(top-gdb) p ptr[-1]
$2 = 122 'z'

So there are two issues here:

1. The actual error, the note being too small for the name. If I go up in
elfcore_grok_win32pstatus, the name_size doesn't make sense:

(top-gdb) p name_size
$9 = 4194304

whereas the note size makes sense:

(top-gdb) p note->descsz
$10 = 1276

2. The internal error from trying to print that error message

I realize this probably isn't caused by your patch at all but... I thought
you'd like to know about it anyway. I can provide more info for either if
needed.

Simon