From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id OYlcI5qgD2q1sQ0AWB0awg (envelope-from ) for ; Thu, 21 May 2026 20:17:30 -0400 Received: by simark.ca (Postfix, from userid 112) id 8C6671E091; Thu, 21 May 2026 20:17:30 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 089841E024 for ; Thu, 21 May 2026 20:17:30 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A65F148FEDA2 for ; Fri, 22 May 2026 00:17:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A65F148FEDA2 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) by sourceware.org (Postfix) with ESMTPS id 5080C48F66CA for ; Fri, 22 May 2026 00:16:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5080C48F66CA Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5080C48F66CA Authentication-Results: sourceware.org; arc=none smtp.remote-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1779408991; cv=none; b=jd9RexX8O5PZSq1QbRiaqeWCPBEBoP0wKlLGNu7ubo41KE/muojGfgHllVjJ58pELeW55mlNVLgidNcKh7Rdgr3sduk2amsFmKOsdILQqIq3ajaJOXLTKu98c6O6dRdFefAnZZc0n5SDkzG9I3IWl+Rn6czb4PI4ZMjsOyVKeSg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1779408991; c=relaxed/simple; bh=sCa7IsrU8ug7tgTWXMJ+19FFfYTYUsYdyeIDrfup1sE=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=MJmK7UYH/5LgWdT3Dhw+74Ngk+ZgIq7WPcDbiSYmywH3jBHStNxxIjXOjETYy/BcRJcfLAEIEVioyRCJXfVmSf7z5i3waNvQ0dJgOo+OXo4uC8pgDlKnMsqU6ZeA9BGnis5FNTZXCsCyqL2zazUQ+kp63GD5CHSB7Rg3G6U6R8E= ARC-Authentication-Results: i=1; sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5080C48F66CA Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-45e6a4d0be0so2953321f8f.1 for ; Thu, 21 May 2026 17:16:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779408990; x=1780013790; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=qgrI5UuwPWAfRdSr735HAu2BwFuDCx0jt1Cy0B6W7T8=; b=CFxVMj5WBePJ2/usaZk1f7qgT6Gpg3b863Du6yTBKk9TcyiQaUVQjKDLYvE3aBU73x Ah+M55+ll08p5UuQjLk+R6WcKImcCQHeuzBqOTIVoluMzIDNGgqVdePuj1qGy+E7II9y /j/m22d7Q7OW/EGgzIZqx6+XfKecEJNefWQjx5UG4tLN+JEjtP/2m4aP8iOM8LApfj2J /Bw6YXlbtHJRCWf0Hr1MAA+jFN+9/40wkKsGc2SHGzrRB62xMtyr+P6W+GxYVhFG89ek MSt9ATb0oXHFAgxcp5SNOcJdY1E+sSRYCo47nkoHramg3zRZPxT92n3DSzCm3OQ4/712 XnYw== X-Gm-Message-State: AOJu0Yx7ZS+492txLfNwmRHklT9ustI8jkFd5VBdB9gPtndTit+Z9Y8P WXQvusohNLvsvq0flu27DnHUCTJNFgpAhrFmy9wWKTunVw6jy+owhULE1ANuZg== X-Gm-Gg: Acq92OH8oZ98RlRTIa90Uw5KRgBGuqBhnrTCyYhKdGa7eTTtEkupD8B1HFsJ7W2YSPD EisncmhDTqgJrrTUfa50tvOpzl6us8F3ncOZJwsCWsCgoGplhIlOaYXoqV/ebaB9msyF72/QEJB bObC/LJcwdt3DxiZCmmpf1puuMswFMly9kaJ4CEp6Ne0pmq13ISQ0p5cE1AvqtP6+Cr+kX1+LbL sakRlwkbUZs38F5feC9OVXSSX7fr97j255/nsOoGVciUhDTFdbFaesD2/r1RDKb/krMMyPMwCnj wDSQpM84+v1v3ldsT+jWRLtrcTWXmUpcyeTMZxhLMtkhrMQUjqICR05SrAZjQjURb4E9NRnIj+J o2CxC1jZHBlbOwgUyRd97y4286Z2JrpqtyxeaTcU0yoRdTogpV8yjkKqZHIRxAr0tDzvMs3u88u j9kkf+Luw44nGjGgvXVERTwA== X-Received: by 2002:a05:6000:41f0:b0:45e:9ea3:ce9a with SMTP id ffacd0b85a97d-45eb3688c81mr952834f8f.8.1779408990096; Thu, 21 May 2026 17:16:30 -0700 (PDT) Received: from localhost ([2001:8a0:fae3:2600:cb04:347e:aaad:ca08]) by smtp.gmail.com with UTF8SMTPSA id ffacd0b85a97d-45eb4982891sm966573f8f.16.2026.05.21.17.16.29 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 May 2026 17:16:29 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 1/5] Fix "set cwd ..." on Cygwin, part 1 Date: Fri, 22 May 2026 01:16:22 +0100 Message-ID: <20260522001626.393908-2-pedro@palves.net> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260522001626.393908-1-pedro@palves.net> References: <20260522001626.393908-1-pedro@palves.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org When running gdb.base/exitsignal.exp on Cygwin, we see: (gdb) set cwd /cygdrive/d/cygwin-gdb/build-testsuite/outputs/gdb.base/exitsignal (gdb) run Starting program: /cygdrive/d/cygwin-gdb/build-testsuite/outputs/gdb.base/exitsignal/exitsignal Error converting inferior cwd: 28 (gdb) FAIL: gdb.base/exitsignal.exp: runto: run to main 28 is ENOSPC. But this isn't really literally no space left, though. cygwin_conv_path documentation mentions that error code. According to the Cygwin API documentation for cygwin_conv_path, the function fails with ENOSPC ("No space left on device") when the size of the destination buffer is smaller than what is required for the conversion. See: https://cygwin.com/cygwin-api/func-cygwin-conv-path.html If we look closely at how the buffer size argument is being passed, we see we have two problems here: 1) Incorrectly passing down the input buffer size instead of the output size. The code passes strlen(inferior_cwd) as the size of the destination buffer (infcwd). However, the target Windows path format (e.g. "D:\cygwin-gdb\..." in my case) could be longer or shorter than the POSIX source path ("/cygdrive/d/..."). In my specific case, the source string is 64 characters, while the target Windows string is 61 (wide) characters (and twice as many bytes). 2) Incorrectly passing character count instead of byte count The conversion target token is CCP_POSIX_TO_WIN_W. The _W means that the destination buffer infcwd takes wide characters (wchar_t). The documentation states that the size argument is in bytes, not characters. This commit fixes it, by passing the byte size of the destination buffer. Change-Id: I70af6ef394f48da35ccc2e04ef764915e09e59de commit-id: 66c930c2 --- gdb/windows-nat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index d506b42fbda..862568fa21e 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -2925,7 +2925,7 @@ windows_nat_target::create_inferior (const char *exec_file, if (inferior_cwd != NULL && cygwin_conv_path (CCP_POSIX_TO_WIN_W, inferior_cwd, - infcwd, strlen (inferior_cwd)) < 0) + infcwd, sizeof (infcwd)) < 0) error (_("Error converting inferior cwd: %d"), errno); args = (wchar_t *) alloca ((wcslen (toexec) + wcslen (cygallargs) + 2) -- 2.53.0