* "Invalid parameter passed to C runtime function" from MinGW GDB
@ 2018-11-18 16:46 Eli Zaretskii
2018-11-19 22:06 ` Tom Tromey
0 siblings, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2018-11-18 16:46 UTC (permalink / raw)
To: gdb-patches
While debugging the issue with internal_error when stepping out of
'main', I noticed that GDB emits the above warning many times. It
turns out the warning is triggered by this:
common/filestuff.c:
gdb_file_up
gdb_fopen_cloexec (const char *filename, const char *opentype)
{
FILE *result;
/* Probe for "e" support once. But, if we can tell the operating
system doesn't know about close on exec mode "e" without probing,
skip it. E.g., the Windows runtime issues an "Invalid parameter
passed to C runtime function" OutputDebugString warning for
unknown modes. Assume that if O_CLOEXEC is zero, then "e" isn't
supported. */
static int fopen_e_ever_failed_einval = O_CLOEXEC == 0; <<<<<<<<<<<<
if (!fopen_e_ever_failed_einval)
{
char *copy;
copy = (char *) alloca (strlen (opentype) + 2);
strcpy (copy, opentype);
/* This is a glibc extension but we try it unconditionally on
this path. */
strcat (copy, "e");
result = fopen (filename, copy); <<<<<<<<<<<<<<<<<<
MinGW doesn't support the "e" mode. As you see, we try to be smart
about that, but that trick no longer works, because Gnulib does this:
build-gnulib/import/fcntl.h:
#if !defined O_CLOEXEC && defined O_NOINHERIT
/* Mingw spells it 'O_NOINHERIT'. */
# define O_CLOEXEC O_NOINHERIT
#endif
and O_CLOEXEC is no longer zero.
I propose to fix this as below. Any objections to committing this to
master (with a suitable ChangeLog, of course)?
diff --git a/gdb/common/filestuff.c b/gdb/common/filestuff.c
index d4bd1a8..3fa035a 100644
--- a/gdb/common/filestuff.c
+++ b/gdb/common/filestuff.c
@@ -300,8 +300,10 @@ gdb_fopen_cloexec (const char *filename, const char *opentype)
skip it. E.g., the Windows runtime issues an "Invalid parameter
passed to C runtime function" OutputDebugString warning for
unknown modes. Assume that if O_CLOEXEC is zero, then "e" isn't
- supported. */
- static int fopen_e_ever_failed_einval = O_CLOEXEC == 0;
+ supported. On MinGW, O_CLOEXEC is an alias of O_NOINHERIT, and
+ "e" isn't supported. */
+ static int fopen_e_ever_failed_einval =
+ O_CLOEXEC == 0 || O_CLOEXEC == O_NOINHERIT;
if (!fopen_e_ever_failed_einval)
{
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: "Invalid parameter passed to C runtime function" from MinGW GDB
2018-11-18 16:46 "Invalid parameter passed to C runtime function" from MinGW GDB Eli Zaretskii
@ 2018-11-19 22:06 ` Tom Tromey
2018-11-20 16:52 ` Eli Zaretskii
2018-11-20 16:54 ` Eli Zaretskii
0 siblings, 2 replies; 4+ messages in thread
From: Tom Tromey @ 2018-11-19 22:06 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches
>>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:
Eli> I propose to fix this as below. Any objections to committing this to
Eli> master (with a suitable ChangeLog, of course)?
Eli> diff --git a/gdb/common/filestuff.c b/gdb/common/filestuff.c
Eli> index d4bd1a8..3fa035a 100644
Eli> --- a/gdb/common/filestuff.c
Eli> +++ b/gdb/common/filestuff.c
Eli> @@ -300,8 +300,10 @@ gdb_fopen_cloexec (const char *filename, const char *opentype)
Eli> skip it. E.g., the Windows runtime issues an "Invalid parameter
Eli> passed to C runtime function" OutputDebugString warning for
Eli> unknown modes. Assume that if O_CLOEXEC is zero, then "e" isn't
Eli> - supported. */
Eli> - static int fopen_e_ever_failed_einval = O_CLOEXEC == 0;
Eli> + supported. On MinGW, O_CLOEXEC is an alias of O_NOINHERIT, and
Eli> + "e" isn't supported. */
Eli> + static int fopen_e_ever_failed_einval =
Eli> + O_CLOEXEC == 0 || O_CLOEXEC == O_NOINHERIT;
Looks reasonable to me, thanks.
Tom
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: "Invalid parameter passed to C runtime function" from MinGW GDB
2018-11-19 22:06 ` Tom Tromey
@ 2018-11-20 16:52 ` Eli Zaretskii
2018-11-20 16:54 ` Eli Zaretskii
1 sibling, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2018-11-20 16:52 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: "Invalid parameter passed to C runtime function" from MinGW GDB
2018-11-19 22:06 ` Tom Tromey
2018-11-20 16:52 ` Eli Zaretskii
@ 2018-11-20 16:54 ` Eli Zaretskii
1 sibling, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2018-11-20 16:54 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
> From: Tom Tromey <tom@tromey.com>
> Cc: gdb-patches@sourceware.org
> Date: Mon, 19 Nov 2018 15:06:49 -0700
>
> Eli> diff --git a/gdb/common/filestuff.c b/gdb/common/filestuff.c
> Eli> index d4bd1a8..3fa035a 100644
> Eli> --- a/gdb/common/filestuff.c
> Eli> +++ b/gdb/common/filestuff.c
> Eli> @@ -300,8 +300,10 @@ gdb_fopen_cloexec (const char *filename, const char *opentype)
> Eli> skip it. E.g., the Windows runtime issues an "Invalid parameter
> Eli> passed to C runtime function" OutputDebugString warning for
> Eli> unknown modes. Assume that if O_CLOEXEC is zero, then "e" isn't
> Eli> - supported. */
> Eli> - static int fopen_e_ever_failed_einval = O_CLOEXEC == 0;
> Eli> + supported. On MinGW, O_CLOEXEC is an alias of O_NOINHERIT, and
> Eli> + "e" isn't supported. */
> Eli> + static int fopen_e_ever_failed_einval =
> Eli> + O_CLOEXEC == 0 || O_CLOEXEC == O_NOINHERIT;
>
> Looks reasonable to me, thanks.
Thanks, pushed to master. (Sorry for an empty message I sent by
mistake a few minutes ago.)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-11-20 16:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-18 16:46 "Invalid parameter passed to C runtime function" from MinGW GDB Eli Zaretskii
2018-11-19 22:06 ` Tom Tromey
2018-11-20 16:52 ` Eli Zaretskii
2018-11-20 16:54 ` Eli Zaretskii
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).