Friday, December 19, 2014

Crashing Outlook: _WTFCrash and the WTF Namespace

Copy/pasted a long terminal session into an Outlook 14.4.6 (OS X Office 2011) message, and it crashed. Best part are the _WTFCrash and WTF namespace Microsoft uses:


Microsoft Error Reporting log version: 2.0

Error Signature:
Exception: EXC_BAD_ACCESS
Date/Time: 2014-12-19 17:55:49 +0000
Application Name: Microsoft Outlook
Application Bundle ID: com.microsoft.Outlook
Application Signature: OPIM
Application Version: 14.4.6.141106
Crashed Module Name: JavaScriptCore
Crashed Module Version: 9537.78.1
Crashed Module Offset: 0x0027ab23
Blame Module Name: Microsoft Outlook
Blame Module Version: 14.4.6.141106
Blame Module Offset: 0x000611ad
Application LCID: 1033
Extra app info: Reg=en Loc=0x0409
Crashed thread: 0


Thread 0 crashed:

#  1  0x9670eb23 in _WTFCrash + 0x00000043 (JavaScriptCore + 0x0027ab23)
#  2  0x96495ef1 in WTF::fastMalloc(unsigned long) + 0x00000701 (JavaScriptCore + 0x00001ef1)
#  3  0x9649d90d in WTF::StringImpl::create(unsigned short const*, unsigned int) + 0x0000003D (JavaScriptCore + 0x0000990d)
#  4  0x967dd035 in WTF::String::String(NSString*) + 0x000001C5 (WebCore + 0x00002035)
#  5  0x96e39d0f in -[DOMHTMLElement setInnerHTML:] + 0x0000003F (WebCore + 0x0065ed0f)
#  6  0x9b8a91e1 in -[NSHTMLWriter readDocumentFragment:] + 0x00000231 (AppKit + 0x005b21e1)
#  7  0x9b8a9286 in -[NSHTMLWriter documentFragmentForDocument:] + 0x00000042 (AppKit + 0x005b2286)
#  8  0x9b6f2943 in -[NSAttributedString(NSAttributedStringKitAdditions) _documentFromRange:document:documentAttributes:subresources:] + 0x000000C0 (AppKit + 0x003fb943)
#  9  0x9899c571 in WebEditorClient::documentFragmentFromAttributedString(NSAttributedString*, WTF::Vector<WTF::RefPtr<WebCore::ArchiveResource>, 0ul, WTF::CrashOnOverflow>&) + 0x00000211 (WebKit + 0x0005a571)
# 10  0x97359a9e in WebCore::documentFragmentWithRTF(WebCore::Frame*, NSString*, WTF::String const&) + 0x0000029E (WebCore + 0x00b7ea9e)
# 11  0x97358536 in WebCore::Pasteboard::documentFragment(WebCore::Frame*, WTF::PassRefPtr<WebCore::Range>, bool, bool&) + 0x00000E96 (WebCore + 0x00b7d536)
# 12  0x96e8c496 in WebCore::Editor::pasteWithPasteboard(WebCore::Pasteboard*, bool) + 0x000000C6 (WebCore + 0x006b1496)
# 13  0x96e81873 in WebCore::Editor::paste() + 0x000000A3 (WebCore + 0x006a6873)
# 14  0x96e8a88e in WebCore::executePaste(WebCore::Frame*, WebCore::Event*, WebCore::EditorCommandSource, WTF::String const&) + 0x0000003E (WebCore + 0x006af88e)
# 15  0x96bec7c5 in WebCore::Editor::Command::execute(WTF::String const&, WebCore::Event*) const + 0x000000C5 (WebCore + 0x004117c5)
# 16  0x9897314f in -[WebHTMLView executeCoreCommandBySelector:] + 0x0000008F (WebKit + 0x0003114f)
# 17  0x989738d8 in -[WebHTMLView paste:] + 0x00000028 (WebKit + 0x000318d8)
# 18  0x9549a2af in -[NSObject performSelector:withObject:] + 0x00000046 (libobjc.A.dylib + 0x0001a2af)
# 19  0x9b54b8a5 in -[NSApplication sendAction:to:from:] + 0x000001B6 (AppKit + 0x002548a5)
# 20  0x9b567c65 in -[NSMenuItem _corePerformAction] + 0x000001E6 (AppKit + 0x00270c65)
# 21  0x9b56796a in -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 0x000000A3 (AppKit + 0x0027096a)
# 22  0x9b567021 in -[NSMenu _performActionWithHighlightingForItemAtIndex:sendAccessibilityNotification:] + 0x0000004F (AppKit + 0x00270021)
# 23  0x9b566fcd in -[NSMenu _performActionWithHighlightingForItemAtIndex:] + 0x00000030 (AppKit + 0x0026ffcd)
# 24  0x9b566972 in -[NSMenu performKeyEquivalent:] + 0x00000126 (AppKit + 0x0026f972)
# 25  0x9b563095 in -[NSApplication _handleKeyEquivalent:] + 0x000003AA (AppKit + 0x0026c095)
# 26  0x9b4cc8a2 in -[NSApplication sendEvent:] + 0x00000F47 (AppKit + 0x001d58a2)
# 27  0x000b81ad in long OPF::CopyProperty<OpaqueSavedSpotlightSearch>(OpaqueContext*, OpaqueSavedSpotlightSearch const*, PropertyAccessor<CUnicodeString, OPF::Traits<OpaqueSavedSpotlightSearch>::SharableType>::GetProp, char const*, __CFString const**) + 0x0001A543 (Microsoft Outlook + 0x000611ad)
# 28  0x9b3111bc in -[NSApplication run] + 0x00000337 (AppKit + 0x0001a1bc)
# 29  0x9b2f9ff8 in _NSApplicationMain + 0x0000048D (AppKit + 0x00002ff8)
# 30  0x0005ae0e in CSharablePtr<CNetHostOption>::Set(CNetHostOption*) + 0x000001E0 (Microsoft Outlook + 0x00003e0e)

