X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=TUF FJe9M0KpTXVafg/fxP7Tg/Yqmk2EFgP3J8EMFWHJuqyrTOeuiy1gGbpAVigXfJmz Xn+RGL8te5G18yXnuB4+/RwoYgPdI8R2wG2qZHw6GqJ95ttWZMFzW6Rw8av2L2HI 8Ik/iS9qY+MzocYM0anRWXJN/JpiSiIr4HLaH1k8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type:content-transfer-encoding; s=default; bh=/a+Vjzhux Afb2N7W9JdYgoY48hE=; b=wgLKD9dVN8kGUFkylfYTgqqJtRAQ+GrYPxn6xsNxI Ljn2b0WnZSBBYFZlBNHKfntg27k33Vy5F4xZxqv4I8BLFoe7rjsz3pa9NKIzANOU 0qYacGQS0JRYYjj+3fUw0nj5p9aFM2tnWQGJhJgmzmBm1yKeESEtBdH6x+Mvt84k BI= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,HTML_MESSAGE,SPF_PASS autolearn=ham version=3.3.2 spammy=_not_, exercises, colon, Hx-exchange-antispam-report-test:21748063052155 X-HELO: us-smtp-1.mimecast.com From: Ken Harris To: "cygwin AT cygwin DOT com" Subject: winsup\cygwin\path.cc issues Date: Wed, 2 May 2018 13:49:45 +0000 Message-ID: x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM2PR0501MB1081;7:T+R1pouj+an4JrsR71MW7FWHugrP366C1Rz3DtfsUZBjM/uTADTmzx/C4PzTKk9YC5d6JLBEUAUuoiF//ZIHuE5jQdcdwuJ75HYiKjDAII89L1y39r453zKKZr3icKXSM/ZnggSB6lJ5Y37sPf92WJA3IwdFSJexYepTS8ns0m2nUE3GvGRjnwpS8/Lzlkn/UIRusVQvxn5yzNB1O0F+JOEhOHIcp44hxkkXG+uXvGjWEFDSROk5bZWG2SyFoQ5Z x-ms-exchange-antispam-srfa-diagnostics: SOS; x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020);SRVR:DM2PR0501MB1081; x-ms-traffictypediagnostic: DM2PR0501MB1081: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(21748063052155); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231254)(944501410)(52105095)(3002001)(10201501046)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123558120)(6072148)(201708071742011);SRVR:DM2PR0501MB1081;BCL:0;PCL:0;RULEID:;SRVR:DM2PR0501MB1081; x-forefront-prvs: 06607E485E x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(366004)(346002)(396003)(376002)(39860400002)(39380400002)(189003)(199004)(2906002)(106356001)(8936002)(105586002)(3280700002)(6116002)(14454004)(790700001)(6916009)(25786009)(72206003)(3846002)(3660700001)(53936002)(966005)(97736004)(7736002)(2351001)(478600001)(74316002)(6506007)(6306002)(81166006)(99286004)(81156014)(54896002)(9686003)(2900100001)(5640700003)(55016002)(8676002)(66066001)(1730700003)(68736007)(186003)(236005)(33656002)(2501003)(5630700001)(575784001)(59450400001)(6436002)(7696005)(102836004)(26005)(86362001)(486006)(5250100002)(606006)(316002)(476003)(5660300001)(505234006)(460985005);DIR:OUT;SFP:1101;SCL:1;SRVR:DM2PR0501MB1081;H:DM2PR0501MB1358.namprd05.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; x-microsoft-antispam-message-info: 2zAriM8PCcwAAcqpnBRjKBUIaLpBfq6qeVooKVvetV4A/pkTdbklnmqa4kk9HCoftINa9qgCMTga2Bs2oQX1lK8fhyXxcJsWebBSou9WH+VNWdQKrbe6Vtbg+nmWOWE+qeVAajIK4QPb/tlNOaRfXVBIGHMkbmfOj1BJrD0xg1XPygmg2IrEjXeR4jFNEC0+ spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 6c0007fe-b6c3-4921-135d-08d5b033908b X-OriginatorOrg: mathworks.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6c0007fe-b6c3-4921-135d-08d5b033908b X-MS-Exchange-CrossTenant-originalarrivaltime: 02 May 2018 13:49:45.3585 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 99dd3a11-4348-4468-9bdd-e5072b1dc1e6 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR0501MB1081 X-MC-Unique: -nnCdk10OHKRPGR7ZMWutA-1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by delorie.com id w42Do46b022385 Hi: While originally investigating a sporadic failure in MSYS2, I believe I found that its origin may actually be within Cygwin. Given the following command sequence on cygwin64 in a CMD.EXE command prompt (on Windows 10 x64 if it matters). cd C:\Cygwin64\bin echo.exe running \”test\” logging to ../../../my.log two problems appear: #1 – line 2802 in https://cygwin.com/git/gitweb.cgi?p=newlib-cygwin.git;a=blob;f=winsup/cygwin/path.cc;h=a132a0a7e0418ba921eefab72fade9930baadff3;hb=HEAD pointer ‘p’ will underflow if a backslash is not found in ‘path’. It may be that it finds an (unrelated) backslash in someone else’s buffer and fails benignly…but in MSYS2, I’ve see it bump up against unmapped address space a fail very cryptically (as an access violation early in dcrt0.cc initialization before the signal handler is installed). #2 – The reason it fails to find its expected backslash appears within path.cc again beginning on line 1381, when a drive-letter is inserted into destination path. Later in normalize_win32_path(), when “../” expressions are applied (i.e. lines 1421 and 1441), these calculations don’t take into account the size of the inserted drive letter (plus colon) and results in overwriting the top-most slash with pathname characters – which then exercises issue #1. If echo doesn’t crash, there doesn’t appear to be any obvious evidence of this error. In fact, from debugging a recent version of Cygwin’s “echo.exe”, it looked like the environment block occupying memory at a lower address than ‘path’ contained plenty of backslashes to break line 2802’s loop. In MSYS2, it seems occasionally (though not always), memory below ‘path’ pointer will _not_ contain a backslash. The result seems to be just C0000005 returned by the echo.exe process. I’m not familiar with how to build Cygwin so I haven’t verified this with putting an assert in code. I did debug echo.exe with WinDBG and following how the caller of NtCreateFile handles C0000034 return value (which least to the ‘p’ underflow), watched the disassembly for line 2802: cygwin1!setpassent+0x22a3: 00000001`800de563 8078ff5c cmp byte ptr [rax-1],5Ch ds:00000006`0000ffee=00 march down lower than the path string: 00000006`0000fff0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .................. 00000006`00010002 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .................. 00000006`00010014 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .................. 00000006`00010026 00 00 13 80 00 00 00 00 00 00 43 3a 43 6d 79 2e 6c 6f ..........C:Cmy.lo 00000006`00010038 67 00 20 46 69 6c 65 73 5c 4d 41 54 4c 41 42 00 52 32 g. Files\MATLAB.R2 00000006`0001004a 30 31 38 62 00 6c 6e 6b 00 00 00 00 00 00 00 00 00 00 018b.lnk.......... 00000006`0001005c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .................. 00000006`0001006e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .................. Hope you find this of use. Thanks, -ken -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple