Artifacts Associated With Ticket 3544685fffffffffffffffffffffffffffffffff
Ticket change [e8c6a2dc37] (rid 104703) by stwo on 2012-07-16 17:50:18:
- assignee initialized to: "mistachkin"
- cmimetype initialized to: "text/plain"
- comment initialized to:
Trunk and 8.5.12rc0. async-4.3 fails on i386 and amd64 (sporadic) "Test file error: child killed: SIGABRT" interp-36.7 fails on i386 and amd64 event-14.1 fails on i386 (sporadic), difficult to reproduce, try repeatedly running the event tests with minimal delay between runs. I am currently able to reproduce this one with trunk but not 8.5.12rc0.
- foundin initialized to: "None"
- is_private initialized to: "0"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "stwo"
- subsystem initialized to: "49. Threading"
- title initialized to: "Threaded build failures on OpenBSD-current"
- type initialized to: "Bug"
Ticket change [38f1901dde] (rid 112300) by dgp on 2012-07-18 00:20:42:
- icomment:
What does the interp-36.7 failure look like?
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [9bf5ee81c8] (rid 111207) by dgp on 2012-07-18 00:49:53:
- foundin changed to: "obsolete: 8.5.12"
Ticket change [3787e4951b] (rid 107298) by stwo on 2012-07-19 11:20:20:
- icomment:
This is with 8.5.12rc1. I can't get info for async-4.3 anymore since it just SIGABRTs, I guess, but iirc the reason for failure was similar. ==== interp-36.7 SlaveBgerror sets error handler of slave [1999035] FAILED ==== Contents of test case: slave eval { variable done {} after 0 error foo after 10 [list ::set [namespace which -variable done] {}] vwait [namespace which -variable done] } set result ---- Result was: untouched ---- Result should have been (exact matching): foo ==== interp-36.7 FAILED - login: "stwo"
- mimetype: "text/plain"
- username: "stwo"
- icomment:
Ticket change [fa74261e77] (rid 91880) by dgp on 2012-07-19 20:57:36:
- icomment:
so, timing sensitivty could be an issue. Does it help to change the "after 10 ..." to "after 200 ..." ?
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [a6c1dc8240] (rid 98661) by stwo on 2012-07-19 22:00:06:
- icomment:
interp-36.7 passes if "after 10 ..." is changed to "after 200 ..."
- login: "stwo"
- mimetype: "text/plain"
- username: "stwo"
- icomment:
Ticket change [f884926bfa] (rid 91556) by stwo on 2012-07-19 23:03:24:
- icomment:
Re async-4.3: There may be a specific problem with async-4.3 but for now the SIGABRT comes from other code in async.test which can be boiled down to: $ make runtest % testasync delete [testasync create q] Abort trap (core dumped)
- login: "stwo"
- mimetype: "text/plain"
- username: "stwo"
- icomment:
Ticket change [1017944049] (rid 94910) by stwo on 2012-07-19 23:48:02:
- icomment:
The async test problems appear to be caused by an imperfect backport resulting in a mismatched mutex lock/unlock pair (lock was missing). Bug 2981154, checkin 15a55ecb19.
- login: "stwo"
- mimetype: "text/plain"
- username: "stwo"
- icomment:
Ticket change [bb8d3a5ab6] (rid 129506) by nijtmans on 2012-07-20 00:34:33:
- assignee changed to: "nijtmans"
- icomment:
Looks like you'r right. Fix committed to branch bug-3544685. Please test.
- login: "nijtmans"
- mimetype: "text/plain"
- username: "nijtmans"
Ticket change [9df7184c77] (rid 96399) by ferrieux on 2012-07-20 00:39:14:
- icomment:
Sorry, committed to trunk in the meantime. The chat is a nice place to synchronize ;)
- login: "ferrieux"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- username: "ferrieux"
- icomment:
Ticket change [14f369dec0] (rid 124483) by nijtmans on 2012-07-20 00:43:36:
- icomment:
No problem. I first assigned this issue to me, because it was still assigned to Joe. Now assigned to you, for handling it further.
- login: "nijtmans"
- mimetype: "text/plain"
- username: "nijtmans"
- icomment:
Ticket change [cedb7730f6] (rid 112855) by nijtmans on 2012-07-20 00:43:37:
- assignee changed to: "ferrieux"
Ticket change [95ecc2046f] (rid 106234) by ferrieux on 2012-07-20 00:44:01:
- assignee changed to: "nijtmans"
- icomment:
Of course, by "trunk" I mean "tip", of core-8-5-branch.
- login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
Ticket change [957e552e60] (rid 106163) by ferrieux on 2012-07-20 00:46:37:
- assignee changed to: "ferrieux"
Ticket change [a18268539f] (rid 109726) by nijtmans on 2012-07-20 00:47:24:
- icomment:
> Of course, by "trunk" I mean "tip", of core-8-5-branch. Sure
- login: "nijtmans"
- mimetype: "text/plain"
- username: "nijtmans"
- icomment:
Ticket change [85aece4510] (rid 131360) by ferrieux on 2012-07-20 00:48:30:
- icomment:
Hum, this only fixes the elephant in the front chair. What's the status of the other failures reported here ?
- login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment:
Ticket change [78624328c9] (rid 89956) by nijtmans on 2012-07-20 00:54:04:
- icomment:
Stuart is the best person answering that first. That's why I put it in a branch ;-)
- login: "nijtmans"
- mimetype: "text/plain"
- username: "nijtmans"
- icomment:
Ticket change [2df194ce82] (rid 119140) by nijtmans on 2012-07-20 00:54:05:
- assignee changed to: "stwo"
Ticket change [b935760c46] (rid 129099) by ferrieux on 2012-07-20 01:08:31:
- icomment:
The fix was required, regardless of other lurking nasties. That's why I put it in the main 8.5 line. Anyway Stu, please update us now.
- login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment:
Ticket change [6b9fcb3111] (rid 128359) by stwo on 2012-07-20 01:57:10:
- icomment:
Async tests all pass now; the mutex lock was the thing needed, thanks. With the latest 8.5 trunk I just got an event-12.4 failure which looks like the other event failure and the interp one as well. Is it just a matter of the tests or is there a problem? I've never seen these errors in a non-threaded build. The event-12.4 failure looks like this: ==== event-12.4 Tcl_UpdateCmd procedure FAILED ==== Contents of test case: foreach i [after info] { after cancel $i } after 10; update; # On Mac make sure update won't take long after 200 {set x x-done} after 600 {set y y-done} after idle {set z z-done} set x before set y before set z before after 300 update list $x $y $z ---- Result was: x-done y-done z-done ---- Result should have been (exact matching): x-done before z-done ==== event-12.4 FAILED - login: "stwo"
- mimetype: "text/plain"
- username: "stwo"
- icomment:
Ticket change [c9ff398684] (rid 122386) by ferrieux on 2012-07-20 04:48:11:
- icomment:
Thanks to a ktrace output of a similar failure for event-11.4, here's a detailed analysis: event-11.4 is: after 10; update after 100 {set x x-done} after 200 {set y y-done} after 300 {set z z-done} after idle {set q q-done} => vwait on y and expect z to be not done yet the test fails because the pthread_condwait from 100 to 200 actually sees 500ms elapsed. As a consequence, the Tcl core immediately fires all due timers, including z. So my take is that on this system, mysterious chunks of 400ms get stolen by the system clock, or the PCLOCK_REALTIME mode of pthread_condwait is awfully buggy. - login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment:
Ticket change [b4f254b4c7] (rid 125142) by ferrieux on 2012-07-20 05:01:24:
- icomment:
Hum, scary: http://unix.derkeiler.com/Mailing-Lists/FreeBSD/stable/2012-02/msg00486.html
- login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment:
Ticket change [b1e5420a7c] (rid 98241) by ferrieux on 2012-07-20 05:03:23:
- icomment:
Even closer to our case: http://old.nabble.com/Possible-pthread_cond_timedwait()-regression-on-kfreebsd-i386-td33950701.html
- login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment:
Ticket change [76b7e81f74] (rid 105630) by dkf on 2012-07-20 18:00:05:
- icomment:
It's when you see suggested patches like http://unix.derkeiler.com/Mailing-Lists/FreeBSD/stable/2012-02/msg00538.html that you start to wonder...
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [35f048aafb] (rid 107032) by ferrieux on 2012-07-20 18:54:23:
- icomment:
I'm scared. Stu, what about switching over to the bright side now ?
- login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment:
Ticket change [df627382c6] (rid 115008) by stwo on 2012-07-20 20:35:44:
- icomment:
OpenBSD != FreeBSD != NetBSD. On OpenBSD, pthread_cond_timedwait() ends up at sys__thrsleep which is in kern/kern_synch.c. This little program appears to demonstrate that pthread_cond_timedwait() is ok. #define NS to use nanosleep instead of pthread_cond_timedwait(). #include <stdio.h> #include <unistd.h> #include <pthread.h> #include <errno.h> #include <time.h> extern int errno; pthread_mutex_t m; pthread_cond_t c; /*#define NS 1*/ void go (void) { struct timespec ts1, ts2, tts; int r; pthread_mutex_init(&m, NULL); pthread_cond_init(&c, NULL); pthread_mutex_lock(&m); clock_gettime(CLOCK_REALTIME, &ts1); #ifdef NS tts.tv_sec = 2; tts.tv_nsec = 200000000; r = nanosleep(&tts,NULL); #else tts.tv_sec = ts1.tv_sec + 2; tts.tv_nsec = ts1.tv_nsec + 200000000; r = pthread_cond_timedwait(&c, &m, &tts); #endif clock_gettime(CLOCK_REALTIME, &ts2); pthread_mutex_unlock(&m); #ifdef NS if (r != 0) { perror(NULL); return; } #else if (r != 0 && r != ETIMEDOUT) { errno = r; perror(NULL); return; } #endif printf("%d %ld\n", ts1.tv_sec, ts1.tv_nsec); printf("%d %ld\n", ts2.tv_sec, ts2.tv_nsec); } int main (int argc, char *argv[]) { go(); return 0; } - login: "stwo"
- mimetype: "text/plain"
- username: "stwo"
- icomment:
Ticket change [4a96871342] (rid 126559) by ferrieux on 2012-07-21 18:04:50:
- icomment:
Uh, sorry, but it's not testing exactly the same thing ;) In the ktrace you sent me, we see that Tcl is basically doing: gettimeofday(T1) clock_gettime(REALTIME,NOW) pthread_cond_timedwait(NOW+100ms) gettimeofday(T2) /* Oh ! T2-T1 is much bigger than 100ms !!! */ While it seems that your program uses clock_gettime(REALTIME) instead of gettimeofday (=> own dogfood) And with NS, it is testing yet another thing (discrepancies between the realtime clock and relative timers). If the bug is in the time comparison inside pthread_cond_timedwait, I don't expect such a discrepancy to exist; additionally, such an obvious shift between the two clocks would have been noticed elsewhere, not confined to pthread as the bug seems to be. Can you please retry a minimal test along the above lines ? Also, using the same order of magnitude (100ms) and many runs in a row could help reproduce the issue.
- login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment:
Ticket change [1f3c737a67] (rid 91114) by ferrieux on 2012-07-27 05:44:54:
- icomment:
Update: updated snippet and new ktrace by Stu; still no repro, but show something interesting by contrast: In fact, the Tcl sequence of syscalls does *not* include clock_gettime ! It is only based on gettimeofday. 1342727996.861547 CALL gettimeofday(0xcfbe1788,0) 1342727996.861558 STRU struct timeval { "Jul 19 15:59:56 2012".861555 } 1342727996.861565 RET gettimeofday 0 1342727996.861574 CALL __thrsleep(0x2e62abe0,CLOCK_REALTIME,0xcfbe17e4,0x83596ea0,0x2e62ac78) 1342727996.861584 STRU struct timespec { "Jul 19 15:59:56 2012".951731000 } *** 500ms delay, 400ms late !!! *** 1342727997.361283 RET __thrsleep 35/0x23 1342727997.361400 CALL gettimeofday(0xcfbe17d8,0) 1342727997.361430 STRU struct timeval { "Jul 19 15:59:57 2012".361426 } 1342727997.361441 RET gettimeofday 0 So for some reason Tcl trusts gettimeofday and pthread_cond_timedwait' s absolute target to be congruent. Maybe that plays a role in the bug. The log above shows another strange phenomenon (as if Time itself had slipped), but the analysis is muddied by the fact that we don't know which of the two clocks feeds the ktrace timestamps... - login: "ferrieux"
- mimetype: "text/plain"
- priority changed to: "8"
- username: "ferrieux"
- icomment:
Ticket change [70d36d19da] (rid 100559) by ferrieux on 2012-07-27 06:08:10:
- icomment:
Okay, after a bit of diving, it seems that clock_gettime(CLOCK_REALTIME) is the same as gettimeofday(), so maybe this difference is a red herring after all. Suggestions: (1) rewrite the snippet to use gettimeofday exclusively, incl. to compute the target of the pcond. Ktrace it to verify we get the same sequence as below (2) if the gaps are still not reproduced, it's tough since the original trace shows absolutely zero activity on other threads (of the tcltest process tree) during the gap... maybe other processes ? An interesting experiment would be to sync the system's clock (to the precision of an eye-and-finger, should be enough) to an outside wall clock; then wait for Tcl to show the gap ; then check the clocks. If the system clock has drifted by a visible amount (400ms in the previous tests), we have our analysis !
- login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment:
Ticket change [9b10666167] (rid 111061) by ferrieux on 2012-08-02 01:14:41:
- icomment:
Stu has just made the wall-clock experiment. Executive summary: no system clock drift. Details: (1) Get timestamp on a wall-clock minute boundary (2) make several failing tests, under ktrace, verifying the above gap in pthread_condwait's actual delay (3) Get 2nd minute-aligned timestamp Result: delta is 119.88, which to the precision of eye and finger is 2mn. (and any drift would have been in the other direction). Conclusion: pthread_condwait alone (not the system clock) has a problem. I suggest to try the patch mentioned earlier (the one Donal found, about second/nanosecond arithmetic)
- login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment:
Ticket change [ca0c978b5b] (rid 143462) by jan.nijtmans on 2015-10-07 14:07:37:
- closer changed to: "nobody"
- comment changed to:
Trunk and 8.5.12rc0. async-4.3 fails on i386 and amd64 (sporadic) "Test file error: child killed: SIGABRT" interp-36.7 fails on i386 and amd64 event-14.1 fails on i386 (sporadic), difficult to reproduce, try repeatedly running the event tests with minimal delay between runs. I am currently able to reproduce this one with trunk but not 8.5.12rc0.
- icomment:
Status? I think this one is fixed now (as "Resolution" suggests), but why is it still Open?
- login: "jan.nijtmans"
- mimetype: "text/plain"
- severity changed to: "Minor"
Ticket change [bd2e82bc98] (rid 143464) by stwo on 2015-10-07 16:30:23:
- icomment:
The async behaviour in a couple of the Tcl tests in a threaded tclsh is not 100% predictable. So there isn't really a bug in Tcl but since the symptoms still persist I left the ticket open as a reminder.
- login: "stwo"
- mimetype: "text/plain"
- username: "stwo"
- icomment:
Ticket change [68627e7046] (rid 258387) by serhiy.storchaka on 2026-10-17 06:24:49:
- foundin changed to: "9.0.5, 9.1.0"
- icomment:
async-4.3 has not been run outside MSVC builds since [c0c61fa7cf] (2021): the knownMsvcBug constraint became true on MSVC instead of false. It passes on OpenBSD 7.9 (main, 10 of 10 runs) and on Linux (20 of 20 runs) with the constraint fixed in branch [/timeline?r=async-test-msvc-constraint|async-test-msvc-constraint].
- login: "serhiy.storchaka"
- mimetype: "text/x-fossil-wiki"
Ticket change [d8e17c2e92] (rid 259257) by serhiy.storchaka on 2026-10-19 11:58:16:
- login: "serhiy.storchaka"
- resolution changed to: "Fixed"
- status changed to: "Closed"
Ticket change [263cc4abe0] (rid 259961) by serhiy.storchaka on 2026-10-22 17:19:27:
- closedate changed to: "2461332.998807477"
- closer changed to: "serhiy.storchaka"
- login: "serhiy.storchaka"