X86 Thread State:
 eax: 0x00000000  ebx: 0x964957fe  ecx: 0x039aa300  edx:0x000b2260
 edi: 0x00000000  esi: 0xa0b3dbb0  ebp: 0xbffa7fa8  esp:0xbffa7f10
  ss: 0x00000023  eip: 0x9670eb23   cs: 0x0000001b   ds:0x00000023
  es: 0x00000023   fs: 0x00000000   gs: 0x0000000f  eflags:0x00010286


Thread 1:

#  1  0x98304992 in _kevent64 + 0x0000000A (libsystem_kernel.dylib + 0x00018992)
#  2  0x97c37532 in __dispatch_mgr_init + 0x00000000 (libdispatch.dylib + 0x00003532)

X86 Thread State:
 eax: 0x00000171  ebx: 0xb00926a0  ecx: 0xb009267c  edx:0x98304992
 edi: 0xb00926a0  esi: 0x97c377b9  ebp: 0xb00926f8  esp:0xb009267c
  ss: 0x00000023  eip: 0x98304992   cs: 0x0000000b   ds:0x00000023
  es: 0x00000023   fs: 0x00000023   gs: 0x0000000f  eflags:0x00000286


Thread 2:

#  1  0x98303b76 in ___semwait_signal + 0x0000000A (libsystem_kernel.dylib + 0x00017b76)
#  2  0x9105ddc2 in _sleep$UNIX2003 + 0x0000002D (libsystem_c.dylib + 0x0007bdc2)
#  3  0x028e5992 in _MerpCreateSession + 0x00000B3F (merp + 0x00003992)
#  4  0x028e505e in _MerpCreateSession + 0x0000020B (merp + 0x0000305e)
#  5  0x028e4fe9 in _MerpCreateSession + 0x00000196 (merp + 0x00002fe9)
#  6  0x028e6586 in _MerpCreateSession + 0x00001733 (merp + 0x00004586)
#  7  0x980055fb in __pthread_body + 0x00000090 (libsystem_pthread.dylib + 0x000015fb)
#  8  0x98005485 in __pthread_struct_init + 0x00000000 (libsystem_pthread.dylib + 0x00001485)
#  9  0x9800acf2 in _thread_start + 0x00000022 (libsystem_pthread.dylib + 0x00006cf2)

X86 Thread State:
 eax: 0x0000014e  ebx: 0xb0218ad8  ecx: 0xb0218a6c  edx:0x98303b76
 edi: 0x9105deea  esi: 0xb0218ad0  ebp: 0xb0218ab8  esp:0xb0218a6c
  ss: 0x00000023  eip: 0x98303b76   cs: 0x0000000b   ds:0x00000023
  es: 0x00000023   fs: 0x00000023   gs: 0x0000000f  eflags:0x00000246


Thread 3:

#  1  0x982fef7a in _mach_msg_trap + 0x0000000A (libsystem_kernel.dylib + 0x00012f7a)
#  2  0x9a7bcbf9 in ___CFRunLoopServiceMachPort + 0x000000A9 (CoreFoundation + 0x00076bf9)
#  3  0x9a7bc1d1 in ___CFRunLoopRun + 0x00000571 (CoreFoundation + 0x000761d1)
#  4  0x9a7bb9ea in _CFRunLoopRunSpecific + 0x0000018A (CoreFoundation + 0x000759ea)
#  5  0x9a7bb84b in _CFRunLoopRunInMode + 0x0000007B (CoreFoundation + 0x0007584b)
#  6  0x9b4c8b88 in __NSEventThread + 0x0000011B (AppKit + 0x001d1b88)
#  7  0x980055fb in __pthread_body + 0x00000090 (libsystem_pthread.dylib + 0x000015fb)
#  8  0x98005485 in __pthread_struct_init + 0x00000000 (libsystem_pthread.dylib + 0x00001485)
#  9  0x9800acf2 in _thread_start + 0x00000022 (libsystem_pthread.dylib + 0x00006cf2)

