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:message-id:date:from:mime-version:to:subject :content-type; q=dns; s=default; b=Z1FKFuTpOFXn72Py2qjz+kX2/8Mmt b0zUOlyXMLALP+bR0R6ZOFavNnUsGNRF1S/KYRHkTS78RswgISx9gGXpWgekHrVi oM+9K4VucIBaqkddjMpNZK/tIa2IBPXPZn5Ouidmet0ROZEfWGDGCxzUR9SyFI9z zHDoF8rzoBbhhs= 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:message-id:date:from:mime-version:to:subject :content-type; s=default; bh=/lqtfDAVW2fRz8S+f1IMpmF5IlE=; b=mrE 8zVBKeYAEOTSRA6GRLq6I2L90jA3thykW5m2dPv49keFXsKB/PgwZva/1Ad3nu8n 9CECk6CApJvOpdLCVmMqzCGKR3cEWTrIu0TupZ7+SBl4uIX7Tcd8HfmDa3py/nks VuUTFoCVgOFCmmuo3t4VofgDFkFFJT2B7mRhV0cE= 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.5 required=5.0 tests=AWL,BAYES_50,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-HELO: smtpout08.bt.lon5.cpcloud.co.uk X-CTCH-RefID: str=0001.0A090207.52A4AE0A.000A,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0 X-Junkmail-Premium-Raw: score=28/97,refid=2.7.2:2013.12.8.155114:17:28.394,ip=86.174.32.56,rules=__MOZILLA_MSGID, __HAS_MSGID, __SANE_MSGID, __HAS_FROM, __USER_AGENT, __MOZILLA_USER_AGENT, __MIME_VERSION, __TO_MALFORMED_2, __TO_NO_NAME, __CT, __CTYPE_HAS_BOUNDARY, __CTYPE_MULTIPART, __CTYPE_MULTIPART_MIXED, __BAT_BOUNDARY, __ANY_URI, __URI_NO_MAILTO, __URI_NO_WWW, __URI_NO_PATH, __CP_NOT_1, BODYTEXTP_SIZE_3000_LESS, BODY_SIZE_2000_2999, __MIME_TEXT_ONLY, RDNS_GENERIC_POOLED, SXL_IP_DYNAMIC[56.32.174.86.fur], HTML_00_01, HTML_00_10, BODY_SIZE_5000_LESS, RDNS_SUSP_GENERIC, RDNS_SUSP, BODY_SIZE_7000_LESS, MIME_TEXT_ONLY_MP_MIXED X-CTCH-Spam: Unknown Message-ID: <52A4AE10.8080303@dronecode.org.uk> Date: Sun, 08 Dec 2013 17:36:16 +0000 From: Jon TURNEY User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Signal occasionally causes thread inside win32 api to be suspended? Content-Type: multipart/mixed; boundary="------------080508060406030003070107" --------------080508060406030003070107 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit I don't really understand the intricacies of cygwin signal delivery, but I see that it can suspend the target thread to determine if it's in a safe place to deliver the signal (outside a win32 API call). I think that sometimes the thread is not correctly resumed. This appears to be the cause of been a long-standing problem with the X.org X server on cygwin, which we work around by disabling smart-scheduling (no great loss), but I've only just recently understood enough about the problem to produce a STC. If you run the attached for a while, it stops. According to Process Hacker, the main thread is in the suspended state, inside ntdll.dll. e.g.: $ uname -a CYGWIN_NT-5.1 byron 1.7.26(0.271/5/3) 2013-11-29 11:25 i686 Cygwin $ ./signal-in-kernel32 hMod is 0x7c800000 iteration 1 [...] iteration 139325 # stops! --------------080508060406030003070107 Content-Type: text/plain; charset=windows-1252; name="signal-in-kernel32.c" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="signal-in-kernel32.c" #include #include #include #include #include long SmartScheduleInterval = 20; /* ms */ long SmartScheduleTime = 0; static void SmartScheduleTimer(int sig) { SmartScheduleTime += SmartScheduleInterval; } void SmartScheduleStartTimer(void) { struct itimerval timer; timer.it_interval.tv_sec = 0; timer.it_interval.tv_usec = SmartScheduleInterval * 1000; timer.it_value.tv_sec = 0; timer.it_value.tv_usec = SmartScheduleInterval * 1000; setitimer(ITIMER_REAL, &timer, 0); } int main() { /* Set up the timer signal function */ struct sigaction act; act.sa_handler = SmartScheduleTimer; sigemptyset(&act.sa_mask); sigaddset(&act.sa_mask, SIGALRM); if (sigaction(SIGALRM, &act, 0) < 0) { perror("sigaction failed"); return -1; } HMODULE hMod = LoadLibraryEx("kernel32.dll", NULL, 0); assert(hMod); printf("hMod is %p\n", hMod); /* start timer */ SmartScheduleStartTimer(); /* Loop forever, spending most of our time inside ntdll */ int i = 0; while (1) { void *gpa = GetProcAddress(hMod, "GetProcAddress"); assert(gpa); i++; printf("iteration %d\n", i); } } --------------080508060406030003070107 Content-Type: text/plain; charset=us-ascii -- 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 --------------080508060406030003070107--