public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/18168] New: "set write on" or "--write" corrupt the binary file
@ 2015-03-26 16:52 mail at cristos dot x25.pl
  2015-03-26 18:10 ` [Bug gdb/18168] " mail at cristos dot x25.pl
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: mail at cristos dot x25.pl @ 2015-03-26 16:52 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 18168
           Summary: "set write on" or "--write" corrupt the binary file
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: critical
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: mail at cristos dot x25.pl

Created attachment 8213
  --> https://sourceware.org/bugzilla/attachment.cgi?id=8213&action=edit
the hexdumps of a binary file before and after executing commands in the
description

When enabling binary patching via "set write on" command or "--write" command
line switch, the exectuable loaded becomes corrupted. Try executing:

$ gdb --write a_binary_file
(gdb)quit
# ./a_binary_file
bash: ./a_binary_file: cannot execute binary file: Exec format error

Careful examination of the binary shows this:
# file ./a_binary_file
a_binary_file: data

# readelf -a ./a_binary_file
readelf: Error: Not an ELF file - it has the wrong magic bytes at the start

Attached are the hexdumps of the files before and after executing "gdb --write"
and quitting gdb immediately

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


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

* [Bug gdb/18168] "set write on" or "--write" corrupt the binary file
  2015-03-26 16:52 [Bug gdb/18168] New: "set write on" or "--write" corrupt the binary file mail at cristos dot x25.pl
@ 2015-03-26 18:10 ` mail at cristos dot x25.pl
  2015-03-26 18:43 ` mail at cristos dot x25.pl
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: mail at cristos dot x25.pl @ 2015-03-26 18:10 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #1 from Krzysztof Majzerowicz-Jaszcz <mail at cristos dot x25.pl> ---
The bug exists on the latest HEAD
GNU gdb (GDB) 7.9.50.20150326-cvs

My environment:
$ uname -a
Linux tesla 3.19.2-1-ARCH #1 SMP PREEMPT Wed Mar 18 16:21:02 CET 2015 x86_64
GNU/Linux
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /build/gcc-multilib/src/gcc-4.9-20150304/configure
--prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared
--enable-threads=posix --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch
--disable-libssp --enable-gnu-unique-object --enable-linker-build-id
--enable-cloog-backend=isl --enable-lto --enable-plugin
--enable-install-libiberty --with-linker-hash-style=gnu --enable-multilib
--disable-werror --enable-checking=release
Thread model: posix
gcc version 4.9.2 20150304 (prerelease) (GCC)

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


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

* [Bug gdb/18168] "set write on" or "--write" corrupt the binary file
  2015-03-26 16:52 [Bug gdb/18168] New: "set write on" or "--write" corrupt the binary file mail at cristos dot x25.pl
  2015-03-26 18:10 ` [Bug gdb/18168] " mail at cristos dot x25.pl
@ 2015-03-26 18:43 ` mail at cristos dot x25.pl
  2015-07-26 20:34 ` jan.kratochvil at redhat dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: mail at cristos dot x25.pl @ 2015-03-26 18:43 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #2 from Krzysztof Majzerowicz-Jaszcz <mail at cristos dot x25.pl> ---
I can confirm that the bug does NOT exist on CentOS 7 - GDB version "GNU gdb
(GDB) Red Hat Enterprise Linux 7.6.1-51.el7"

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


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

* [Bug gdb/18168] "set write on" or "--write" corrupt the binary file
  2015-03-26 16:52 [Bug gdb/18168] New: "set write on" or "--write" corrupt the binary file mail at cristos dot x25.pl
  2015-03-26 18:10 ` [Bug gdb/18168] " mail at cristos dot x25.pl
  2015-03-26 18:43 ` mail at cristos dot x25.pl
