gdb/2110: Segmentation fault when attaching to a process of a C program

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

gdb/2110: Segmentation fault when attaching to a process of a C program

phydthekid

>Number:         2110
>Category:       gdb
>Synopsis:       Segmentation fault when attaching to a process of a C program
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Apr 06 14:58:01 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator:     fork_debug.c attached
>Release:        unknown-1.0
>Organization:
>Environment:
Ubuntu 64-bit Breezy Badger 5.10
>Description:
When I try to send a signal SIGUSR1 to my process to which I'm attached, gdb goes SEG fault and eveything crashes
>How-To-Repeat:
gcc -g fork_debug.c -o something
run something in a shell
open another shell
gdb attach (pid of one child, read output of something)
b 64
signal SIGUSR1
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/x-csrc; name="fork_debug.c"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="fork_debug.c"

Ly8gTWFyaW8gUGlzc2FyZG8gZSBZdm9ubmUgQ2FycGVnbmEKLy8gQmFydG9sb21lbyBNb250cnVj
Y2hpbwovLyBFc2VyY2l6aW8gNSBkZWxsYSBwcmltYSBlc2VyY2l0YXppb25lIG1vZGlmaWNhdG8K
Ly8gcGVyIGlsbHVzdHJhcmUgaWwgZGVidWcgZGkgcHJvY2Vzc2kgY29uY29ycmVudGkgY29uIGls
IGdkYgovLyAyOSBmZWJicmFpbyAyMDA0CgojaW5jbHVkZSA8c3lzL3R5cGVzLmg+CiNpbmNsdWRl
IDxzeXMvd2FpdC5oPgojaW5jbHVkZSA8c3RkaW8uaD4KI2luY2x1ZGUgPHN5cy9zdGF0Lmg+CiNp
bmNsdWRlIDxmY250bC5oPgojaW5jbHVkZSA8c2lnbmFsLmg+CiNpbmNsdWRlIDx1bmlzdGQuaD4K
CiNkZWZpbmUgREVCVUcKCiNp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