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:date:from:reply-to:message-id:to:subject :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=Wv/PrJvtMoIJWYDIZsOpA3J/9AFoFvpCRoVGOy1rYNDdhZNWuS2es nVMRj6jJ+7vZfmmZ3EH5nuqdy2FN6seQNPmtUrZRjJyh9Oqm/Vhj3dQjYC9x2xph nCztZ05Lhbct+bLN7EaV4s28lFwea0Ny3i0VSz1doZvpVn4xD3vLE0= 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:date:from:reply-to:message-id:to:subject :mime-version:content-type:content-transfer-encoding; s=default; bh=RLug5xwo5RBVvjIVIs8mrndH2sI=; b=wS1ziV0dNBKAnG55mkAKYjV8Xn6h yiK0EDm2Gq6LLvlvx6q8GxE2TmN5jAyfZH5Wz32FNg/jkLzdhxrgeOAT2R1BIOs0 ua+X0kUYwaIb5TT55JsLvPaoGL8O1PtVmmEwSCSKhQY5qag7BywhU1mXdcQwzqZk W1480WyKnYx9IOo= 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=0.8 required=5.0 tests=BAYES_50,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-HELO: wp389.webpack.hosteurope.de Date: Fri, 9 Jan 2015 19:48:25 -0800 From: Ivan Shcherbakov Reply-To: Ivan Shcherbakov Message-ID: <407424850.20150109194825@shcherbakov.info> To: cygwin AT cygwin DOT com Subject: SetupDiGetDeviceRegistryProperty problems on Windows 8 MIME-Version: 1.0 Content-Type: text/plain; charset=windows-1251 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id t0A3n8IS001006 Hi All, I’ve recently discovered a strange Cygwin bug on Windows 8. Calling SetupDiGetDeviceRegistryProperty() from a Cygwin thread created with pthread_create() causes it fail unconditionally. This actually breaks libusb for any program that uses it outside the main thread. The bug can be reproduced with a small program below. Could anyone please advise me if this could be fixed in one of the next Cygwin releases? Best regards, Ivan Shcherbakov Repro case (g ++ thread_repro.cpp -o thread_repro.exe -lsetupapi && ./thread_repro): #include #include #include #include void list_devices(int maxCount) { HDEVINFO hDevInfo = SetupDiGetClassDevs(NULL, NULL, NULL, DIGCF_PRESENT | DIGCF_ALLCLASSES); SP_DEVINFO_DATA devinfo = { sizeof(devinfo) }; for (int i = 0; i < maxCount && SetupDiEnumDeviceInfo(hDevInfo, i, &devinfo); i++) { DWORD dataType = 0; char szData[1024] = { 0, }; if (SetupDiGetDeviceRegistryPropertyA(hDevInfo, &devinfo, SPDRP_HARDWAREID, &dataType, (BYTE *) szData, sizeof(szData), NULL)) printf("%d: %s\n", i, szData); else printf("%d - error %d\n", i, GetLastError()); devinfo.cbSize = sizeof(devinfo); } SetupDiDestroyDeviceInfoList(hDevInfo); } void* thread_body(void *) { printf("Listing devices from a pthread\n"); list_devices(10); return 0; } int main() { printf("Listing devices from the main thread\n"); list_devices(10); pthread_t t; pthread_create(&t, NULL, thread_body, 0); pthread_join(t, NULL); return 0; } The output on Windows 8: Listing devices from the main thread 0: USB\VID_0E0F&PID_0007&REV_0100 1: ACPI\VEN_PNP&DEV_0100 2: STORAGE\Volume 3: PCI\VEN_15AD&DEV_07A0&SUBSYS_07A015AD&REV_01 4: PCI\VEN_15AD&DEV_07A0&SUBSYS_07A015AD&REV_01 5: PCI\VEN_15AD&DEV_07A0&SUBSYS_07A015AD&REV_01 6: PCI\VEN_15AD&DEV_07A0&SUBSYS_07A015AD&REV_01 7: PCI\VEN_15AD&DEV_07A0&SUBSYS_07A015AD&REV_01 8: PCI\VEN_15AD&DEV_07A0&SUBSYS_07A015AD&REV_01 9: PCI\VEN_15AD&DEV_07A0&SUBSYS_07A015AD&REV_01 Listing devices from a pthread 0 - error 13 1 - error 13 2 - error 13 3 - error 13 4 - error 13 5 - error 13 6 - error 13 7 - error 13 8 - error 13 9 - error 13 -- 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