This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug breakpoints/22461] New: breakpoint after mprotect


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

            Bug ID: 22461
           Summary: breakpoint after mprotect
           Product: gdb
           Version: 8.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: breakpoints
          Assignee: unassigned at sourceware dot org
          Reporter: sebastien15753 at gmail dot com
  Target Milestone: ---

Created attachment 10622
  --> https://sourceware.org/bugzilla/attachment.cgi?id=10622&action=edit
code that induce the bug

I built a shared library (.so) and a binary that use this library.

The binary results in the compilation of main.c (in attachment) and is mapped
from 0x555555554000 to 0x555555555000.

The library results in the compilation of perso.c(in attachment) and is mapped
from 0x7ffff7bd6000 to 7ffff7bd7000.

The main() function simply call a function in that library.
The function in the library remove the PROT_EXEC flag of the range
0x555555554000 to 0x555555555000 where is mapped the binary, execute another
function called `myfunction` in the same library and restore the PROT_EXEC flag
of the range 0x555555554000 to 0x555555555000.

Executing it inside gdb with no breakpoints works fine.
The bug is, if I set a breakpoint at myfunction() and execute it I have a
SIGSEGV signal.

One can reproduce the bug by downloading the attached files and compile by
using the Makefile. 
gdb commands for reproduction are :

    $ gdb binary
    (gdb) b main
    (gdb) r
    (gdb) b myfunction
    (gdb) c
    (gdb) si #SIGSEGV

An example is done in attachment as a screenshot. 

Some other useful information :

    [seb@archlinux code]$ uname -a
    Linux archlinux 4.13.12-1-ARCH #1 SMP PREEMPT Wed Nov 8 11:54:06 CET 2017
x86_64 GNU/Linux

    [seb@archlinux code]$ gcc -v
Utilisation des specs internes.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/lto-wrapper
Cible : x86_64-pc-linux-gnu
Configuré avec: /build/gcc/src/gcc/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 --enable-libmpx --with-system-zlib --with-isl
--enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu
--disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object
--enable-linker-build-id --enable-lto --enable-plugin
--enable-install-libiberty --with-linker-hash-style=gnu
--enable-gnu-indirect-function --disable-multilib --disable-werror
--enable-checking=release --enable-default-pie --enable-default-ssp
Modèle de thread: posix
gcc version 7.2.0 (GCC) 


    [seb@archlinux code]$ gdb -v
GNU gdb (GDB) 8.0.1
Copyright (C) 2017 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-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".

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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]