public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug testsuite/29726] New: [gdb] FAIL: gdb.server/connect-with-no-symbol-file.exp: sysroot=: action=delete: connection to GDBserver succeeded
@ 2022-10-27  7:19 vries at gcc dot gnu.org
  2022-10-27  7:21 ` [Bug testsuite/29726] " vries at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: vries at gcc dot gnu.org @ 2022-10-27  7:19 UTC (permalink / raw)
  To: gdb-prs

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

            Bug ID: 29726
           Summary: [gdb] FAIL:
                    gdb.server/connect-with-no-symbol-file.exp: sysroot=:
                    action=delete: connection to GDBserver succeeded
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: testsuite
          Assignee: unassigned at sourceware dot org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

I build gdb using -O2, and ran the testsuite using taskset -c 0, and ran into:
...
(gdb) PASS: gdb.server/connect-with-no-symbol-file.exp: sysroot=:
action=delete: setup: adjust sysroot
builtin_spawn
/home/vries/gdb_versions/devel/build/gdb/testsuite/../../gdb/../gdbserver/gdbserver
--once localhost:2385
/home/vries/gdb_versions/devel/build/gdb/testsuite/outputs/gdb.server/connect-with-no-symbol-file/connect-with-no-symbol-file^M
/bin/bash:
/home/vries/gdb_versions/devel/build/gdb/testsuite/outputs/gdb.server/connect-with-no-symbol-file/connect-with-no-symbol-file:
Permission denied^M
/bin/bash: line 0: exec:
/home/vries/gdb_versions/devel/build/gdb/testsuite/outputs/gdb.server/connect-with-no-symbol-file/connect-with-no-symbol-file:
cannot execute: Permission denied^M
During startup program exited with code 126.^M
Exiting^M
target remote localhost:2385^M
`/home/vries/gdb_versions/devel/build/gdb/testsuite/outputs/gdb.server/connect-with-no-symbol-file/connect-with-no-symbol-file'
has disappeared; keeping its symbols.^M
localhost:2385: Connection timed out.^M
(gdb) FAIL: gdb.server/connect-with-no-symbol-file.exp: sysroot=:
action=delete: connection to GDBserver succeeded
...

AFAICT, the following is intended to happen:
- enter scenario "permission"
- cp $exec.bak $exec
- disconnect
- gdbserver start with $exec
- chmod 000 $exec
- connect to gdbserver
- detach
- enter scenario "delete"
- cp $exec.bak $exec
- disconnect
- gdbserver start with $exec
- delete $exec
- connect to gdbserver
- detach

So, it looks like the second "gdbserver start with $exec" fails because it has
no permission to execute $exec, which at first glance suggest that the chmod
000 $exec is still effective, despite the subsequent "cp $exec.bak $exec" which
should have restored the permissions.

FTR, the $exec.bak still has the correct permissions set:
...
$ ls -al
outputs/gdb.server/connect-with-no-symbol-file/connect-with-no-symbol-file.bak
-rwxr-xr-x 1 vries users 12104 Oct 26 18:00
outputs/gdb.server/connect-with-no-symbol-file/connect-with-no-symbol-file.bak
...

And due to the "delete $exec", we can't see the permissions of that one.

This doesn't look like a gdb bug, but I have no idea yet what it could be.

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

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

* [Bug testsuite/29726] [gdb] FAIL: gdb.server/connect-with-no-symbol-file.exp: sysroot=: action=delete: connection to GDBserver succeeded
  2022-10-27  7:19 [Bug testsuite/29726] New: [gdb] FAIL: gdb.server/connect-with-no-symbol-file.exp: sysroot=: action=delete: connection to GDBserver succeeded vries at gcc dot gnu.org
@ 2022-10-27  7:21 ` vries at gcc dot gnu.org
  2022-10-27  7:45 ` vries at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: vries at gcc dot gnu.org @ 2022-10-27  7:21 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
