public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Handle SIGSEGV in gdb selftests
@ 2022-12-15 21:14 Tom Tromey
  2022-12-16 15:17 ` Tom de Vries
  0 siblings, 1 reply; 8+ messages in thread
From: Tom Tromey @ 2022-12-15 21:14 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

The gdb.gdb self-tests were timing out for me.  Looking into it, the
problem is that the version of the Boehm GC that is used by Guile on
my machine causes a SEGV during stack probing.  This unexpected stop
confuses the tests and causes repeated timeouts.

This patch adapts the two failing tests.  This makes them work for me,
and reduces the running time of gdb.gdb from 20 minutes to about 11
seconds.
---
 gdb/testsuite/gdb.gdb/python-helper.exp | 6 ++++++
 gdb/testsuite/gdb.gdb/selftest.exp      | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/gdb/testsuite/gdb.gdb/python-helper.exp b/gdb/testsuite/gdb.gdb/python-helper.exp
index 3585ac9f0bf..fc52929489e 100644
--- a/gdb/testsuite/gdb.gdb/python-helper.exp
+++ b/gdb/testsuite/gdb.gdb/python-helper.exp
@@ -93,6 +93,12 @@ proc test_python_helper {} {
     # here.
     gdb_test_multiple "continue" "start inner gdb" {
 	-i "$inferior_spawn_id"
+	-re "received signal SIGSEGV.* in GC_.*$outer_prompt_re" {
+	    # Some versions of the GC used by Guile cause a SEGV
+	    # during stack probing.  Ignore this and carry on.
+	    send_gdb "continue\n"
+	    exp_continue
+	}
 	-re "\r\n$gdb_prompt $" {
 	    pass $gdb_test_name
 	}
diff --git a/gdb/testsuite/gdb.gdb/selftest.exp b/gdb/testsuite/gdb.gdb/selftest.exp
index ca1e7cffb4e..e2b9247f65d 100644
--- a/gdb/testsuite/gdb.gdb/selftest.exp
+++ b/gdb/testsuite/gdb.gdb/selftest.exp
@@ -75,6 +75,12 @@ proc test_with_self { } {
 	set test "xgdb is at prompt"
 	gdb_test_multiple "continue" $test {
 	    -i "$inferior_spawn_id"
+	    -re "received signal SIGSEGV.* in GC_.*$gdb_prompt" {
+		# Some versions of the GC used by Guile cause a SEGV
+		# during stack probing.  Ignore this and carry on.
+		send_gdb "continue\n"
+		exp_continue
+	    }
 	    -re "$banner" {
 		pass $test
 	    }
-- 
2.34.3


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

* Re: [PATCH] Handle SIGSEGV in gdb selftests
  2022-12-15 21:14 [PATCH] Handle SIGSEGV in gdb selftests Tom Tromey
@ 2022-12-16 15:17 ` Tom de Vries
  2022-12-16 16:11   ` Tom Tromey
  0 siblings, 1 reply; 8+ messages in thread
From: Tom de Vries @ 2022-12-16 15:17 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 12/15/22 22:14, Tom Tromey via Gdb-patches wrote:
> The gdb.gdb self-tests were timing out for me.  Looking into it, the
> problem is that the version of the Boehm GC that is used by Guile on
> my machine causes a SEGV during stack probing.  This unexpected stop
> confuses the tests and causes repeated timeouts.
> 

FWIW, that's https://sourceware.org/bugzilla/show_bug.cgi?id=29325 .

Thanks,
- Tom

> This patch adapts the two failing tests.  This makes them work for me,
> and reduces the running time of gdb.gdb from 20 minutes to about 11
> seconds.
> ---
>   gdb/testsuite/gdb.gdb/python-helper.exp | 6 ++++++
>   gdb/testsuite/gdb.gdb/selftest.exp      | 6 ++++++
>   2 files changed, 12 insertions(+)
> 
> diff --git a/gdb/testsuite/gdb.gdb/python-helper.exp b/gdb/testsuite/gdb.gdb/python-helper.exp
> index 3585ac9f0bf..fc52929489e 100644
> --- a/gdb/testsuite/gdb.gdb/python-helper.exp
> +++ b/gdb/testsuite/gdb.gdb/python-helper.exp
> @@ -93,6 +93,12 @@ proc test_python_helper {} {
>       # here.
>       gdb_test_multiple "continue" "start inner gdb" {
>   	-i "$inferior_spawn_id"
> +	-re "received signal SIGSEGV.* in GC_.*$outer_prompt_re" {
> +	    # Some versions of the GC used by Guile cause a SEGV
> +	    # during stack probing.  Ignore this and carry on.
> +	    send_gdb "continue\n"
> +	    exp_continue
> +	}
>   	-re "\r\n$gdb_prompt $" {
>   	    pass $gdb_test_name
>   	}
> diff --git a/gdb/testsuite/gdb.gdb/selftest.exp b/gdb/testsuite/gdb.gdb/selftest.exp
> index ca1e7cffb4e..e2b9247f65d 100644
> --- a/gdb/testsuite/gdb.gdb/selftest.exp
> +++ b/gdb/testsuite/gdb.gdb/selftest.exp
> @@ -75,6 +75,12 @@ proc test_with_self { } {
>   	set test "xgdb is at prompt"
>   	gdb_test_multiple "continue" $test {
>   	    -i "$inferior_spawn_id"
> +	    -re "received signal SIGSEGV.* in GC_.*$gdb_prompt" {
> +		# Some versions of the GC used by Guile cause a SEGV
> +		# during stack probing.  Ignore this and carry on.
> +		send_gdb "continue\n"
> +		exp_continue
> +	    }
>   	    -re "$banner" {
>   		pass $test
>   	    }

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

* Re: [PATCH] Handle SIGSEGV in gdb selftests
  2022-12-16 15:17 ` Tom de Vries
