Page MenuHome GnuPG

Fix "Invalid Parameter passed to C runtime function" warnings on Windows
Closed, ResolvedPublic

Description

When starting gpg-agent on Windows you get hundredts (probably 256 ;-) )
warnings in DebugView about "Invalid Parameter passed to C runtime function"

I was curious about this and tracked it down to:

common/exechelp-w32.c (get_all_open_fds)

The Line: if (!(fstat (fd, &statbuf) == -1 && errno == EBADF))

Produces this and It's called in a loop for 256 FD's. Each time a warning is
produced. According to MSDN:
https://msdn.microsoft.com/en-us/library/221w8e43.aspx

"A return value of –1 indicates an error. If the file descriptor is invalid or
buffer is NULL, the invalid parameter handler is invoked, as described in
Parameter Validation."

The invalid parameter handler is afaik what produces this warning.

I don't know a way how to check if an fd is valid without triggering the invalid
parameter handler. get_osfilehandle also triggers the invalid parameter handler :-/

So no fix here from me but I wanted to note down where the message comes from.

Event Timeline

werner added a subscriber: werner.

Actually we do not need that function on Windows. It is on Unix called at
startup to get a list of files not to close. On Windows we do not need to close
the files before a CreateProcess and thus close_all_fds is a dummy anyway.

I removed calling this function under Windows. To go into 2.1.18.

werner claimed this task.
werner removed a project: Restricted Project.