X86 Thread State:
 eax: 0xffffffe1  ebx: 0xb031c048  ecx: 0xb031bf2c  edx:0x982fef7a
 edi: 0x00000c00  esi: 0x07000006  ebp: 0xb031bf68  esp:0xb031bf2c
  ss: 0x00000023  eip: 0x982fef7a   cs: 0x0000000b   ds:0x00000023
  es: 0x00000023   fs: 0x00000023   gs: 0x0000000f  eflags:0x00000206


Thread 4:

#  1  0x983037ca in ___psynch_cvwait + 0x0000000A (libsystem_kernel.dylib + 0x000177ca)
#  2  0x98009bd9 in _pthread_cond_wait$UNIX2003 + 0x00000047 (libsystem_pthread.dylib + 0x00005bd9)
#  3  0x964a5ae4 in JSC::BlockAllocator::blockFreeingThreadMain() + 0x00000114 (JavaScriptCore + 0x00011ae4)
#  4  0x9649ce1c in WTF::threadEntryPoint(void*) + 0x0000004C (JavaScriptCore + 0x00008e1c)
#  5  0x9649cdb0 in WTF::wtfThreadEntryPoint(void*) + 0x00000010 (JavaScriptCore + 0x00008db0)
#  6  0x980055fb in __pthread_body + 0x00000090 (libsystem_pthread.dylib + 0x000015fb)
#  7  0x98005485 in __pthread_struct_init + 0x00000000 (libsystem_pthread.dylib + 0x00001485)
#  8  0x9800acf2 in _thread_start + 0x00000022 (libsystem_pthread.dylib + 0x00006cf2)

X86 Thread State:
 eax: 0x00000131  ebx: 0x00000060  ecx: 0xb0420e6c  edx:0x983037ca
 edi: 0x00000800  esi: 0x00000701  ebp: 0xb0420ef8  esp:0xb0420e6c
  ss: 0x00000023  eip: 0x983037ca   cs: 0x0000000b   ds:0x00000023
  es: 0x00000023   fs: 0x00000023   gs: 0x0000000f  eflags:0x00000246


Thread 5:

#  1  0x983037ca in ___psynch_cvwait + 0x0000000A (libsystem_kernel.dylib + 0x000177ca)
#  2  0x98009bd9 in _pthread_cond_wait$UNIX2003 + 0x00000047 (libsystem_pthread.dylib + 0x00005bd9)
#  3  0x964a64eb in JSC::GCThread::waitForNextPhase() + 0x0000007B (JavaScriptCore + 0x000124eb)
#  4  0x964a6378 in JSC::GCThread::gcThreadMain() + 0x00000058 (JavaScriptCore + 0x00012378)
#  5  0x9649ce1c in WTF::threadEntryPoint(void*) + 0x0000004C (JavaScriptCore + 0x00008e1c)
#  6  0x9649cdb0 in WTF::wtfThreadEntryPoint(void*) + 0x00000010 (JavaScriptCore + 0x00008db0)
#  7  0x980055fb in __pthread_body + 0x00000090 (libsystem_pthread.dylib + 0x000015fb)
#  8  0x98005485 in __pthread_struct_init + 0x00000000 (libsystem_pthread.dylib + 0x00001485)
#  9  0x9800acf2 in _thread_start + 0x00000022 (libsystem_pthread.dylib + 0x00006cf2)

X86 Thread State:
 eax: 0x00000131  ebx: 0x00000860  ecx: 0xb04a2e5c  edx:0x983037ca
 edi: 0x00000e00  esi: 0x00000c00  ebp: 0xb04a2ee8  esp:0xb04a2e5c
  ss: 0x00000023  eip: 0x983037ca   cs: 0x0000000b   ds:0x00000023
  es: 0x00000023   fs: 0x00000023   gs: 0x0000000f  eflags:0x00000246


Thread 6:

#  1  0x983037ca in ___psynch_cvwait + 0x0000000A (libsystem_kernel.dylib + 0x000177ca)
#  2  0x98009bd9 in _pthread_cond_wait$UNIX2003 + 0x00000047 (libsystem_pthread.dylib + 0x00005bd9)
#  3  0x964a64eb in JSC::GCThread::waitForNextPhase() + 0x0000007B (JavaScriptCore + 0x000124eb)
#  4  0x964a6378 in JSC::GCThread::gcThreadMain() + 0x00000058 (JavaScriptCore + 0x00012378)
#  5  0x9649ce1c in WTF::threadEntryPoint(void*) + 0x0000004C (JavaScriptCore + 0x00008e1c)
#  6  0x9649cdb0 in WTF::wtfThreadEntryPoint(void*) + 0x00000010 (JavaScriptCore + 0x00008db0)
#  7  0x980055fb in __pthread_body + 0x00000090 (libsystem_pthread.dylib + 0x000015fb)
#  8  0x98005485 in __pthread_struct_init + 0x00000000 (libsystem_pthread.dylib + 0x00001485)
#  9  0x9800acf2 in _thread_start + 0x00000022 (libsystem_pthread.dylib + 0x00006cf2)

