From: Ken M. <ken...@sp...> - 2010-06-30 21:01:24
|
Hello, I am trying to use thread pools to run jobs concurrently on OS X 10.6. The tclsh says that patchlevel is 8.5.7, and the Thread package is version 2.6.5. I had to patch the Thread package because tpool::create would always crash, due to a buffer being too small (I believe this is already patched in CVS - see http://sourceforge.net/ tracker/?func=detail&aid=2833864&group_id=10894&atid=110894). Here is a simplified version of my code: package require Thread set pool [tpool::create -maxworkers 4] set joblist [list] foreach job <jobs to do> { lappend joblist [tpool::post $pool $job] } foreach job $joblist { tpool::wait $pool $job if {[catch {tpool::get $pool $job} m]} { puts "Error: $m" exit 1 } } while {[tpool::release $pool]} {} Usually everything works fine. However, occasionally the interpreter will crash in Tcl_FinalizeThread - either a segfault or an abort. Is there something I am doing wrong? I have crash dump output: ======== Segfault: ======== Process: tclsh8.5 [36473] Path: /System/Library/Frameworks/Tcl.framework/Versions/ 8.5/tclsh8.5 Identifier: tclsh8.5 Version: ??? (???) Code Type: X86-64 (Native) Parent Process: tclsh8.5 [36454] Date/Time: 2010-06-30 12:55:19.890 -0700 OS Version: Mac OS X 10.6.3 (10D573) Report Version: 6 Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000017 Crashed Thread: 4 Thread 0: Dispatch queue: com.apple.main-thread 0 dyld 0x00007fff5fc0d6ab ImageLoaderMachO::getExportedSymbolAddress(ImageLoader::Symbol const*, ImageLoader::LinkContext const&, ImageLoader const*) const + 1 1 dyld 0x00007fff5fc12dc0 ImageLoaderMachOCompressed::resolve(ImageLoader::LinkContext const&, char const*, unsigned char, int, ImageLoader const**, ImageLoaderMachOCompressed::LastLookup*) + 208 2 dyld 0x00007fff5fc1698e ImageLoaderMachOCompressed::doBindFastLazySymbol(unsigned int, ImageLoader::LinkContext const&) + 238 3 dyld 0x00007fff5fc04783 dyld::fastBindLazySymbol(ImageLoader**, unsigned long) + 98 4 libSystem.B.dylib 0x00007fff864bf01e dyld_stub_binder + 118 5 ??? 0x00000001000e4010 0 + 4295901200 6 Tcl 0x000000010004b31f Tcl_Finalize + 249 7 Tcl 0x000000010004b414 Tcl_Exit + 89 8 Tcl 0x000000010001c0c1 Tcl_Alloc + 8021 9 Tcl 0x0000000100016559 Tcl_CreateInterp + 4820 10 Tcl 0x000000010004e2eb TclStackAlloc + 6637 11 Tcl 0x0000000100054fae TclStackAlloc + 34480 12 Tcl 0x0000000100017ad7 TclEvalObjEx + 714 13 Tcl 0x000000010007339c Tcl_Main + 2237 14 tclsh 0x00000001000019d0 0x100000000 + 6608 15 tclsh 0x0000000100001978 0x100000000 + 6520 Thread 1: Dispatch queue: com.apple.libdispatch-manager 0 libSystem.B.dylib 0x00007fff863d04ea kevent + 10 1 libSystem.B.dylib 0x00007fff863d23bd _dispatch_mgr_invoke + 154 2 libSystem.B.dylib 0x00007fff863d2094 _dispatch_queue_invoke + 185 3 libSystem.B.dylib 0x00007fff863d1bbe _dispatch_worker_thread2 + 252 4 libSystem.B.dylib 0x00007fff863d14e8 _pthread_wqthread + 353 5 libSystem.B.dylib 0x00007fff863d1385 start_wqthread + 13 Thread 2: 0 libSystem.B.dylib 0x00007fff863d130a __workq_kernreturn + 10 1 libSystem.B.dylib 0x00007fff863d171c _pthread_wqthread + 917 2 libSystem.B.dylib 0x00007fff863d1385 start_wqthread + 13 Thread 3: 0 libSystem.B.dylib 0x00007fff863fb286 select $DARWIN_EXTSN + 10 1 Tcl 0x00000001000abd86 Tcl_InitNotifier + 1520 2 libSystem.B.dylib 0x00007fff863f08b6 _pthread_start + 331 3 libSystem.B.dylib 0x00007fff863f0769 thread_start + 13 Thread 4 Crashed: 0 Tcl 0x0000000100059ae5 Tcl_CreateHashEntry + 231 1 Tcl 0x0000000100093b37 TclpRealloc + 1270 2 Tcl 0x0000000100092b84 Tcl_GetThreadData + 31 3 Tcl 0x000000010007a4bb Tcl_CreateEventSource + 137 4 Tcl 0x000000010004b046 Tcl_FinalizeThread + 77 5 Tcl 0x00000001000928f1 Tcl_ExitThread + 16 6 libthread2.6.5.dylib 0x00000001001caa3d TpoolWorker + 860 7 libSystem.B.dylib 0x00007fff863f08b6 _pthread_start + 331 8 libSystem.B.dylib 0x00007fff863f0769 thread_start + 13 Thread 4 crashed with X86 Thread State (64-bit): rax: 0x0000000100308610 rbx: 0x0000000100307ba0 rcx: 0x000000000000001a rdx: 0x0000000000000000 rdi: 0x0000000100307ba0 rsi: 0x00000001000edce0 rbp: 0x0000000100698d90 rsp: 0x0000000100698d40 r8: 0x0000000101035618 r9: 0x0000000000000001 r10: 0x00007fff863b77a2 r11: 0x0000000000000246 r12: 0x0000000000000007 r13: 0x00000000000edce0 r14: 0x0000000000000000 r15: 0x00000001000edce0 rip: 0x0000000100059ae5 rfl: 0x0000000000010202 cr2: 0x0000000000000017 ======== Abort: ======== Process: tclsh8.5 [36499] Path: /System/Library/Frameworks/Tcl.framework/Versions/ 8.5/tclsh8.5 Identifier: tclsh8.5 Version: ??? (???) Code Type: X86-64 (Native) Parent Process: tclsh8.5 [36498] Date/Time: 2010-06-30 12:55:24.311 -0700 OS Version: Mac OS X 10.6.3 (10D573) Report Version: 6 Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Crashed Thread: 4 Application Specific Information: abort() called Thread 0: Dispatch queue: com.apple.main-thread 0 Tcl 0x0000000100093501 TclpFree + 165 1 Tcl 0x000000010007135c TclAddLiteralObj + 791 2 Tcl 0x000000010004b324 Tcl_Finalize + 254 3 Tcl 0x000000010004b414 Tcl_Exit + 89 4 Tcl 0x000000010001c0c1 Tcl_Alloc + 8021 5 Tcl 0x0000000100016559 Tcl_CreateInterp + 4820 6 Tcl 0x000000010004e2eb TclStackAlloc + 6637 7 Tcl 0x0000000100054fae TclStackAlloc + 34480 8 Tcl 0x0000000100017ad7 TclEvalObjEx + 714 9 Tcl 0x000000010007339c Tcl_Main + 2237 10 tclsh 0x00000001000019d0 0x100000000 + 6608 11 tclsh 0x0000000100001978 0x100000000 + 6520 Thread 1: Dispatch queue: com.apple.libdispatch-manager 0 libSystem.B.dylib 0x00007fff863d04ea kevent + 10 1 libSystem.B.dylib 0x00007fff863d23bd _dispatch_mgr_invoke + 154 2 libSystem.B.dylib 0x00007fff863d2094 _dispatch_queue_invoke + 185 3 libSystem.B.dylib 0x00007fff863d1bbe _dispatch_worker_thread2 + 252 4 libSystem.B.dylib 0x00007fff863d14e8 _pthread_wqthread + 353 5 libSystem.B.dylib 0x00007fff863d1385 start_wqthread + 13 Thread 2: 0 libSystem.B.dylib 0x00007fff863d130a __workq_kernreturn + 10 1 libSystem.B.dylib 0x00007fff863d171c _pthread_wqthread + 917 2 libSystem.B.dylib 0x00007fff863d1385 start_wqthread + 13 Thread 3: 0 libSystem.B.dylib 0x00007fff863fb286 select $DARWIN_EXTSN + 10 1 Tcl 0x00000001000abd86 Tcl_InitNotifier + 1520 2 libSystem.B.dylib 0x00007fff863f08b6 _pthread_start + 331 3 libSystem.B.dylib 0x00007fff863f0769 thread_start + 13 Thread 4 Crashed: 0 libSystem.B.dylib 0x00007fff8642a01e __semwait_signal_nocancel + 10 1 libSystem.B.dylib 0x00007fff86429f20 nanosleep $NOCANCEL + 129 2 libSystem.B.dylib 0x00007fff86486902 usleep $NOCANCEL + 57 3 libSystem.B.dylib 0x00007fff864a5eb8 abort + 93 4 Tcl 0x000000010007cbb8 Tcl_Panic + 0 5 Tcl 0x000000010007cc5a Tcl_Panic + 162 6 Tcl 0x0000000100059dbe Tcl_DeleteHashTable + 250 7 Tcl 0x0000000100093a2f TclpRealloc + 1006 8 Tcl 0x0000000100093b2e TclpRealloc + 1261 9 Tcl 0x000000010004b00c Tcl_FinalizeThread + 19 10 Tcl 0x00000001000928f1 Tcl_ExitThread + 16 11 libthread2.6.5.dylib 0x00000001001caa3d TpoolWorker + 860 12 libSystem.B.dylib 0x00007fff863f08b6 _pthread_start + 331 13 libSystem.B.dylib 0x00007fff863f0769 thread_start + 13 Thread 4 crashed with X86 Thread State (64-bit): rax: 0x000000000000003c rbx: 0x000000010071bc30 rcx: 0x000000010071bbe8 rdx: 0x0000000000000001 rdi: 0x0000000000000c03 rsi: 0x0000000000000000 rbp: 0x000000010071bc20 rsp: 0x000000010071bbe8 r8: 0x0000000000000000 r9: 0x0000000000989680 r10: 0x0000000000000001 r11: 0x0000000000000246 r12: 0x0000000000000000 r13: 0x00000001000b66b7 r14: 0x00000001000b669c r15: 0x000000000000004c rip: 0x00007fff8642a01e rfl: 0x0000000000000247 cr2: 0x0000000101178700 Thanks, -Ken |