From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0F0F1385840F; Thu, 22 Sep 2022 08:42:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0F0F1385840F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663836143; bh=5UDxM23BQcGPywwxsxDSjaKsjCoKT8IvEO6Oe1CB8Z8=; h=From:To:Subject:Date:From; b=rdicvUe78hob+3fMerx5UkLozm7IFlFr3GX16mkXHm0QX3hTuHev0ztdEjHszIEBE x79EGN210ck1tLvVRy/aBz/0wzR+P5syLOBfk3Pzx+uZrYbTiES8hUGgFqiHAdBBAh VaJDHhXg6/nnUxBuNFbpZ4cgYdY5wmJa8fNYGDFg= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug driver/107007] New: libiberty's win32_spawn error handling is poor Date: Thu, 22 Sep 2022 08:42:22 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: driver X-Bugzilla-Version: 12.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone cf_gcchost Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107007 Bug ID: 107007 Summary: libiberty's win32_spawn error handling is poor Product: gcc Version: 12.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: driver Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- Host: *-*-mingw* As described in https://gcc.gnu.org/pipermail/gcc-help/2022-September/141906.html the pex_win32_exec_child function just assumes that all errors are ENOENT: /* Create the child process. */=20=20 pid =3D win32_spawn (executable, (flags & PEX_SEARCH) !=3D 0, argv, env, dwCreationFlags, &si, &pi); if (pid =3D=3D (pid_t) -1) pid =3D spawn_script (executable, argv, env, dwCreationFlags, &si, &pi); if (pid =3D=3D (pid_t) -1) { *err =3D ENOENT; *errmsg =3D "CreateProcess"; } This gives users incorrect information when something goes wrong for a reas= on that isn't "No such file or directory". Maybe win32_spawn should use the Win32 GetLastError() function to get a Win= dows Error Code and then translate that to an errno value, and store it in errno= . Or ensure that GetLastError will still be valid for the caller of win32_spawn = and spawn_script to retrieve. libstdc++-v3/src/c++11/system_error.cc already has code to do that translat= ion (so maybe it should move to libiberty, and then reuse that in libstdc++).=