Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <pedro@palves.net>
To: gdb-patches@sourceware.org
Subject: [PATCH] gdb/Windows testsuite: Avoid "bad" words in exe names
Date: Thu,  9 Jul 2026 18:43:51 +0100	[thread overview]
Message-ID: <20260709174351.431907-1-pedro@palves.net> (raw)

Running gdb.base/execl-update-breakpoints.exp on Windows 11 shows this
FAIL:

 (gdb) run
 Starting program: .../gdb.base/execl-update-breakpoints/execl-update-breakpoints1.exe
 Error creating process .../gdb.base/execl-update-breakpoints/execl-update-breakpoints1.exe (error 740): The requested operation requires elevation.
 (gdb) FAIL: gdb.base/execl-update-breakpoints.exp: runto: run to main

Error 740 is ERROR_ELEVATION_REQUIRED.

Turns out that Windows has an "installer detection" heuristic that
refuses to launch executables whose filename contains keywords like
"update", "setup", and "install" without elevation (admin rights),
unless the PE embeds a manifest declaring
requestedExecutionLevel="asInvoker".

I found some older Microsoft documentation claiming that the heuristic
only applies to 32-bit binaries, but what I observe is that:

 - It triggers with 64-bit PEs on current Windows.

And also:

 - Matches the word (e.g. "update") as a substring anywhere in the
   filename (not just as a prefix).

 - Is not drive-dependent.  I thought moving the process to a dev
   drive might suppress the check, but it does not.

I saw this problem first in a downstream ROCgdb testcase, and there I
fixed it by adjusting the name of that particular testcase.

Since this is the second case I'm seeing this already, I thought I'd
fix it in a more general way this time, one that avoids adding the
same explanatory comment to several testcases.

Fix it by making standard_testfile tweak the resulting "binfile"
output variable to avoid the "bad" words, on Windows.  This way, in
theory we only need to handle this once, in a central place.

Change-Id: I93c7d733fb8870b4ec6ff97ca59013211b362061
---
 gdb/testsuite/lib/gdb.exp | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 8eeaf2fc8e6..1201b615ee6 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -4130,6 +4130,12 @@ proc is_aarch64_target {} {
     return [expr {![is_aarch32_target]}]
 }
 
+# Return true if the target is Windows-based.
+
+proc is_windows_based_target {} {
+    return [expr {[istarget *-*-cygwin*] || [istarget *-*-mingw*]}]
+}
+
 # Return 1 if displaced stepping is supported on target, otherwise, return 0.
 proc support_displaced_stepping {} {
 
@@ -8414,7 +8420,23 @@ proc standard_testfile {args} {
     global testfile binfile
 
     set testfile $gdb_test_file_name
-    set binfile [standard_output_file ${testfile}]
+
+    if {[is_windows_based_target]} {
+	# Windows' installer detection heuristic refuses to launch
+	# executables whose name contains the following words without
+	# elevation, failing with ERROR_ELEVATION_REQUIRED (740).
+	#
+	# Map of WORD => REPLACEMENT.
+	set word_map {
+	    "update" "up_date"
+	    "setup" "set_up"
+	    "install" "inst_all"
+	}
+	set binfile_basename [string map $word_map $testfile]
+    } else {
+	set binfile_basename $testfile
+    }
+    set binfile [standard_output_file ${binfile_basename}]
 
     if {[llength $args] == 0} {
 	set args .c

base-commit: 4c4e1dd5a02c1a03e7eb408987404ffd1adfd1e4
-- 
2.54.0


             reply	other threads:[~2026-07-09 17:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-09 17:43 Pedro Alves [this message]
2026-07-10  5:18 ` Eli Zaretskii
2026-07-10 18:59   ` [PATCH] gdb/Windows testsuite: Embed asInvoker manifest in test executables Pedro Alves
2026-07-10 19:09     ` Pedro Alves
2026-07-11  6:07     ` Eli Zaretskii
2026-07-22 14:16       ` Pedro Alves
2026-07-10 14:41 ` [PATCH] gdb/Windows testsuite: Avoid "bad" words in exe names Andrew Burgess
2026-07-10 19:14   ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260709174351.431907-1-pedro@palves.net \
    --to=pedro@palves.net \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox