* [PATCH] libstdc++, Darwin: Do not use dev/null as the file for executables.
@ 2024-03-19 10:54 Iain Sandoe
2024-03-19 11:01 ` Jonathan Wakely
0 siblings, 1 reply; 2+ messages in thread
From: Iain Sandoe @ 2024-03-19 10:54 UTC (permalink / raw)
To: libstdc++, gcc-patches; +Cc: fxcoudert, nightstrike
Note that Windows-based platforms do something quite similar, but always
use the same (x.exe) filename. I wonder, in passing, if that makes a
vulnerability in parallel testing (I chose to avoid the possibility for
Darwin).
Tested on x86_64-darwin21, x86_64-linux-gnu,
OK for trunk?
back-ports where applicable (I did not yet check)?
thanks
Iain
--- 8< ---
Darwin has a separate debug linker, which is invoked when the command
line contains source files and debug is enabled.
Using /dev/null as the executable name does not, therefore, work when
debug is enabled, since the debug linker does not accept /dev/null as
a valid executable name.
The leads to incorrectly UNSUPPORTED testcases because of the unintended
error result from the test compilation.
The solution here is to use a temporary file that is deleted at the
end of the test (which is the mechanism used elsewhere)
libstdc++-v3/ChangeLog:
* testsuite/lib/libstdc++.exp (v3_target_compile): Instead of
/dev/null, use a temporary file for test executables on Darwin.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
---
libstdc++-v3/testsuite/lib/libstdc++.exp | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 58804ecab26..4ae4cecb169 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -615,11 +615,15 @@ proc v3_target_compile { source dest type options } {
}
}
+ # For Windows and Darwin we might want to create a temporary file.
+ # note that it needs deleteting.
+ set file_to_delete ""
# Small adjustment for Windows hosts.
if { $dest == "/dev/null"
&& [info exists ::env(OS)] && [string match "Windows*" $::env(OS)] } {
if { $type == "executable" } {
set dest "x.exe"
+ set file_to_delete ${dest}
} else {
# Windows uses special file named "nul" as a substitute for
# /dev/null
@@ -627,6 +631,15 @@ proc v3_target_compile { source dest type options } {
}
}
+ # Using /dev/null as the executable name does not work on Darwin when
+ # debug is enabled, since the debug linker does not accept /dev/null as
+ # a valid executable name.
+ if { $dest == "/dev/null" && [istarget *-*-darwin*]
+ && $type == "executable" } {
+ set dest dev-null-[pid].exe
+ set file_to_delete ${dest}
+ }
+
lappend options "compiler=$cxx_final"
lappend options "timeout=[timeout_value]"
@@ -637,7 +650,12 @@ proc v3_target_compile { source dest type options } {
}
set comp_output [target_compile $source $dest $type $options]
-
+ if { $type == "executable" && $file_to_delete != "" } {
+ file delete $file_to_delete
+ if { [istarget *-*-darwin*] && [file exists $file_to_delete.dSYM] } {
+ file delete -force $file_to_delete.dSYM
+ }
+ }
return $comp_output
}
--
2.39.2 (Apple Git-143)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] libstdc++, Darwin: Do not use dev/null as the file for executables.
2024-03-19 10:54 [PATCH] libstdc++, Darwin: Do not use dev/null as the file for executables Iain Sandoe
@ 2024-03-19 11:01 ` Jonathan Wakely
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Wakely @ 2024-03-19 11:01 UTC (permalink / raw)
To: iain; +Cc: libstdc++, gcc-patches, fxcoudert, nightstrike
On Tue, 19 Mar 2024 at 10:55, Iain Sandoe wrote:
>
> Note that Windows-based platforms do something quite similar, but always
> use the same (x.exe) filename. I wonder, in passing, if that makes a
> vulnerability in parallel testing (I chose to avoid the possibility for
> Darwin).
Parallel testing should use a separate directory for each runtest
process, so each x.exe is in a separate directory. That's a
predictable name that could be used by an attacker, but I don't think
it's a problem specific to parallel testing. A single runtest process
has the same behaviour.
> Tested on x86_64-darwin21, x86_64-linux-gnu,
> OK for trunk?
> back-ports where applicable (I did not yet check)?
> thanks
> Iain
>
> --- 8< ---
>
> Darwin has a separate debug linker, which is invoked when the command
> line contains source files and debug is enabled.
>
> Using /dev/null as the executable name does not, therefore, work when
> debug is enabled, since the debug linker does not accept /dev/null as
> a valid executable name.
>
> The leads to incorrectly UNSUPPORTED testcases because of the unintended
> error result from the test compilation.
>
> The solution here is to use a temporary file that is deleted at the
> end of the test (which is the mechanism used elsewhere)
>
> libstdc++-v3/ChangeLog:
>
> * testsuite/lib/libstdc++.exp (v3_target_compile): Instead of
> /dev/null, use a temporary file for test executables on Darwin.
>
> Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
> ---
> libstdc++-v3/testsuite/lib/libstdc++.exp | 20 +++++++++++++++++++-
> 1 file changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
> index 58804ecab26..4ae4cecb169 100644
> --- a/libstdc++-v3/testsuite/lib/libstdc++.exp
> +++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
> @@ -615,11 +615,15 @@ proc v3_target_compile { source dest type options } {
> }
> }
>
> + # For Windows and Darwin we might want to create a temporary file.
> + # note that it needs deleteting.
Capital N for Note, and "deleting".
OK for trunk and branches with that change.
> + set file_to_delete ""
> # Small adjustment for Windows hosts.
> if { $dest == "/dev/null"
> && [info exists ::env(OS)] && [string match "Windows*" $::env(OS)] } {
> if { $type == "executable" } {
> set dest "x.exe"
> + set file_to_delete ${dest}
> } else {
> # Windows uses special file named "nul" as a substitute for
> # /dev/null
> @@ -627,6 +631,15 @@ proc v3_target_compile { source dest type options } {
> }
> }
>
> + # Using /dev/null as the executable name does not work on Darwin when
> + # debug is enabled, since the debug linker does not accept /dev/null as
> + # a valid executable name.
> + if { $dest == "/dev/null" && [istarget *-*-darwin*]
> + && $type == "executable" } {
> + set dest dev-null-[pid].exe
> + set file_to_delete ${dest}
> + }
> +
> lappend options "compiler=$cxx_final"
> lappend options "timeout=[timeout_value]"
>
> @@ -637,7 +650,12 @@ proc v3_target_compile { source dest type options } {
> }
>
> set comp_output [target_compile $source $dest $type $options]
> -
> + if { $type == "executable" && $file_to_delete != "" } {
> + file delete $file_to_delete
> + if { [istarget *-*-darwin*] && [file exists $file_to_delete.dSYM] } {
> + file delete -force $file_to_delete.dSYM
> + }
> + }
> return $comp_output
> }
>
> --
> 2.39.2 (Apple Git-143)
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-03-19 11:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-19 10:54 [PATCH] libstdc++, Darwin: Do not use dev/null as the file for executables Iain Sandoe
2024-03-19 11:01 ` Jonathan Wakely
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).