@ 2022-12-16 16:11   ` Tom Tromey
  2022-12-26  8:02     ` tdevries
  0 siblings, 1 reply; 8+ messages in thread
From: Tom Tromey @ 2022-12-16 16:11 UTC (permalink / raw)
  To: Tom de Vries; +Cc: Tom Tromey, gdb-patches

>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:

Tom> On 12/15/22 22:14, Tom Tromey via Gdb-patches wrote:
>> The gdb.gdb self-tests were timing out for me.  Looking into it, the
>> problem is that the version of the Boehm GC that is used by Guile on
>> my machine causes a SEGV during stack probing.  This unexpected stop
>> confuses the tests and causes repeated timeouts.
>> 

Tom> FWIW, that's https://sourceware.org/bugzilla/show_bug.cgi?id=29325 .

Thanks, I updated the commit message.

Tom

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

* Re: [PATCH] Handle SIGSEGV in gdb selftests
  2022-12-16 16:11   ` Tom Tromey
@ 2022-12-26  8:02     ` tdevries
  2023-01-14  1:11       ` Simon Marchi
  0 siblings, 1 reply; 8+ messages in thread
From: tdevries @ 2022-12-26  8:02 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 2022-12-16 16:11, Tom Tromey via Gdb-patches wrote:
>>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
> 
> Tom> On 12/15/22 22:14, Tom Tromey via Gdb-patches wrote:
>>> The gdb.gdb self-tests were timing out for me.  Looking into it, the
>>> problem is that the version of the Boehm GC that is used by Guile on
>>> my machine causes a SEGV during stack probing.  This unexpected stop
>>> confuses the tests and causes repeated timeouts.
>>> 
> 
> Tom> FWIW, that's https://sourceware.org/bugzilla/show_bug.cgi?id=29325 
> .
> 
> Thanks, I updated the commit message.

I ran into this again, tried out the patch and checked that it fixes the 
problem.

LGTM.

Thanks,
- Tom

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

* Re: [PATCH] Handle SIGSEGV in gdb selftests
  2022-12-26  8:02     ` tdevries
@ 2023-01-14  1:11       ` Simon Marchi
  2023-01-14  1:19         ` Simon Marchi
  0 siblings, 1 reply; 8+ messages in thread
From: Simon Marchi @ 2023-01-14  1:11 UTC (permalink / raw)
  To: tdevries, Tom Tromey; +Cc: gdb-patches



On 12/26/22 03:02, tdevries via Gdb-patches wrote:
> On 2022-12-16 16:11, Tom Tromey via Gdb-patches wrote:
>>>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
>>
>> Tom> On 12/15/22 22:14, Tom Tromey via Gdb-patches wrote:
>>>> The gdb.gdb self-tests were timing out for me.  Looking into it, the
>>>> problem is that the version of the Boehm GC that is used by Guile on
>>>> my machine causes a SEGV during stack probing.  This unexpected stop
>>>> confuses the tests and causes repeated timeouts.
>>>>
>>
>> Tom> FWIW, that's https://sourceware.org/bugzilla/show_bug.cgi?id=29325 .
>>
>> Thanks, I updated the commit message.
> 
> I ran into this again, tried out the patch and checked that it fixes the problem.
> 
> LGTM.
> 
> Thanks,
> - Tom

Hi both Toms,

I still see the issue on Ubuntu 22.04, when testing with the
native-extended-gdbserver board:

...
Thread 1 "xgdb" received signal SIGSEGV, Segmentation fault.
0x00007ffff6d828f2 in GC_find_limit_with_bound () from /usr/lib/x86_64-linux-gnu/libgc.so.1
(gdb) FAIL: gdb.gdb/selftest.exp: xgdb is at prompt

