public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2] gdb/testsuite: Fix race in gdb.dwarf2/calling-convention.exp
@ 2022-03-31 11:12 Lancelot SIX
  2022-04-01  9:11 ` Pedro Alves
  0 siblings, 1 reply; 5+ messages in thread
From: Lancelot SIX @ 2022-03-31 11:12 UTC (permalink / raw)
  To: gdb-patches; +Cc: lsix, pedro, Lancelot SIX

Hi,

Here is a V2 for [1] based on Pedro's input.

Changes since V1:

- Use gdb_test to handle the question/response exchange with GDB instead
  of gdb_test_multiple.
- Improve the question regex.
- Added Pedro as co-author since the new patch is basically what he
  proposed in the review.

Best,
Lancelot.

[1] https://sourceware.org/pipermail/gdb-patches/2022-March/187114.html

---

Pedro Alves warned me that there is a race in
gdb.dwarf2/calling-convention.exp making the test sometimes fail on his
setup.  This can be reliably reproduced using :

    make check-read1 TESTS="gdb.dwarf2/calling-convention.exp"

The relevant part of the gdb.log file is:

    return 35
    Function 'foo' does not follow the target calling convention.
    If you continue, setting the return value will probably lead to unpredictable behaviors.
    Make foo return now? (y or n) PASS: gdb.dwarf2/calling-convention.exp: return 35
    n
    Not confirmed
    (gdb) FAIL: gdb.dwarf2/calling-convention.exp: finish

The issue is that when doing the test for "return 35", the DejaGnu test
sends "n" (to tell GDB not to perform the return action) but never
consumes the "Not confirmed" acknowledgment sent by GDB.  Later, when
trying to do the next test, DejaGnu tries to match the leftover output
from the "return" test. As this output is not expected, the test fails.

Fix by using gdb_test since it is able to handle the question-answer
dance with GDB and do the proper validation.

Tested on x86_64-gnu-linux, using

- make check TESTS="gdb.dwarf2/calling-convention.exp"
- make check-read1 TESTS="gdb.dwarf2/calling-convention.exp"

Co-authored-by: Pedro Alves <pedro@palves.net>
Change-Id: I42858b13db2cbd623c5c1739de65ad423e0c0938
---
 gdb/testsuite/gdb.dwarf2/calling-convention.exp | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/gdb/testsuite/gdb.dwarf2/calling-convention.exp b/gdb/testsuite/gdb.dwarf2/calling-convention.exp
index 0a11cb15c68..f1422ff9a98 100644
--- a/gdb/testsuite/gdb.dwarf2/calling-convention.exp
+++ b/gdb/testsuite/gdb.dwarf2/calling-convention.exp
@@ -83,12 +83,14 @@ gdb_test "call foo ()" \
 gdb_breakpoint "foo"
 gdb_continue_to_breakpoint "foo"
 
-gdb_test_multiple "return 35" "" {
-    -re ".*Function 'foo' does not follow the target calling convention.\r\nIf you continue, setting the return value will probably lead to unpredictable behaviors.\r\nMake foo return now?.*\\(y or n\\) $" {
-	send_gdb "n\n"
-	pass $gdb_test_name
-    }
-}
+gdb_test "return 35" \
+       "Not confirmed" \
+       "return 35" \
+       [multi_line \
+           "Function 'foo' does not follow the target calling convention." \
+           "If you continue, setting the return value will probably lead to unpredictable behaviors." \
+           "Make foo return now\\? \\(y or n\\) $"] \
+       "n"
 
 gdb_test "finish" [multi_line \
     "Run till exit from #0  $hex in foo \\(\\)" \

base-commit: 5530c021ce01abf368a9cde26b22c4b34f320ee8
-- 
2.25.1


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

* Re: [PATCH v2] gdb/testsuite: Fix race in gdb.dwarf2/calling-convention.exp
  2022-03-31 11:12 [PATCH v2] gdb/testsuite: Fix race in gdb.dwarf2/calling-convention.exp Lancelot SIX
@ 2022-04-01  9:11 ` Pedro Alves
  2022-04-01  9:51   ` Lancelot SIX
  2022-04-14 12:36   ` Tom de Vries
  0 siblings, 2 replies; 5+ messages in thread
From: Pedro Alves @ 2022-04-01  9:11 UTC (permalink / raw)
  To: Lancelot SIX, gdb-patches; +Cc: lsix

On 2022-03-31 12:12, Lancelot SIX wrote:

> Pedro Alves warned me that there is a race in
> gdb.dwarf2/calling-convention.exp making the test sometimes fail on his
> setup.  This can be reliably reproduced using :
> 
>     make check-read1 TESTS="gdb.dwarf2/calling-convention.exp"
> 
> The relevant part of the gdb.log file is:
> 
>     return 35
>     Function 'foo' does not follow the target calling convention.
>     If you continue, setting the return value will probably lead to unpredictable behaviors.
>     Make foo return now? (y or n) PASS: gdb.dwarf2/calling-convention.exp: return 35
>     n
>     Not confirmed
>     (gdb) FAIL: gdb.dwarf2/calling-convention.exp: finish
> 
> The issue is that when doing the test for "return 35", the DejaGnu test
> sends "n" (to tell GDB not to perform the return action) but never
> consumes the "Not confirmed" acknowledgment sent by GDB.  Later, when
> trying to do the next test, DejaGnu tries to match the leftover output
> from the "return" test. As this output is not expected, the test fails.
> 
> Fix by using gdb_test since it is able to handle the question-answer
> dance with GDB and do the proper validation.
> 
Thanks.  I guess unsurprisingly, I find this OK.