Created attachment 14418
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14418&action=edit
gdb.log

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

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

* [Bug testsuite/29726] [gdb] FAIL: gdb.server/connect-with-no-symbol-file.exp: sysroot=: action=delete: connection to GDBserver succeeded
  2022-10-27  7:19 [Bug testsuite/29726] New: [gdb] FAIL: gdb.server/connect-with-no-symbol-file.exp: sysroot=: action=delete: connection to GDBserver succeeded vries at gcc dot gnu.org
  2022-10-27  7:21 ` [Bug testsuite/29726] " vries at gcc dot gnu.org
@ 2022-10-27  7:45 ` vries at gcc dot gnu.org
  2022-10-27  8:17 ` vries at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: vries at gcc dot gnu.org @ 2022-10-27  7:45 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #2 from Tom de Vries <vries at gcc dot gnu.org> ---
FTR, this also the only test-case in the testsuite that for me triggers the:
...
# of unexpected core files      1
...
that is generated from $exec:
...
$ file build/gdb/testsuite/corebuild/gdb/testsuite/core: ELF 64-bit LSB core
file x86-64, version 1 (SYSV), SVR4-style, from
'/home/vries/gdb_versions/devel/build/gdb/testsuite/outputs/gdb.server/connect-w',
real uid: 1000, effective uid: 1000, real gid: 100, effective gid: 100, execfn:
'/home/vries/gdb_versions/devel/build/gdb/testsuite/outputs/gdb.server/connect-with-no-symbol-file/connect-with-no-symbol-file',
platform: 'x86_64'
...
due to a segfault in the dynamic linker:
...
$ gdb
./outputs/gdb.server/connect-with-no-symbol-file/connect-with-no-symbol-file
build/gdb/testsuite/core
Reading symbols from
./outputs/gdb.server/connect-with-no-symbol-file/connect-with-no-symbol-file...

warning: exec file is newer than core file.
[New LWP 28741]
Core was generated by
`/home/vries/gdb_versions/devel/build/gdb/testsuite/outputs/gdb.server/connect-w'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00000000f7dd4550 in ?? ()
(gdb) 
...

I'm not sure if it's related, but I thought it's worthwhile mentioning.

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

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

* [Bug testsuite/29726] [gdb] FAIL: gdb.server/connect-with-no-symbol-file.exp: sysroot=: action=delete: connection to GDBserver succeeded
  2022-10-27  7:19 [Bug testsuite/29726] New: [gdb] FAIL: gdb.server/connect-with-no-symbol-file.exp: sysroot=: action=delete: connection to GDBserver succeeded vries at gcc dot gnu.org
  2022-10-27  7:21 ` [Bug testsuite/29726] " vries at gcc dot gnu.org
  2022-10-27  7:45 ` vries at gcc dot gnu.org
@ 2022-10-27  8:17 ` vries at gcc dot gnu.org
  2022-10-27  8:33 ` vries at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: vries at gcc dot gnu.org @ 2022-10-27  8:17 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #3 from Tom de Vries <vries at gcc dot gnu.org> ---