The modified code looks like this:


        set test "xgdb is at prompt"
        gdb_test_multiple "continue" $test {
            -i "$inferior_spawn_id"
            -re "received signal SIGSEGV.* in GC_.*$gdb_prompt" {
                # Some versions of the GC used by Guile cause a SEGV
                # during stack probing.  Ignore this and carry on.
                send_gdb "continue\n"
                exp_continue
            }
            -re "$banner" {
                pass $test
            }
        }

Shouldn't the SIGSEGV -re be before the `-i $inferior_spawn_id`?
Otherwise we expect the "received signal SIGSEGV" message to come from
the debugged GDB, when it's the top GDB that will print it (like when
debugging any other test program).

I think we don't see the problem when testing with native because
the top and bottom GDBs share the same spawn id.

Simon

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

* Re: [PATCH] Handle SIGSEGV in gdb selftests
  2023-01-14  1:11       ` Simon Marchi
@ 2023-01-14  1:19         ` Simon Marchi
  2023-01-17 16:20           ` Tom Tromey
  0 siblings, 1 reply; 8+ messages in thread
From: Simon Marchi @ 2023-01-14  1:19 UTC (permalink / raw)
  To: tdevries, Tom Tromey; +Cc: gdb-patches



On 1/13/23 20:11, Simon Marchi via Gdb-patches wrote:
> 
> 
> On 12/26/22 03:02, tdevries via Gdb-patches wrote:
>> On 2022-12-16 16:11, Tom Tromey via Gdb-patches wrote:
>>>>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
>>>
>>> Tom> On 12/15/22 22:14, Tom Tromey via Gdb-patches wrote:
>>>>> The gdb.gdb self-tests were timing out for me.  Looking into it, the
>>>>> problem is that the version of the Boehm GC that is used by Guile on
>>>>> my machine causes a SEGV during stack probing.  This unexpected stop
>>>>> confuses the tests and causes repeated timeouts.
>>>>>
>>>
>>> Tom> FWIW, that's https://sourceware.org/bugzilla/show_bug.cgi?id=29325 .
>>>
>>> Thanks, I updated the commit message.
>>
>> I ran into this again, tried out the patch and checked that it fixes the problem.
>>
>> LGTM.
>>
>> Thanks,
>> - Tom
> 
> Hi both Toms,
> 
> I still see the issue on Ubuntu 22.04, when testing with the
> native-extended-gdbserver board:
> 
> ...
> Thread 1 "xgdb" received signal SIGSEGV, Segmentation fault.
> 0x00007ffff6d828f2 in GC_find_limit_with_bound () from /usr/lib/x86_64-linux-gnu/libgc.so.1
> (gdb) FAIL: gdb.gdb/selftest.exp: xgdb is at prompt
> 
> The modified code looks like this:
> 
> 
>         set test "xgdb is at prompt"
>         gdb_test_multiple "continue" $test {
>             -i "$inferior_spawn_id"
>             -re "received signal SIGSEGV.* in GC_.*$gdb_prompt" {
>                 # Some versions of the GC used by Guile cause a SEGV
>                 # during stack probing.  Ignore this and carry on.
>                 send_gdb "continue\n"
>                 exp_continue
>             }
>             -re "$banner" {
>                 pass $test
>             }
>         }
> 
> Shouldn't the SIGSEGV -re be before the `-i $inferior_spawn_id`?
> Otherwise we expect the "received signal SIGSEGV" message to come from
> the debugged GDB, when it's the top GDB that will print it (like when
> debugging any other test program).
> 
> I think we don't see the problem when testing with native because
> the top and bottom GDBs share the same spawn id.
> 
> Simon


Here's a patch to fix it, with a commit message.


From f2d47cdd63ea9abddabdccd8097b2a6e7d1e64b1 Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@efficios.com>
Date: Fri, 13 Jan 2023 20:08:41 -0500
Subject: [PATCH] gdb/testsuite: expect SIGSEGV from top GDB spawn id

When testing with the native-extended-gdbserver, I get:

    Thread 1 "xgdb" received signal SIGSEGV, Segmentation fault.
    0x00007ffff6d828f2 in GC_find_limit_with_bound () from /usr/lib/x86_64-linux-gnu/libgc.so.1
    (gdb) FAIL: gdb.gdb/selftest.exp: xgdb is at prompt

This is because the -re that is supposed to match this SIGSEGV is after
`-i $inferior_spawn_id`.  On native, the top and bottom GDB are on the
same spawn id, so it ends up working.  But with a gdbserver board,
that's not the case.  Move the SIGSEGV -re before the `-i
$inferior_spawn_id` line, such that it matches what the top GDB outputs.

Do the same fix in gdb.gdb/python-helper.exp.

Change-Id: I3291630e218a5a3a6a47805b999ddbc9b968c927
---
 gdb/testsuite/gdb.gdb/python-helper.exp | 2 +-
 gdb/testsuite/gdb.gdb/selftest.exp      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/gdb.gdb/python-helper.exp b/gdb/testsuite/gdb.gdb/python-helper.exp
index c147c6bcbb03..98f03ef456f3 100644
--- a/gdb/testsuite/gdb.gdb/python-helper.exp
+++ b/gdb/testsuite/gdb.gdb/python-helper.exp
@@ -86,13 +86,13 @@ proc test_python_helper {} {
     # stop is being detected from the inner GDB, hence the use of -i
     # here.
     gdb_test_multiple "continue" "start inner gdb" {
-	-i "$inferior_spawn_id"
 	-re "received signal SIGSEGV.* in GC_.*$outer_prompt_re" {
 	    # Some versions of the GC used by Guile cause a SEGV
 	    # during stack probing.  Ignore this and carry on.
 	    send_gdb "continue\n"
 	    exp_continue
 	}
+	-i "$inferior_spawn_id"
 	-re "\r\n$gdb_prompt $" {
 	    pass $gdb_test_name
 	}
diff --git a/gdb/testsuite/gdb.gdb/selftest.exp b/gdb/testsuite/gdb.gdb/selftest.exp
index 177c29fb224d..df12602b64bb 100644
--- a/gdb/testsuite/gdb.gdb/selftest.exp
+++ b/gdb/testsuite/gdb.gdb/selftest.exp
@@ -74,13 +74,13 @@ proc test_with_self { } {
 			"$gdb_prompt $"]
 	set test "xgdb is at prompt"
 	gdb_test_multiple "continue" $test {
-	    -i "$inferior_spawn_id"
 	    -re "received signal SIGSEGV.* in GC_.*$gdb_prompt" {
 		# Some versions of the GC used by Guile cause a SEGV
 		# during stack probing.  Ignore this and carry on.
 		send_gdb "continue\n"
 		exp_continue
 	    }
+	    -i "$inferior_spawn_id"
 	    -re "$banner" {
 		pass $test
 	    }

base-commit: 325ab797da3b71e03eba184930f08ee3179a30d6
-- 
2.39.0


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

* Re: [PATCH] Handle SIGSEGV in gdb selftests
  2023-01-14  1:19         ` Simon Marchi