X86 Thread State:
 eax: 0x00000131  ebx: 0x00000860  ecx: 0xb0524e5c  edx:0x983037ca
 edi: 0x00000f00  esi: 0x00000c00  ebp: 0xb0524ee8  esp:0xb0524e5c
  ss: 0x00000023  eip: 0x983037ca   cs: 0x0000000b   ds:0x00000023
  es: 0x00000023   fs: 0x00000023   gs: 0x0000000f  eflags:0x00000246


Thread 7:

#  1  0x983037ca in ___psynch_cvwait + 0x0000000A (libsystem_kernel.dylib + 0x000177ca)
#  2  0x98009bd9 in _pthread_cond_wait$UNIX2003 + 0x00000047 (libsystem_pthread.dylib + 0x00005bd9)
#  3  0x964a64eb in JSC::GCThread::waitForNextPhase() + 0x0000007B (JavaScriptCore + 0x000124eb)
#  4  0x964a6378 in JSC::GCThread::gcThreadMain() + 0x00000058 (JavaScriptCore + 0x00012378)
#  5  0x9649ce1c in WTF::threadEntryPoint(void*) + 0x0000004C (JavaScriptCore + 0x00008e1c)
#  6  0x9649cdb0 in WTF::wtfThreadEntryPoint(void*) + 0x00000010 (JavaScriptCore + 0x00008db0)
#  7  0x980055fb in __pthread_body + 0x00000090 (libsystem_pthread.dylib + 0x000015fb)
#  8  0x98005485 in __pthread_struct_init + 0x00000000 (libsystem_pthread.dylib + 0x00001485)
#  9  0x9800acf2 in _thread_start + 0x00000022 (libsystem_pthread.dylib + 0x00006cf2)

X86 Thread State:
 eax: 0x00000131  ebx: 0x00000860  ecx: 0xb05a6e5c  edx:0x983037ca
 edi: 0x00001200  esi: 0x00000c00  ebp: 0xb05a6ee8  esp:0xb05a6e5c
  ss: 0x00000023  eip: 0x983037ca   cs: 0x0000000b   ds:0x00000023
  es: 0x00000023   fs: 0x00000023   gs: 0x0000000f  eflags:0x00000246


Thread 8:

#  1  0x983037ca in ___psynch_cvwait + 0x0000000A (libsystem_kernel.dylib + 0x000177ca)
#  2  0x98009bd9 in _pthread_cond_wait$UNIX2003 + 0x00000047 (libsystem_pthread.dylib + 0x00005bd9)
#  3  0x964a64eb in JSC::GCThread::waitForNextPhase() + 0x0000007B (JavaScriptCore + 0x000124eb)
#  4  0x964a6378 in JSC::GCThread::gcThreadMain() + 0x00000058 (JavaScriptCore + 0x00012378)
#  5  0x9649ce1c in WTF::threadEntryPoint(void*) + 0x0000004C (JavaScriptCore + 0x00008e1c)
#  6  0x9649cdb0 in WTF::wtfThreadEntryPoint(void*) + 0x00000010 (JavaScriptCore + 0x00008db0)
#  7  0x980055fb in __pthread_body + 0x00000090 (libsystem_pthread.dylib + 0x000015fb)
#  8  0x98005485 in __pthread_struct_init + 0x00000000 (libsystem_pthread.dylib + 0x00001485)
#  9  0x9800acf2 in _thread_start + 0x00000022 (libsystem_pthread.dylib + 0x00006cf2)

X86 Thread State:
 eax: 0x00000131  ebx: 0x00000860  ecx: 0xb0628e5c  edx:0x983037ca
 edi: 0x00001000  esi: 0x00000c00  ebp: 0xb0628ee8  esp:0xb0628e5c
  ss: 0x00000023  eip: 0x983037ca   cs: 0x0000000b   ds:0x00000023
  es: 0x00000023   fs: 0x00000023   gs: 0x0000000f  eflags:0x00000246


Thread 9:

#  1  0x983037ca in ___psynch_cvwait + 0x0000000A (libsystem_kernel.dylib + 0x000177ca)
#  2  0x98009bd9 in _pthread_cond_wait$UNIX2003 + 0x00000047 (libsystem_pthread.dylib + 0x00005bd9)
#  3  0x964a64eb in JSC::GCThread::waitForNextPhase() + 0x0000007B (JavaScriptCore + 0x000124eb)
#  4  0x964a6378 in JSC::GCThread::gcThreadMain() + 0x00000058 (JavaScriptCore + 0x00012378)
#  5  0x9649ce1c in WTF::threadEntryPoint(void*) + 0x0000004C (JavaScriptCore + 0x00008e1c)
#  6  0x9649cdb0 in WTF::wtfThreadEntryPoint(void*) + 0x00000010 (JavaScriptCore + 0x00008db0)
#  7  0x980055fb in __pthread_body + 0x00000090 (libsystem_pthread.dylib + 0x000015fb)
#  8  0x98005485 in __pthread_struct_init + 0x00000000 (libsystem_pthread.dylib + 0x00001485)
#  9  0x9800acf2 in _thread_start + 0x00000022 (libsystem_pthread.dylib + 0x00006cf2)

X86 Thread State:
 eax: 0x00000131  ebx: 0x00000860  ecx: 0xb06aae5c  edx:0x983037ca
 edi: 0x00001100  esi: 0x00000c00  ebp: 0xb06aaee8  esp:0xb06aae5c
  ss: 0x00000023  eip: 0x983037ca   cs: 0x0000000b   ds:0x00000023
  es: 0x00000023   fs: 0x00000023   gs: 0x0000000f  eflags:0x00000246


Thread 10:

#  1  0x983037ca in ___psynch_cvwait + 0x0000000A (libsystem_kernel.dylib + 0x000177ca)
#  2  0x98009bd9 in _pthread_cond_wait$UNIX2003 + 0x00000047 (libsystem_pthread.dylib + 0x00005bd9)
#  3  0x964a64eb in JSC::GCThread::waitForNextPhase() + 0x0000007B (JavaScriptCore + 0x000124eb)
#  4  0x964a6378 in JSC::GCThread::gcThreadMain() + 0x00000058 (JavaScriptCore + 0x00012378)
#  5  0x9649ce1c in WTF::threadEntryPoint(void*) + 0x0000004C (JavaScriptCore + 0x00008e1c)
#  6  0x9649cdb0 in WTF::wtfThreadEntryPoint(void*) + 0x00000010 (JavaScriptCore + 0x00008db0)
#  7  0x980055fb in __pthread_body + 0x00000090 (libsystem_pthread.dylib + 0x000015fb)
#  8  0x98005485 in __pthread_struct_init + 0x00000000 (libsystem_pthread.dylib + 0x00001485)
#  9  0x9800acf2 in _thread_start + 0x00000022 (libsystem_pthread.dylib + 0x00006cf2)

X86 Thread State:
 eax: 0x00000131  ebx: 0x00000860  ecx: 0xb072ce5c  edx:0x983037ca
 edi: 0x00000d00  esi: 0x00000c01  ebp: 0xb072cee8  esp:0xb072ce5c
  ss: 0x00000023  eip: 0x983037ca   cs: 0x0000000b   ds:0x00000023
  es: 0x00000023   fs: 0x00000023   gs: 0x0000000f  eflags:0x00000246


Thread 11:

#  1  0x982fef7a in _mach_msg_trap + 0x0000000A (libsystem_kernel.dylib + 0x00012f7a)
#  2  0x9a430186 in _YieldToThread + 0x00000146 (CarbonCore + 0x000bd186)
#  3  0x028ff412 in LThread::Yield(LThread const*) + 0x0000004C (PowerPlantCore + 0x00005412)
#  4  0x028fffb9 in LThread::YieldConsideringPriority() + 0x0000002F (PowerPlantCore + 0x00005fb9)
#  5  0x000d98b2 in  + 0x00004023 (Microsoft Outlook + 0x000828b2)
#  6  0x000d9863 in  + 0x00003FD4 (Microsoft Outlook + 0x00082863)
#  7  0x000d12d7 in  + 0x000006A2 (Microsoft Outlook + 0x0007a2d7)
#  8  0x028fff52 in LThread::DoEntry(void*) + 0x0000001E (PowerPlantCore + 0x00005f52)
#  9  0x9a42fe1c in _CooperativeThread + 0x00000131 (CarbonCore + 0x000bce1c)
# 10  0x980055fb in __pthread_body + 0x00000090 (libsystem_pthread.dylib + 0x000015fb)
# 11  0x98005485 in __pthread_struct_init + 0x00000000 (libsystem_pthread.dylib + 0x00001485)
# 12  0x9800acf2 in _thread_start + 0x00000022 (libsystem_pthread.dylib + 0x00006cf2)

X86 Thread State:
 eax: 0xffffffe1  ebx: 0xb039ede8  ecx: 0xb039ed7c  edx:0x982fef7a
 edi: 0x00000020  esi: 0x00000003  ebp: 0xb039edb8  esp:0xb039ed7c
  ss: 0x00000023  eip: 0x982fef7a   cs: 0x0000000b   ds:0x00000023
  es: 0x00000023   fs: 0x00000023   gs: 0x0000000f  eflags:0x00000206


Thread 12:

#  1  0x982fef7a in _mach_msg_trap + 0x0000000A (libsystem_kernel.dylib + 0x00012f7a)
#  2  0x9a430186 in _YieldToThread + 0x00000146 (CarbonCore + 0x000bd186)
#  3  0x028ff412 in LThread::Yield(LThread const*) + 0x0000004C (PowerPlantCore + 0x00005412)
#  4  0x028fffb9 in LThread::YieldConsideringPriority() + 0x0000002F (PowerPlantCore + 0x00005fb9)
#  5  0x000d98b2 in  + 0x00004023 (Microsoft Outlook + 0x000828b2)
#  6  0x000d9863 in  + 0x00003FD4 (Microsoft Outlook + 0x00082863)
#  7  0x000d12d7 in  + 0x000006A2 (Microsoft Outlook + 0x0007a2d7)
#  8  0x028fff52 in LThread::DoEntry(void*) + 0x0000001E (PowerPlantCore + 0x00005f52)
#  9  0x9a42fe1c in _CooperativeThread + 0x00000131 (CarbonCore + 0x000bce1c)
# 10  0x980055fb in __pthread_body + 0x00000090 (libsystem_pthread.dylib + 0x000015fb)
# 11  0x98005485 in __pthread_struct_init + 0x00000000 (libsystem_pthread.dylib + 0x00001485)
# 12  0x9800acf2 in _thread_start + 0x00000022 (libsystem_pthread.dylib + 0x00006cf2)

X86 Thread State:
 eax: 0xffffffe1  ebx: 0xb0934de8  ecx: 0xb0934d7c  edx:0x982fef7a
 edi: 0x00000020  esi: 0x00000003  ebp: 0xb0934db8  esp:0xb0934d7c
  ss: 0x00000023  eip: 0x982fef7a   cs: 0x0000000b   ds:0x00000023
  es: 0x00000023   fs: 0x00000023   gs: 0x0000000f  eflags:0x00000206


Thread 13:

#  1  0x982fef7a in _mach_msg_trap + 0x0000000A (libsystem_kernel.dylib + 0x00012f7a)
#  2  0x9a430186 in _YieldToThread + 0x00000146 (CarbonCore + 0x000bd186)
#  3  0x028ff412 in LThread::Yield(LThread const*) + 0x0000004C (PowerPlantCore + 0x00005412)
#  4  0x028fffb9 in LThread::YieldConsideringPriority() + 0x0000002F (PowerPlantCore + 0x00005fb9)
#  5  0x000d98b2 in  + 0x00004023 (Microsoft Outlook + 0x000828b2)
#  6  0x000d9863 in  + 0x00003FD4 (Microsoft Outlook + 0x00082863)
#  7  0x000d12d7 in  + 0x000006A2 (Microsoft Outlook + 0x0007a2d7)
#  8  0x028fff52 in LThread::DoEntry(void*) + 0x0000001E (PowerPlantCore + 0x00005f52)
#  9  0x9a42fe1c in _CooperativeThread + 0x00000131 (CarbonCore + 0x000bce1c)
# 10  0x980055fb in __pthread_body + 0x00000090 (libsystem_pthread.dylib + 0x000015fb)
# 11  0x98005485 in __pthread_struct_init + 0x00000000 (libsystem_pthread.dylib + 0x00001485)
# 12  0x9800acf2 in _thread_start + 0x00000022 (libsystem_pthread.dylib + 0x00006cf2)

X86 Thread State:
 eax: 0xffffffe1  ebx: 0xb09b6de8  ecx: 0xb09b6d7c  edx:0x982fef7a
 edi: 0x00000020  esi: 0x00000003  ebp: 0xb09b6db8  esp:0xb09b6d7c
  ss: 0x00000023  eip: 0x982fef7a   cs: 0x0000000b   ds:0x00000023
  es: 0x00000023   fs: 0x00000023   gs: 0x0000000f  eflags:0x00000206


Thread 14:

#  1  0x982fef7a in _mach_msg_trap + 0x0000000A (libsystem_kernel.dylib + 0x00012f7a)
#  2  0x9a430186 in _YieldToThread + 0x00000146 (CarbonCore + 0x000bd186)
#  3  0x028ff412 in LThread::Yield(LThread const*) + 0x0000004C (PowerPlantCore + 0x00005412)
#  4  0x028fffb9 in LThread::YieldConsideringPriority() + 0x0000002F (PowerPlantCore + 0x00005fb9)
#  5  0x000d98b2 in  + 0x00004023 (Microsoft Outlook + 0x000828b2)
#  6  0x000d9863 in  + 0x00003FD4 (Microsoft Outlook + 0x00082863)
#  7  0x000d12d7 in  + 0x000006A2 (Microsoft Outlook + 0x0007a2d7)
#  8  0x028fff52 in LThread::DoEntry(void*) + 0x0000001E (PowerPlantCore + 0x00005f52)
#  9  0x9a42fe1c in _CooperativeThread + 0x00000131 (CarbonCore + 0x000bce1c)
# 10  0x980055fb in __pthread_body + 0x00000090 (libsystem_pthread.dylib + 0x000015fb)
# 11  0x98005485 in __pthread_struct_init + 0x00000000 (libsystem_pthread.dylib + 0x00001485)
# 12  0x9800acf2 in _thread_start + 0x00000022 (libsystem_pthread.dylib + 0x00006cf2)