The lingering question is whether people are OK with making gdb_test's
question handling less forgiving.  If not, then this should be converted
back to gdb_test_multiple.

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

* Re: [PATCH v2] gdb/testsuite: Fix race in gdb.dwarf2/calling-convention.exp
  2022-04-01  9:11 ` Pedro Alves
@ 2022-04-01  9:51   ` Lancelot SIX
  2022-04-14 12:36   ` Tom de Vries
  1 sibling, 0 replies; 5+ messages in thread
From: Lancelot SIX @ 2022-04-01  9:51 UTC (permalink / raw)
  To: Pedro Alves, gdb-patches; +Cc: lsix

>>
>> Fix by using gdb_test since it is able to handle the question-answer
>> dance with GDB and do the proper validation.
>>
> Thanks.  I guess unsurprisingly, I find this OK.
> 
> The lingering question is whether people are OK with making gdb_test's
> question handling less forgiving.  If not, then this should be converted
> back to gdb_test_multiple.


I'll wait for a decision to be made on your series before doing anything 
on this patch.

If you ask me I like the changes you propose for gdb_test. I find it 
makes perfect sense gdb_test fails if a the question answer pair is 
specified in the test but GDB does not ask the question.  But I am not 
the person to convince ;)

Thanks,
Lancelot.

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

* Re: [PATCH v2] gdb/testsuite: Fix race in gdb.dwarf2/calling-convention.exp
  2022-04-01  9:11 ` Pedro Alves
  2022-04-01  9:51   ` Lancelot SIX
@ 2022-04-14 12:36   ` Tom de Vries
  2022-04-14 13:48     ` Lancelot SIX
  1 sibling, 1 reply; 5+ messages in thread
From: Tom de Vries @ 2022-04-14 12:36 UTC (permalink / raw)
  To: Pedro Alves, Lancelot SIX, gdb-patches; +Cc: lsix

On 4/1/22 11:11, Pedro Alves wrote:
> On 2022-03-31 12:12, Lancelot SIX wrote:
> 
>> Pedro Alves warned me that there is a race in
>> gdb.dwarf2/calling-convention.exp making the test sometimes fail on his
>> setup.  This can be reliably reproduced using :
>>
>>      make check-read1 TESTS="gdb.dwarf2/calling-convention.exp"
>>
>> The relevant part of the gdb.log file is:
>>
>>      return 35
>>      Function 'foo' does not follow the target calling convention.
>>      If you continue, setting the return value will probably lead to unpredictable behaviors.
>>      Make foo return now? (y or n) PASS: gdb.dwarf2/calling-convention.exp: return 35
>>      n
>>      Not confirmed
>>      (gdb) FAIL: gdb.dwarf2/calling-convention.exp: finish
>>
>> The issue is that when doing the test for "return 35", the DejaGnu test
>> sends "n" (to tell GDB not to perform the return action) but never
>> consumes the "Not confirmed" acknowledgment sent by GDB.  Later, when
>> trying to do the next test, DejaGnu tries to match the leftover output
>> from the "return" test. As this output is not expected, the test fails.
>>
>> Fix by using gdb_test since it is able to handle the question-answer
>> dance with GDB and do the proper validation.
>>
> Thanks.  I guess unsurprisingly, I find this OK.
> 
> The lingering question is whether people are OK with making gdb_test's
> question handling less forgiving.  If not, then this should be converted
> back to gdb_test_multiple.

this problem also triggers on gdb-12-branch, and I guess we're likely 
not backporting the new gdb_test behaviour there, in which case we'll 
need a gdb_test_multiple version of this patch applied to gdb-12-branch.

Thanks,
- Tom

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

* Re: [PATCH v2] gdb/testsuite: Fix race in gdb.dwarf2/calling-convention.exp
  2022-04-14 12:36   ` Tom de Vries
@ 2022-04-14 13:48     ` Lancelot SIX
  0 siblings, 0 replies; 5+ messages in thread
From: Lancelot SIX @ 2022-04-14 13:48 UTC (permalink / raw)
  To: Tom de Vries, Pedro Alves, gdb-patches; +Cc: lsix

> 
> this problem also triggers on gdb-12-branch, and I guess we're likely
> not backporting the new gdb_test behaviour there, in which case we'll
> need a gdb_test_multiple version of this patch applied to gdb-12-branch.
> 
> Thanks,
> - Tom

Hi,

I'll send a v3 based on gdb_test_multiple.  If Pedro's change to 
gdb_test lands in, I'll send a follow up patch to adjust this testcase.

Thanks,
Lancelot.

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

end of thread, other threads:[~2022-04-14 13:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-31 11:12 [PATCH v2] gdb/testsuite: Fix race in gdb.dwarf2/calling-convention.exp Lancelot SIX
2022-04-01  9:11 ` Pedro Alves
2022-04-01  9:51   ` Lancelot SIX
2022-04-14 12:36   ` Tom de Vries
2022-04-14 13:48     ` Lancelot SIX

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