I tried to reproduce using:
...
$ git diff
diff --git a/gdb/testsuite/gdb.server/connect-with-no-symbol-file.exp
b/gdb/testsuite/gdb.s
erver/connect-with-no-symbol-file.exp
index d45e958a529..d3e9f96f46a 100644
--- a/gdb/testsuite/gdb.server/connect-with-no-symbol-file.exp
+++ b/gdb/testsuite/gdb.server/connect-with-no-symbol-file.exp
@@ -93,12 +93,17 @@ proc connect_no_symbol_file { sysroot action } {
 # Make sure we have the original symbol file in a safe place to copy from.
 gdb_remote_download host $binfile $binfile.bak

-# Start with no executable loaded.
-clean_restart
-
-# Run the test with different permutations.
-foreach_with_prefix sysroot {"" "target:"} {
-    foreach_with_prefix action {"permission" "delete"} {
-       connect_no_symbol_file $sysroot $action
+set n 1000
+for {set i 1} {$i <= $n} {incr i} {
+    # Start with no executable loaded.
+    clean_restart
+
+    with_test_prefix $i {
+       # Run the test with different permutations.
+       foreach_with_prefix sysroot {"" "target:"} {
+           foreach_with_prefix action {"permission" "delete"} {
+               connect_no_symbol_file $sysroot $action
+           }
+       }
     }
 }
...
but that runs into a hang after ~200 iterations:
...
builtin_spawn
/home/vries/gdb_versions/devel/build/gdb/testsuite/../../gdb/../gdbserver/gdbserver
--once localhost:3151
/home/vries/gdb_versions/devel/build/gdb/testsuite/outputs/gdb.server/connect-with-no-symbol-file/connect-with-no-symbol-file^M
spawn of
/home/vries/gdb_versions/devel/build/gdb/testsuite/../../gdb/../gdbserver/gdbserver
--once localhost:3151
/home/vries/gdb_versions/devel/build/gdb/testsuite/outputs/gdb.server/connect-with-no-symbol-file/connect-with-no-symbol-file
failed
ERROR: tcl error sourcing
/home/vries/gdb_versions/devel/src/gdb/testsuite/gdb.server/connect-with-no-symbol-file.exp.
ERROR: Timeout waiting for gdbserver response.
...

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

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

* [Bug testsuite/29726] [gdb] FAIL: gdb.server/connect-with-no-symbol-file.exp: sysroot=: action=delete: connection to GDBserver succeeded
  2022-10-27  7:19 [Bug testsuite/29726] New: [gdb] FAIL: gdb.server/connect-with-no-symbol-file.exp: sysroot=: action=delete: connection to GDBserver succeeded vries at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2022-10-27  8:17 ` vries at gcc dot gnu.org
@ 2022-10-27  8:33 ` vries at gcc dot gnu.org
  2022-10-27  9:04 ` vries at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: vries at gcc dot gnu.org @ 2022-10-27  8:33 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #4 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tom de Vries from comment #3)
> but that runs into a hang after ~200 iterations:

OK, that makes sense, in gdbserver_start we do:
...
        global server_spawn_id
        set server_spawn_id [remote_spawn target $gdbserver_command]
...
but don't actually check if the spawn succeeded.

AFAICT failure to spawn should result in -1, but most places also check for !=
"".

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

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

* [Bug testsuite/29726] [gdb] FAIL: gdb.server/connect-with-no-symbol-file.exp: sysroot=: action=delete: connection to GDBserver succeeded
  2022-10-27  7:19 [Bug testsuite/29726] New: [gdb] FAIL: gdb.server/connect-with-no-symbol-file.exp: sysroot=: action=delete: connection to GDBserver succeeded vries at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2022-10-27  8:33 ` vries at gcc dot gnu.org
@ 2022-10-27  9:04 ` vries at gcc dot gnu.org
  2022-10-27  9:26 ` luis.machado at arm dot com
  2022-10-27 14:56 ` [Bug testsuite/29726] [gdb/testsuite] " vries at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: vries at gcc dot gnu.org @ 2022-10-27  9:04 UTC (permalink / raw)
  To: gdb-prs

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

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |luis.machado at arm dot com

--- Comment #5 from Tom de Vries <vries at gcc dot gnu.org> ---
(In reply to Tom de Vries from comment #0)
> This doesn't look like a gdb bug, but I have no idea yet what it could be.

I think I understand what's going on.

We're using remote_spawn instead of remote_exec to do chmod 000, and never wait
for it.

So, we know for sure that the chmod 000 has started, but we don't know when it
actually will have effect, which explains the failure I saw: it could have
lingered until after the copy that was supposed to restore the permission.

So, the non-intrusive way to fix this is to wait for the chmod 000 pid before
moving on to the next scenario.

OTOH, it's possible that using remote_spawn is a mistake, and remote_exec was
meant.

In the original submission (
https://sourceware.org/pipermail/gdb-patches/2016-February/131420.html ) we
had:
...
+if {[file exists $binfile]} {
+    system "chmod 000 $binfile"
+}
...
but after a review comment "Seems like this won't work with remote-host
testing?" it was changed to:
...
+       } elseif { $action == "permission" } {
+         remote_spawn target "chmod 000 $binfile"
+       }
...
which was committed.

Then there was a patch to fix behaviour with remote-gdbserver-on-localhost,
which would have gone with remote_exec:
...
+proc make_inaccessible { file } {
+    remote_exec host "chmod 000 $file"
+    remote_exec target "chmod 000 $file"
+}
...

Taking all this into account, I think the use of remote_spawn was a mistake.

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

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

* [Bug testsuite/29726] [gdb] FAIL: gdb.server/connect-with-no-symbol-file.exp: sysroot=: action=delete: connection to GDBserver succeeded
  2022-10-27  7:19 [Bug testsuite/29726] New: [gdb] FAIL: gdb.server/connect-with-no-symbol-file.exp: sysroot=: action=delete: connection to GDBserver succeeded vries at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2022-10-27  9:04 ` vries at gcc dot gnu.org
@ 2022-10-27  9:26 ` luis.machado at arm dot com
  2022-10-27 14:56 ` [Bug testsuite/29726] [gdb/testsuite] " vries at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: luis.machado at arm dot com @ 2022-10-27  9:26 UTC (permalink / raw)
  To: gdb-prs

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

--- Comment #6 from Luis Machado <luis.machado at arm dot com> ---
I can't say I remember exactly what this was about, but your reasoning looks
correct to me. It may be the case I wasn't exactly sure if remote_exec or
remote_spawn should've been used.

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

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

* [Bug testsuite/29726] [gdb/testsuite] FAIL: gdb.server/connect-with-no-symbol-file.exp: sysroot=: action=delete: connection to GDBserver succeeded
  2022-10-27  7:19 [Bug testsuite/29726] New: [gdb] FAIL: gdb.server/connect-with-no-symbol-file.exp: sysroot=: action=delete: connection to GDBserver succeeded vries at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2022-10-27  9:26 ` luis.machado at arm dot com
@ 2022-10-27 14:56 ` vries at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: vries at gcc dot gnu.org @ 2022-10-27 14:56 UTC (permalink / raw)
  To: gdb-prs

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

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
   Target Milestone|---                         |13.1
            Summary|[gdb] FAIL:                 |[gdb/testsuite] FAIL:
                   |gdb.server/connect-with-no- |gdb.server/connect-with-no-
                   |symbol-file.exp: sysroot=:  |symbol-file.exp: sysroot=:
                   |action=delete: connection   |action=delete: connection
                   |to GDBserver succeeded      |to GDBserver succeeded
         Resolution|---                         |FIXED

--- Comment #7 from Tom de Vries <vries at gcc dot gnu.org> ---
Fixed by
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=b253899c901fed0ff56b2746945ffc824e412b81

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

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

end of thread, other threads:[~2022-10-27 14:56 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-27  7:19 [Bug testsuite/29726] New: [gdb] FAIL: gdb.server/connect-with-no-symbol-file.exp: sysroot=: action=delete: connection to GDBserver succeeded vries at gcc dot gnu.org
2022-10-27  7:21 ` [Bug testsuite/29726] " vries at gcc dot gnu.org
2022-10-27  7:45 ` vries at gcc dot gnu.org
2022-10-27  8:17 ` vries at gcc dot gnu.org
2022-10-27  8:33 ` vries at gcc dot gnu.org
2022-10-27  9:04 ` vries at gcc dot gnu.org
2022-10-27  9:26 ` luis.machado at arm dot com
2022-10-27 14:56 ` [Bug testsuite/29726] [gdb/testsuite] " vries at gcc dot gnu.org

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