X86 Thread State:
 eax: 0xffffffe1  ebx: 0xb0a38de8  ecx: 0xb0a38d7c  edx:0x982fef7a
 edi: 0x00000020  esi: 0x00000003  ebp: 0xb0a38db8  esp:0xb0a38d7c
  ss: 0x00000023  eip: 0x982fef7a   cs: 0x0000000b   ds:0x00000023
  es: 0x00000023   fs: 0x00000023   gs: 0x0000000f  eflags:0x00000206


Thread 15:

#  1  0x982fef7a in _mach_msg_trap + 0x0000000A (libsystem_kernel.dylib + 0x00012f7a)
#  2  0x9a7bcbf9 in ___CFRunLoopServiceMachPort + 0x000000A9 (CoreFoundation + 0x00076bf9)
#  3  0x9a7bc1d1 in ___CFRunLoopRun + 0x00000571 (CoreFoundation + 0x000761d1)
#  4  0x9a7bb9ea in _CFRunLoopRunSpecific + 0x0000018A (CoreFoundation + 0x000759ea)
#  5  0x9a7bb84b in _CFRunLoopRunInMode + 0x0000007B (CoreFoundation + 0x0007584b)
#  6  0x961d1355 in +[NSURLConnection(Loader) _resourceLoadLoop:] + 0x0000017D (Foundation + 0x0006d355)
#  7  0x961d11ce in -[NSThread main] + 0x0000002D (Foundation + 0x0006d1ce)
#  8  0x961d1126 in ___NSThread__main__ + 0x00000592 (Foundation + 0x0006d126)
#  9  0x980055fb in __pthread_body + 0x00000090 (libsystem_pthread.dylib + 0x000015fb)
# 10  0x98005485 in __pthread_struct_init + 0x00000000 (libsystem_pthread.dylib + 0x00001485)
# 11  0x9800acf2 in _thread_start + 0x00000022 (libsystem_pthread.dylib + 0x00006cf2)

X86 Thread State:
 eax: 0xffffffe1  ebx: 0xb0bbdf18  ecx: 0xb0bbddfc  edx:0x982fef7a
 edi: 0x00000c00  esi: 0x07000006  ebp: 0xb0bbde38  esp:0xb0bbddfc
  ss: 0x00000023  eip: 0x982fef7a   cs: 0x0000000b   ds:0x00000023
  es: 0x00000023   fs: 0x00000023   gs: 0x0000000f  eflags:0x00000206


Thread 16:

#  1  0x98304046 in ___workq_kernreturn + 0x0000000A (libsystem_kernel.dylib + 0x00018046)
#  2  0x9800acce in _start_wqthread + 0x0000001E (libsystem_pthread.dylib + 0x00006cce)

X86 Thread State:
 eax: 0x00100170  ebx: 0x00012637  ecx: 0xb0080f9c  edx:0x98304046
 edi: 0x98006c69  esi: 0xb0081000  ebp: 0xb0080fc8  esp:0xb0080f9c
  ss: 0x00000023  eip: 0x98304046   cs: 0x0000000b   ds:0x00000023
  es: 0x00000023   fs: 0x00000023   gs: 0x0000000f  eflags:0x00000282


Thread 17:

#  1  0x98304046 in ___workq_kernreturn + 0x0000000A (libsystem_kernel.dylib + 0x00018046)
#  2  0x9800acce in _start_wqthread + 0x0000001E (libsystem_pthread.dylib + 0x00006cce)

X86 Thread State:
 eax: 0x00100170  ebx: 0xa14e6190  ecx: 0xb0114f9c  edx:0x98304046
 edi: 0x98006c69  esi: 0xb0115000  ebp: 0xb0114fc8  esp:0xb0114f9c
  ss: 0x00000023  eip: 0x98304046   cs: 0x0000000b   ds:0x00000023
  es: 0x00000023   fs: 0x00000023   gs: 0x0000000f  eflags:0x00000282


Loaded modules:

0: Microsoft Outlook (14.4.6.141106 Reg=en Loc=0x0409: /Applications/Microsoft Office 2011/Microsoft Outlook.app/Contents/MacOS/Microsoft Outlook
...

Git Completion and Git Flow Completion

Just updated git this morning from because of a security issue and happy that what I have in my .bashrc still working. A lot trimmed out, but here is the gist of it:

# ensure git from gitscm will be used
export PATH=/usr/local/git/bin:/usr/local/bin:/usr/local/sbin:$PATH
source /usr/local/git/contrib/completion/git-completion.bash
source /usr/local/Cellar/git-flow/0.4.1/etc/bash_completion.d/git-flow-completion.bash
source /usr/local/git/contrib/completion/git-prompt.sh
PS1='\h:\W$(__git_ps1 " (%s)") \u\$ ';

That assumes that you have latest git from git-scm.com and are using git flow and git flow completion.

Middle Truncate in Ruby

Here's a way to truncate the middle of a String, shortening it to the desired length, in Ruby:

class String
  def middle_truncate(len)
    return self if len >= size
    return self[0...len] unless len > 4
    half = len / 2.0
    (result = dup)[(half - 1.5).floor...(1.5 - half).floor] = '...'
    result
  end
end

This has the added benefit of just truncating if string size < 5.


e.g. for an even-sized string:

    2.1.1 :001 > s = "12345678901234567890"
     => "12345678901234567890" 
    2.1.1 :002 > s.middle_truncate 21
     => "12345678901234567890" 
    2.1.1 :003 > s.middle_truncate 20
     => "12345678901234567890" 
    2.1.1 :004 > s.middle_truncate 19
     => "12345678...34567890" 
    2.1.1 :005 > s.middle_truncate 18
     => "1234567...34567890" 
    2.1.1 :006 > s.middle_truncate 5
     => "1...0" 
    2.1.1 :007 > s.middle_truncate 4
     => "1234" 

and for an odd-sized string:

    2.1.1 :012 > s = "123456789012345678901"
     => "123456789012345678901" 
    2.1.1 :013 > s.middle_truncate 22
     => "123456789012345678901" 
    2.1.1 :014 > s.middle_truncate 21
     => "123456789012345678901" 
    2.1.1 :015 > s.middle_truncate 20
     => "12345678...345678901" 
    2.1.1 :016 > s.middle_truncate 19
     => "12345678...45678901" 
    2.1.1 :017 > s.middle_truncate 5
     => "1...1" 
    2.1.1 :018 > s.middle_truncate 4
     => "1234" 

Shared on StackOverflow

Monday, December 1, 2014

Quick-and-Dirty Median in SQL

It's happened a few times where I want a median in postgres for something, but don't feel strongly enough about it to define a function temporarily or permanently.

So, here's the quick-and-dirty SQL for getting a median that I write in those times:

select some_column from some_table order by some_column offset (select count(*) from some_table) / 2 limit 1;

the problem with that way is that you have to specify where clauses in two places, but it is quick-and-dirty. E.g.:

select some_column from some_table where created_at > '2014-01-01' order by some_column offset (select count(*) from some_table where created_at > '2014-01-01') / 2 limit 1;

Change * to id for better performance.

The subsequent min, avg, max are just selecting min(some_column), avg(some_column), and max(some_column).

There are more accurate ways to do it, but that is ok for a reality check.

Friday, November 14, 2014

How to Solve Mac Pro Problems on Boot (HDMI and Display Port Display Problems and Yosemite Upgrade)

How to fix two problems our team has had with the Mac Pro (2014):
  • We had a wierd display issue causing a lock-up (or freeze) on boot. We found out this was caused by connecting to two monitors via HDMI and display port. By getting another display port cable and connecting to both display via display port, all works great. (Note: the genius bar took a look and had said that the Mac Pro was a niche product of Apple and that it would probably take a long time to work out what the issue causing this was, etc.)
  • We had a computer that on boot on start of Mavericks to Yosemite upgrade would show a grey screen for 10 minutes and then the apple and then a few minutes later would reboot, and would continue to do this. Attempting to use shift (safe mode boo), zapping PRAM, and recovery boot (command-R) did not work. We noticed when using command-v (thanks to Tommy for remembering that) we could see it was stuck after showing the second period of efi in verbose mode). A co-worker had a long support call with Apple and they gave up and directed him to a local Apple affiliate for support. We determined this was caused by using the USB output of a Dell monitor (which had a built-in USB hub to allow for Bluetooth peripherals- a keyboard and mouse). Unplugging everything except the monitor and using a wired keyboard and switching the port that was used for display port fixed this problem and allowed it to continue (start) the upgrade process.

Wednesday, October 22, 2014

Git Hooks: One Size Unfortunately Does Not Fit All

Was disheartened to find out recently that despite all the progress in the world's software development community, even when everyone is using git, you cannot rely on a standard set of hooks to enforce commit rules and perform other actions.

Some links to show what I'm talking about:

The problem isn't that something like hooks can't be accomplished across IDEs and platforms in 2014, but rather that it is a pain. Hooks shouldn't require this much lock-in.

Wednesday, October 15, 2014

Which Programming Language or Architecture Is Most Popular?

Although my favorite way of judging programming language or architecture popularity is indeed.com's trends, it might also be helpful to take a look at Tiobe's stats. Other gauges include GitHub's trending projects and architectures and programming language showcase.

Also, here's a mid-2014 post that analyzes GitHub, showing trends in language usage, and another showing Javascript framework popularity.