@ 2023-01-17 16:20           ` Tom Tromey
  2023-01-17 16:22             ` Simon Marchi
  0 siblings, 1 reply; 8+ messages in thread
From: Tom Tromey @ 2023-01-17 16:20 UTC (permalink / raw)
  To: Simon Marchi; +Cc: tdevries, Tom Tromey, gdb-patches

>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:

>> Shouldn't the SIGSEGV -re be before the `-i $inferior_spawn_id`?
>> Otherwise we expect the "received signal SIGSEGV" message to come from
>> the debugged GDB, when it's the top GDB that will print it (like when
>> debugging any other test program).
>> 
>> I think we don't see the problem when testing with native because
>> the top and bottom GDBs share the same spawn id.

Makes sense to me.

Simon> Here's a patch to fix it, with a commit message.

Looks good to me.

Tom

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

* Re: [PATCH] Handle SIGSEGV in gdb selftests
  2023-01-17 16:20           ` Tom Tromey
@ 2023-01-17 16:22             ` Simon Marchi
  0 siblings, 0 replies; 8+ messages in thread
From: Simon Marchi @ 2023-01-17 16:22 UTC (permalink / raw)
  To: Tom Tromey; +Cc: tdevries, gdb-patches

On 1/17/23 11:20, Tom Tromey wrote:
>>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:
> 
>>> Shouldn't the SIGSEGV -re be before the `-i $inferior_spawn_id`?
>>> Otherwise we expect the "received signal SIGSEGV" message to come from
>>> the debugged GDB, when it's the top GDB that will print it (like when
>>> debugging any other test program).
>>>
>>> I think we don't see the problem when testing with native because
>>> the top and bottom GDBs share the same spawn id.
> 
> Makes sense to me.
> 
> Simon> Here's a patch to fix it, with a commit message.
> 
> Looks good to me.
> 
> Tom

Thanks, pushed.

Simon

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

end of thread, other threads:[~2023-01-17 16:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-15 21:14 [PATCH] Handle SIGSEGV in gdb selftests Tom Tromey
2022-12-16 15:17 ` Tom de Vries
2022-12-16 16:11   ` Tom Tromey
2022-12-26  8:02     ` tdevries
2023-01-14  1:11       ` Simon Marchi
2023-01-14  1:19         ` Simon Marchi
2023-01-17 16:20           ` Tom Tromey
2023-01-17 16:22             ` Simon Marchi

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