@ 2015-07-26 20:34 ` jan.kratochvil at redhat dot com
  2015-07-27 16:30 ` [Bug gdb/18168] "set write on" or "--write" corrupt the binary file - 7.9 regression jan.kratochvil at redhat dot com
  2022-05-13 10:08 ` pedro at palves dot net
  4 siblings, 0 replies; 6+ messages in thread
From: jan.kratochvil at redhat dot com @ 2015-07-26 20:34 UTC (permalink / raw)
  To: gdb-prs

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

Jan Kratochvil <jan.kratochvil at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jan.kratochvil at redhat dot com

--- Comment #3 from Jan Kratochvil <jan.kratochvil at redhat dot com> ---
a485e98ea0cbb61ea9da1e7858da545e0bcf1a46 is the first bad commit
commit a485e98ea0cbb61ea9da1e7858da545e0bcf1a46
Author: Alan Modra <amodra@gmail.com>
Date:   Wed Sep 10 14:26:25 2014 +0930

    Move ELF section headers to end of object file

present first in gdb-7.9-branch

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


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

* [Bug gdb/18168] "set write on" or "--write" corrupt the binary file - 7.9 regression
  2015-03-26 16:52 [Bug gdb/18168] New: "set write on" or "--write" corrupt the binary file mail at cristos dot x25.pl
                   ` (2 preceding siblings ...)
  2015-07-26 20:34 ` jan.kratochvil at redhat dot com
@ 2015-07-27 16:30 ` jan.kratochvil at redhat dot com
  2022-05-13 10:08 ` pedro at palves dot net
  4 siblings, 0 replies; 6+ messages in thread
From: jan.kratochvil at redhat dot com @ 2015-07-27 16:30 UTC (permalink / raw)
  To: gdb-prs

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

Jan Kratochvil <jan.kratochvil at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|"set write on" or "--write" |"set write on" or "--write"
                   |corrupt the binary file     |corrupt the binary file -
                   |                            |7.9 regression

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


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

* [Bug gdb/18168] "set write on" or "--write" corrupt the binary file - 7.9 regression
  2015-03-26 16:52 [Bug gdb/18168] New: "set write on" or "--write" corrupt the binary file mail at cristos dot x25.pl
                   ` (3 preceding siblings ...)
  2015-07-27 16:30 ` [Bug gdb/18168] "set write on" or "--write" corrupt the binary file - 7.9 regression jan.kratochvil at redhat dot com
@ 2022-05-13 10:08 ` pedro at palves dot net
  4 siblings, 0 replies; 6+ messages in thread
From: pedro at palves dot net @ 2022-05-13 10:08 UTC (permalink / raw)
  To: gdb-prs

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

Pedro Alves <pedro at palves dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
                 CC|                            |pedro at palves dot net

--- Comment #4 from Pedro Alves <pedro at palves dot net> ---
This has been fixed since, probably by:

commit db72737006fc383cb8838bf7f3dc8e641e60c38f
Author:     Jozef Lawrynowicz <jozef.l@mittosystems.com>
AuthorDate: Tue Sep 11 22:56:36 2018 +0100
Commit:     Tom Tromey <tom@tromey.com>
CommitDate: Mon Sep 24 06:20:17 2018 -0600

    Fix PR gdb/20948: --write option to GDB causes segmentation fault

This commit adds a testcase that would fail if GDB still corrupted the binary:

commit 169692ce6c0fa21c4648d2862cb2bb94012a1cd9
Author:     Pedro Alves <pedro@palves.net>
AuthorDate: Wed May 11 14:20:15 2022 +0100
Commit:     Pedro Alves <pedro@palves.net>
CommitDate: Fri May 13 10:56:05 2022 +0100

    Fix "gdb --write" with core files


Closing.

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

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

end of thread, other threads:[~2022-05-13 10:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-26 16:52 [Bug gdb/18168] New: "set write on" or "--write" corrupt the binary file mail at cristos dot x25.pl
2015-03-26 18:10 ` [Bug gdb/18168] " mail at cristos dot x25.pl
2015-03-26 18:43 ` mail at cristos dot x25.pl
2015-07-26 20:34 ` jan.kratochvil at redhat dot com
2015-07-27 16:30 ` [Bug gdb/18168] "set write on" or "--write" corrupt the binary file - 7.9 regression jan.kratochvil at redhat dot com
2022-05-13 10:08 ` pedro at palves dot net

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