Bug 22046 - Regression on older kernels for T (stopped) processes
Summary: Regression on older kernels for T (stopped) processes
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: 8.0
: P2 normal
Target Milestone: 8.0.1
Assignee: Jan Kratochvil
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-30 19:12 UTC by Jan Kratochvil
Modified: 2017-09-01 04:23 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Kratochvil 2017-08-30 19:12:26 UTC
On <=RHEL6 hosts Fedora/RHEL GDB started to 'kill -STOP' all processes it detached.  Even those not originally T-stopped.  This is a Fedora-specific patch which is based on upstream GDB's PROC_STATE_STOPPED state.

I believe (I did not verify) this patch did regress it:
commit d617208bb06bd461b52ce041d89f7127e3044762
Author: Pedro Alves <palves@redhat.com>
Date:   Mon Jul 25 12:42:17 2016 +0100   
    linux-procfs: Introduce enum proc_state

As originally there was strstr() but now there is strcmp() and so the missing trailing '\n' no longer matches.

The Bug was found by Michal Kolar.

Reproducibility:
$ gdb -p $PID
(gdb) quit
$ ...

Actual results:
===
RHEL6.9 x86_64 # scl enable devtoolset-7 bash
RHEL6.9 x86_64 # which gdb
/opt/rh/devtoolset-7/root/usr/bin/gdb
RHEL6.9 x86_64 # ./testcase.sh
24737 pts/0    S+     0:00 /bin/sleep 4
24737 pts/0    T+     0:00 /bin/sleep 4
RHEL6.9 x86_64 #
===

Expected results:
===
RHEL6.9 x86_64 # which gdb
/usr/bin/gdb
RHEL6.9 x86_64 # ./testcase.sh
24708 pts/0    S+     0:00 /bin/sleep 4
24708 pts/0    S+     0:00 /bin/sleep 4
./testcase.sh: line 20: kill: (24708) - No such process
RHEL6.9 x86_64 #
===

Tested: 5b86dbf4549af98c4428da4764182e03f22c58ab
Comment 1 Jan Kratochvil 2017-08-30 19:14:47 UTC
[patch+8.0.1] Fix T-stopped detach regression on old kernels
https://sourceware.org/ml/gdb-patches/2017-08/msg00532.html
Comment 2 cvs-commit@gcc.gnu.org 2017-09-01 04:17:04 UTC
The master branch has been updated by Jan Kratochvil <jkratoch@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5c811d30d12b6f7c6c6f4ce6d03408d987154548

commit 5c811d30d12b6f7c6c6f4ce6d03408d987154548
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Fri Sep 1 06:13:40 2017 +0200

    PR gdb/22046: Fix T-stopped detach regression on old Linux kernels
    
    On <=RHEL6 hosts Fedora/RHEL GDB started to 'kill -STOP' all processes it
    detached.  Even those not originally T-stopped.  This is a Fedora-specific
    patch which is based on upstream GDB's PROC_STATE_STOPPED state.
    
    I believe (I did not verify) this patch did regress it:
    commit d617208bb06bd461b52ce041d89f7127e3044762
    Author: Pedro Alves <palves@redhat.com>
    Date:   Mon Jul 25 12:42:17 2016 +0100
        linux-procfs: Introduce enum proc_state
    
    As originally there was strstr() but now there is strcmp() and so the missing
    trailing '\n' no longer matches.
    
    The Bug was found by Michal Kolar.
    
    Reproducibility:
    $ gdb -p $PID
    (gdb) quit
    $ ...
    
    Actual results:
    ===
    RHEL6.9 x86_64 # scl enable devtoolset-7 bash
    RHEL6.9 x86_64 # which gdb
    /opt/rh/devtoolset-7/root/usr/bin/gdb
    RHEL6.9 x86_64 # ./testcase.sh
    24737 pts/0    S+     0:00 /bin/sleep 4
    24737 pts/0    T+     0:00 /bin/sleep 4
    RHEL6.9 x86_64 #
    ===
    
    Expected results:
    ===
    RHEL6.9 x86_64 # which gdb
    /usr/bin/gdb
    RHEL6.9 x86_64 # ./testcase.sh
    24708 pts/0    S+     0:00 /bin/sleep 4
    24708 pts/0    S+     0:00 /bin/sleep 4
    ./testcase.sh: line 20: kill: (24708) - No such process
    RHEL6.9 x86_64 #
    ===
    
    gdb/ChangeLog
    2017-09-01  Jan Kratochvil  <jan.kratochvil@redhat.com>
    
    	PR gdb/22046
    	* nat/linux-procfs.c (parse_proc_status_state): Fix PROC_STATE_STOPPED
    	detection.
Comment 3 cvs-commit@gcc.gnu.org 2017-09-01 04:19:39 UTC
The gdb-8.0-branch branch has been updated by Jan Kratochvil <jkratoch@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c247e38d78a98f85066e4a61032ee742d08a0579

commit c247e38d78a98f85066e4a61032ee742d08a0579
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Fri Sep 1 06:13:40 2017 +0200

    PR gdb/22046: Fix T-stopped detach regression on old Linux kernels
    
    On <=RHEL6 hosts Fedora/RHEL GDB started to 'kill -STOP' all processes it
    detached.  Even those not originally T-stopped.  This is a Fedora-specific
    patch which is based on upstream GDB's PROC_STATE_STOPPED state.
    
    I believe (I did not verify) this patch did regress it:
    commit d617208bb06bd461b52ce041d89f7127e3044762
    Author: Pedro Alves <palves@redhat.com>
    Date:   Mon Jul 25 12:42:17 2016 +0100
        linux-procfs: Introduce enum proc_state
    
    As originally there was strstr() but now there is strcmp() and so the missing
    trailing '\n' no longer matches.
    
    The Bug was found by Michal Kolar.
    
    Reproducibility:
    $ gdb -p $PID
    (gdb) quit
    $ ...
    
    Actual results:
    ===
    RHEL6.9 x86_64 # scl enable devtoolset-7 bash
    RHEL6.9 x86_64 # which gdb
    /opt/rh/devtoolset-7/root/usr/bin/gdb
    RHEL6.9 x86_64 # ./testcase.sh
    24737 pts/0    S+     0:00 /bin/sleep 4
    24737 pts/0    T+     0:00 /bin/sleep 4
    RHEL6.9 x86_64 #
    ===
    
    Expected results:
    ===
    RHEL6.9 x86_64 # which gdb
    /usr/bin/gdb
    RHEL6.9 x86_64 # ./testcase.sh
    24708 pts/0    S+     0:00 /bin/sleep 4
    24708 pts/0    S+     0:00 /bin/sleep 4
    ./testcase.sh: line 20: kill: (24708) - No such process
    RHEL6.9 x86_64 #
    ===
    
    gdb/ChangeLog
    2017-09-01  Jan Kratochvil  <jan.kratochvil@redhat.com>
    
    	PR gdb/22046
    	* nat/linux-procfs.c (parse_proc_status_state): Fix PROC_STATE_STOPPED
    	detection.
Comment 4 Jan Kratochvil 2017-09-01 04:23:49 UTC
Fixed.