cutting-room-floor / node-mapbox-gl-native

DEPRECATED
BSD 3-Clause "New" or "Revised" License
30 stars 4 forks source link

Concurrent rendering segfaults #5

Closed mikemorris closed 10 years ago

mikemorris commented 10 years ago

Concurrent rendering tests from https://github.com/mapbox/node-mapbox-gl-native/commit/6238a59f03fc54bad67ef109bb74d3789a9ee191 sometimes segfault on OS X with

Error pixel format
Couldn't create framebuffer: other
invalid plain shader
invalid outline shader
invalid line shader
invalid line shader
invalid line pattern shader
invalid pattern shader
invalid icon shader
invalid sdf shader
invalid sdf shader
invalid dot shader

@yhahn reported a similar segfault on Linux

Error reference: Error pixel format Couldn't create framebuffer: other

Thinking this may be related to https://github.com/mapbox/mapbox-gl-native/issues/473

/cc @kkaefer

mikemorris commented 10 years ago

Fixed mapbox/mapbox-gl-native#473 but the occasional segfaults didn't go away. Looking at backtraces, it doesn't appear that any other thread is currently in the middle of mapbox-gl-native render functions, BUT I found one instance where another thread may have been still doing some GL work? I'm not certain, but this MAY be caused by GL's "async even though design looks sync" API and the lack of glFlush calls?

Check out the segfault in thread 7 and the work that thread 5 is doing in both files in this gist: https://gist.github.com/mikemorris/833ef620f6ffd63bc784

/cc @springmeyer @yhahn

mikemorris commented 10 years ago

And here's another backtrace with a different crash in thread 5 at HeadlessView::resize as soon as it hits a GL command and some residual GL work in thread 6 https://gist.github.com/mikemorris/836e6476eb71fe55074e

mikemorris commented 10 years ago

There are also two different segfaults I've seen:

The first, when it crashes in LineBucket::drawLines

Error pixel format
Couldn't create framebuffer: other
invalid plain shader
invalid outline shader
invalid line shader
invalid line shader
invalid line pattern shader
invalid pattern shader
invalid icon shader
invalid sdf shader
invalid sdf shader
invalid dot shader
libc++abi.dylib: terminating with uncaught exception of type std::runtime_error: Buffer was already deleted or doesn't contain elements

...and the other when it crashes in HeadlessView::clear_buffers

Error pixel format
Process 35922 stopped
* thread #5: tid = 0x47234, 0x00007fff87da2c66 libGL.dylib`glBindFramebufferEXT + 30, stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
    frame #0: 0x00007fff87da2c66 libGL.dylib`glBindFramebufferEXT + 30
mikemorris commented 10 years ago

CGLLockContext has some interesting notes about multithreading.

mikemorris commented 10 years ago

Concurrency and OpenGL

mikemorris commented 10 years ago

Added a little more verbose debugging, and it looks like the actual error it hits is

Error pixel format: invalid CoreGraphics connection
kCGLBadConnection - Invalid connection to Core Graphics.

https://developer.apple.com/library/mac/documentation/graphicsimaging/reference/cgl_opengl/Reference/reference.html#//apple_ref/doc/uid/TP40001186-CH3g-BBCDCEBD

/cc @incanus

springmeyer commented 10 years ago

Check out the segfault in thread 7 and the work that thread 5 is doing in both files in this gist: https://gist.github.com/mikemorris/833ef620f6ffd63bc784

thread #7 appears to be crashing because of a valid c++ exception being thrown __cxa_throw but which is uncaught. So it seems like a first step is to figure out how to respond to that exception without letting it bring down the thread.

mikemorris commented 10 years ago

Interestingly enough, Linux seems to be crashing in an entirely unrelated place (inside StyleParser???)

*** Error in `/home/mapbox/.nvm/v0.10.32/bin/node': double free or corruption (fasttop): 0x0000000000ec48d0 ***

Program received signal SIGABRT, Aborted.

https://gist.github.com/mikemorris/1a5e87d5ffe39911e9c6

mikemorris commented 10 years ago

So this simple experiment makes it looks like it's safe to do "GL stuff" in several threads as long as there is no shared context.

https://github.com/mikemorris/headless-gl-multithreaded

springmeyer commented 10 years ago

running that on OS X I get:

 ./main 
Error pixel format: invalid CoreGraphics connection
Segmentation fault: 11

And this backtrace:

Process:         main [44921]
Path:            /Users/USER/*/main
Identifier:      main
Version:         0
Code Type:       X86-64 (Native)
Parent Process:  bash [44636]
Responsible:     Terminal [362]
User ID:         501

Date/Time:       2014-10-01 15:42:02.749 -0700
OS Version:      Mac OS X 10.9.5 (13F34)
Report Version:  11
Anonymous UUID:  B9F868B4-F6CC-BF2C-C8C7-25252C6F4292

Crashed Thread:  1

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000040

VM Regions Near 0x40:
--> 
    __TEXT                 0000000102027000-000000010202a000 [   12K] r-x/rwx SM=COW  /Users/USER/*

Thread 0:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib          0x00007fff86742a3a __semwait_signal + 10
1   libsystem_pthread.dylib         0x00007fff812a57f3 pthread_join + 433
2   libc++.1.dylib                  0x00007fff8d1d89bc std::__1::thread::join() + 20
3   main                            0x00000001020289a6 main + 86
4   libdyld.dylib                   0x00007fff8945b5fd start + 1

Thread 1 Crashed:
0   ???                             0x00007fff8d1f7716 0 + 140735561037590
1   main                            0x00000001020295dc View::resize(unsigned short, unsigned short, float) + 44
2   main                            0x000000010202855f readPixels() + 95
3   main                            0x0000000102028fe8 void* std::__1::__thread_proxy<void (*)()>(void*) + 376
4   libsystem_pthread.dylib         0x00007fff812a1899 _pthread_body + 138
5   libsystem_pthread.dylib         0x00007fff812a172a _pthread_start + 137
6   libsystem_pthread.dylib         0x00007fff812a5fc9 thread_start + 13

Thread 2:
0   libsystem_kernel.dylib          0x00007fff8673ea56 semaphore_wait_trap + 10
1   libsystem_platform.dylib        0x00007fff8d190451 _os_semaphore_wait + 16
2   libdispatch.dylib               0x00007fff8d0e4258 dispatch_once_f + 171
3   com.apple.CoreGraphics          0x00007fff8d528cf8 CGSMainConnectionID + 40
4   com.apple.opengl                0x00007fff8ccd7eb9 0x7fff8cccf000 + 36537
5   com.apple.opengl                0x00007fff8ccd7e0a CGLChoosePixelFormat + 126
6   main                            0x0000000102029371 View::View() + 97
7   main                            0x0000000102029485 View::View() + 21
8   main                            0x000000010202853d readPixels() + 61
9   main                            0x0000000102028fe8 void* std::__1::__thread_proxy<void (*)()>(void*) + 376
10  libsystem_pthread.dylib         0x00007fff812a1899 _pthread_body + 138
11  libsystem_pthread.dylib         0x00007fff812a172a _pthread_start + 137
12  libsystem_pthread.dylib         0x00007fff812a5fc9 thread_start + 13

Thread 3:
0   com.apple.CoreFoundation        0x00007fff8b35ef3f CFBasicHashFindBucket + 1055
1   com.apple.CoreFoundation        0x00007fff8b35eaef CFDictionaryGetValue + 111
2   com.apple.CoreFoundation        0x00007fff8b398865 __CFBinaryPlistCreateObjectFiltered + 85
3   com.apple.CoreFoundation        0x00007fff8b39a088 __CFBinaryPlistCreateObjectFiltered + 6264
4   com.apple.CoreFoundation        0x00007fff8b39a088 __CFBinaryPlistCreateObjectFiltered + 6264
5   com.apple.CoreFoundation        0x00007fff8b39a088 __CFBinaryPlistCreateObjectFiltered + 6264
6   com.apple.CoreFoundation        0x00007fff8b37bbfc __CFTryParseBinaryPlist + 220
7   com.apple.CoreFoundation        0x00007fff8b37b5af _CFPropertyListCreateWithData + 95
8   com.apple.CoreFoundation        0x00007fff8b37b3bd CFPropertyListCreateWithData + 93
9   com.apple.CoreFoundation        0x00007fff8b397173 -[CFPrefsPlistSource copyReplyForDaemonMessage:toConnection:error:] + 1235
10  com.apple.CoreFoundation        0x00007fff8b4f17e0 __47-[CFPrefsPlistSource alreadylocked_synchronize]_block_invoke_2 + 352
11  com.apple.CoreFoundation        0x00007fff8b39665b withDaemonConnection + 299
12  com.apple.CoreFoundation        0x00007fff8b3960bb -[CFPrefsPlistSource alreadylocked_synchronize] + 587
13  com.apple.CoreFoundation        0x00007fff8b395db3 _copyValueForKey + 131
14  com.apple.CoreFoundation        0x00007fff8b395d07 -[CFPrefsPlistSource copyValueForKey:] + 71
15  com.apple.CoreFoundation        0x00007fff8b395b65 -[CFPrefsSearchListSource alreadylocked_copyValueForKey:] + 149
16  com.apple.CoreFoundation        0x00007fff8b395a9f -[CFPrefsSource copyValueForKey:] + 79
17  com.apple.CoreFoundation        0x00007fff8b395a30 __CFPreferencesCopyAppValue_block_invoke + 32
18  com.apple.CoreFoundation        0x00007fff8b38fc0e +[CFPrefsSearchListSource withSearchListForIdentifier:perform:] + 846
19  com.apple.CoreFoundation        0x00007fff8b38f878 CFPreferencesCopyAppValue + 168
20  com.apple.CoreFoundation        0x00007fff8b3a8e93 ___CFBundleCopyUserLanguages_block_invoke + 35
21  libdispatch.dylib               0x00007fff8d0e428d _dispatch_client_callout + 8
22  libdispatch.dylib               0x00007fff8d0e41fc dispatch_once_f + 79
23  com.apple.CoreFoundation        0x00007fff8b3a8d6f _CFBundleAddPreferredLprojNamesInDirectory + 911
24  com.apple.CoreFoundation        0x00007fff8b3a78ab _CFBundleGetLanguageSearchList + 107
25  com.apple.CoreFoundation        0x00007fff8b3a68ab _CFBundleCreateQueryTableAtPath + 539
26  com.apple.CoreFoundation        0x00007fff8b3a6617 _CFBundleCopyQueryTable + 263
27  com.apple.CoreFoundation        0x00007fff8b3a5ec3 _CFBundleCopyURLsOfKey + 339
28  com.apple.CoreFoundation        0x00007fff8b3a5905 _CFBundleCopyFindResources + 1637
29  com.apple.CoreFoundation        0x00007fff8b3a5293 CFBundleCopyResourceURL + 67
30  com.apple.CoreFoundation        0x00007fff8b3a50d1 CFBundleGetLocalInfoDictionary + 209
31  com.apple.CoreFoundation        0x00007fff8b3a4fc1 CFBundleGetValueForInfoDictionaryKey + 33
32  com.apple.CoreGraphics          0x00007fff8d529ac3 CGSServerPort + 281
33  com.apple.CoreGraphics          0x00007fff8d52996c CGSScoreboard + 23
34  com.apple.CoreGraphics          0x00007fff8d5297c9 initDisplayState + 91
35  com.apple.CoreGraphics          0x00007fff8d529679 initDisplayMappings + 29
36  com.apple.CoreGraphics          0x00007fff8d528e6f __CGSInitialize_block_invoke + 26
37  libdispatch.dylib               0x00007fff8d0e428d _dispatch_client_callout + 8
38  libdispatch.dylib               0x00007fff8d0e41fc dispatch_once_f + 79
39  com.apple.CoreGraphics          0x00007fff8d528cf8 CGSMainConnectionID + 40
40  com.apple.opengl                0x00007fff8ccd7eb9 0x7fff8cccf000 + 36537
41  com.apple.opengl                0x00007fff8ccd7e0a CGLChoosePixelFormat + 126
42  main                            0x0000000102029371 View::View() + 97
43  main                            0x0000000102029485 View::View() + 21
44  main                            0x000000010202853d readPixels() + 61
45  main                            0x0000000102028fe8 void* std::__1::__thread_proxy<void (*)()>(void*) + 376
46  libsystem_pthread.dylib         0x00007fff812a1899 _pthread_body + 138
47  libsystem_pthread.dylib         0x00007fff812a172a _pthread_start + 137
48  libsystem_pthread.dylib         0x00007fff812a5fc9 thread_start + 13

Thread 4:: Dispatch queue: com.apple.libdispatch-manager
0   libsystem_kernel.dylib          0x00007fff86743662 kevent64 + 10
1   libdispatch.dylib               0x00007fff8d0e6421 _dispatch_mgr_invoke + 239
2   libdispatch.dylib               0x00007fff8d0e6136 _dispatch_mgr_thread + 52

Thread 5:
0   libsystem_kernel.dylib          0x00007fff86742e6a __workq_kernreturn + 10
1   libsystem_pthread.dylib         0x00007fff812a2f08 _pthread_wqthread + 330
2   libsystem_pthread.dylib         0x00007fff812a5fb9 start_wqthread + 13

Thread 6:
0   libsystem_kernel.dylib          0x00007fff86742e6a __workq_kernreturn + 10
1   libsystem_pthread.dylib         0x00007fff812a2f08 _pthread_wqthread + 330
2   libsystem_pthread.dylib         0x00007fff812a5fb9 start_wqthread + 13

Thread 1 crashed with X86 Thread State (64-bit):
  rax: 0x00007fff8d1f7715  rbx: 0x0000000102110000  rcx: 0x0000000000008d40  rdx: 0x0000000000000000
  rdi: 0x0000000000000101  rsi: 0x0000000000008d40  rbp: 0x000000010210fa60  rsp: 0x000000010210fa40
   r8: 0x0000000000000040   r9: 0x000000010210f800  r10: 0x00007fff8efee43f  r11: 0x00007fff85fa6c48
  r12: 0x0000000000001003  r13: 0x0000000000000000  r14: 0x00007f8d29c03610  r15: 0x0000000102028e70
  rip: 0x00007fff8d1f7716  rfl: 0x0000000000010206  cr2: 0x0000000000000040

Logical CPU:     2
Error Code:      0x00000004
Trap Number:     14

Binary Images:
       0x102027000 -        0x102029ff7 +main (0) <0433DD45-6560-3F27-81C0-2FB568DBD651> /Users/USER/*/main
    0x7fff69fb2000 -     0x7fff69fe5817  dyld (239.4) <7AD43B9B-5CEA-3C7E-9836-A06909F9CA56> /usr/lib/dyld
    0x7fff81052000 -     0x7fff81158ff7  com.apple.ImageIO.framework (3.3.0 - 1044) <3BCCF2AE-CF1F-3324-A371-DF0A42C841A2> /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
    0x7fff81266000 -     0x7fff8129fff7  com.apple.QD (3.50 - 298) <5343278D-47B7-3AF2-9B4B-4B8B0F942CD1> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/QD.framework/Versions/A/QD
    0x7fff812a0000 -     0x7fff812a7ff7  libsystem_pthread.dylib (53.1.4) <9DA50FD0-D9AC-3051-AD4B-BA0D745BC49C> /usr/lib/system/libsystem_pthread.dylib
    0x7fff81348000 -     0x7fff81648ff7  com.apple.Foundation (6.9 - 1056.16) <24349208-3603-3F5D-95CC-B379616FBEF8> /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
    0x7fff81733000 -     0x7fff8175cff7  libc++abi.dylib (49.1) <21A807D3-6732-3455-B77F-743E9F916DF0> /usr/lib/libc++abi.dylib
    0x7fff81b6b000 -     0x7fff81b6cfff  com.apple.TrustEvaluationAgent (2.0 - 25) <334A82F4-4AE4-3719-A511-86D0B0723E2B> /System/Library/PrivateFrameworks/TrustEvaluationAgent.framework/Versions/A/TrustEvaluationAgent
    0x7fff81bc0000 -     0x7fff81c23ffb  com.apple.SystemConfiguration (1.13.1 - 1.13.1) <2C8E1A73-5AD6-3A7D-8ED8-D6755555A993> /System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration
    0x7fff820eb000 -     0x7fff823bffc7  com.apple.vImage (7.0 - 7.0) <1DDB8AB7-03D5-3D20-9D77-C69074C6FD26> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vImage.framework/Versions/A/vImage
    0x7fff8254c000 -     0x7fff8254dfff  liblangid.dylib (117) <9546E641-F730-3AB0-B3CD-E0E2FDD173D9> /usr/lib/liblangid.dylib
    0x7fff8254e000 -     0x7fff8254efff  com.apple.CoreServices (59 - 59) <67A369BA-2326-383F-995B-853DAD7BFF43> /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices
    0x7fff825a1000 -     0x7fff825a3ff3  libsystem_configuration.dylib (596.15) <4998CB6A-9D54-390A-9F57-5D1AC53C135C> /usr/lib/system/libsystem_configuration.dylib
    0x7fff825a4000 -     0x7fff825a8fff  libpam.2.dylib (20) <A63D4DA2-06A4-3FB8-AC3F-BDD69694EE5E> /usr/lib/libpam.2.dylib
    0x7fff82939000 -     0x7fff82a8dff3  com.apple.audio.toolbox.AudioToolbox (1.10 - 1.10) <69B273E8-5A8E-3FC7-B807-C16B657662FE> /System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox
    0x7fff82a9b000 -     0x7fff82aa0ff7  libunwind.dylib (35.3) <95D4D118-3368-3474-989D-271DE18C8365> /usr/lib/system/libunwind.dylib
    0x7fff83825000 -     0x7fff83894ff1  com.apple.ApplicationServices.ATS (360 - 363.3) <546E89D9-2AE7-3111-B2B8-2366650D22F0> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/ATS
    0x7fff839e1000 -     0x7fff83a3cffb  com.apple.AE (665.5 - 665.5) <3558CC9A-FD30-3DAD-AB40-FE6828E76FE1> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/AE
    0x7fff83a3d000 -     0x7fff83ab0fff  com.apple.securityfoundation (6.0 - 55122.3) <0FDC8F53-104C-3938-A852-5B33C30BAAD5> /System/Library/Frameworks/SecurityFoundation.framework/Versions/A/SecurityFoundation
    0x7fff84311000 -     0x7fff84312ff7  libDiagnosticMessagesClient.dylib (100) <4CDB0F7B-C0AF-3424-BC39-495696F0DB1E> /usr/lib/libDiagnosticMessagesClient.dylib
    0x7fff84a70000 -     0x7fff84a8bff7  libsystem_malloc.dylib (23.10.1) <A695B4E4-38E9-332E-A772-29D31E3F1385> /usr/lib/system/libsystem_malloc.dylib
    0x7fff84a8c000 -     0x7fff84a95ffb  libsystem_notify.dylib (121.20.1) <9B34B4FE-F5AD-3F09-A5F0-46AFF3571323> /usr/lib/system/libsystem_notify.dylib
    0x7fff85108000 -     0x7fff85276ff7  libBLAS.dylib (1094.5) <D862E2B7-91FA-3704-8F62-C1B65D381A84> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
    0x7fff85ed9000 -     0x7fff85f9bff5  com.apple.CoreText (367.20 - 367.20) <B80D086D-93A9-3C35-860E-9C3FDD027F3B> /System/Library/Frameworks/CoreText.framework/Versions/A/CoreText
    0x7fff85f9c000 -     0x7fff85fa7fff  libGL.dylib (9.6.1) <4B65BF9F-F34A-3CD1-94E8-DB26DAA0A59D> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib
    0x7fff86035000 -     0x7fff861a5ff4  com.apple.CFNetwork (673.4 - 673.4) <F3BF6020-99BE-3844-A7B8-352B93AD02F3> /System/Library/Frameworks/CFNetwork.framework/Versions/A/CFNetwork
    0x7fff861a6000 -     0x7fff861b2ff7  com.apple.OpenDirectory (10.9 - 173.90.1) <F08601E8-F7E8-3222-AD05-6A26003779CF> /System/Library/Frameworks/OpenDirectory.framework/Versions/A/OpenDirectory
    0x7fff86209000 -     0x7fff862f3fff  libsqlite3.dylib (158) <447AA928-BCF7-3779-A7E5-210F264E0316> /usr/lib/libsqlite3.dylib
    0x7fff8632e000 -     0x7fff86332ff7  libsystem_stats.dylib (93.90.3) <4E51D5B0-92A0-3D0D-B90E-495A1ED3E391> /usr/lib/system/libsystem_stats.dylib
    0x7fff86479000 -     0x7fff8647aff7  libsystem_blocks.dylib (63) <FB856CD1-2AEA-3907-8E9B-1E54B6827F82> /usr/lib/system/libsystem_blocks.dylib
    0x7fff8647b000 -     0x7fff8648cff7  libsystem_asl.dylib (217.1.4) <B983CA60-F418-317B-B142-48A6376564FC> /usr/lib/system/libsystem_asl.dylib
    0x7fff8668a000 -     0x7fff866d1ff7  libcups.2.dylib (372.4) <36EA4350-43B4-3A5C-9904-10685BFDA7D4> /usr/lib/libcups.2.dylib
    0x7fff866d2000 -     0x7fff866dfff0  libbz2.1.0.dylib (29) <0B98AC35-B138-349C-8063-2B987A75D24C> /usr/lib/libbz2.1.0.dylib
    0x7fff8672d000 -     0x7fff86749ff7  libsystem_kernel.dylib (2422.115.4) <9EDE872E-2A9E-3A78-8E1D-AB790794A098> /usr/lib/system/libsystem_kernel.dylib
    0x7fff86774000 -     0x7fff867d8fff  com.apple.datadetectorscore (5.0 - 354.5) <0AE9749A-6BFC-3032-B802-210DF59AEDB0> /System/Library/PrivateFrameworks/DataDetectorsCore.framework/Versions/A/DataDetectorsCore
    0x7fff86801000 -     0x7fff86806fff  libmacho.dylib (845) <B2BE3C25-CF1F-309B-AB99-1F0B54621445> /usr/lib/system/libmacho.dylib
    0x7fff86807000 -     0x7fff868f5fff  libJP2.dylib (1044) <BE5FF765-5ECE-38B5-BF5D-BE806F5CAD18> /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libJP2.dylib
    0x7fff86992000 -     0x7fff869a2fff  libbsm.0.dylib (33) <2CAC00A2-1352-302A-88FA-C567D4D69179> /usr/lib/libbsm.0.dylib
    0x7fff869a3000 -     0x7fff869ccfff  com.apple.DictionaryServices (1.2 - 208) <A4E4EA9E-08A1-3F77-8B57-A5A1ADD70B52> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/DictionaryServices.framework/Versions/A/DictionaryServices
    0x7fff8731f000 -     0x7fff87320fff  libsystem_sandbox.dylib (278.11.1) <0D0B13EA-6B7A-3AC8-BE60-B548543BEB77> /usr/lib/system/libsystem_sandbox.dylib
    0x7fff87321000 -     0x7fff87325ff7  libGIF.dylib (1044) <7E51DFC3-740A-3CD3-98A1-1EC510A4A055> /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libGIF.dylib
    0x7fff87326000 -     0x7fff87368ff7  libauto.dylib (185.5) <F45C36E8-B606-3886-B5B1-B6745E757CA8> /usr/lib/libauto.dylib
    0x7fff8779d000 -     0x7fff877aeff7  libz.1.dylib (53) <4C5FA1A5-4471-398E-9543-2E54D46E63E9> /usr/lib/libz.1.dylib
    0x7fff877b1000 -     0x7fff877b3fff  libCVMSPluginSupport.dylib (9.6.1) <FB37F4C4-1E84-3349-BB03-92CA0A5F6837> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libCVMSPluginSupport.dylib
    0x7fff87808000 -     0x7fff87859ff7  com.apple.audio.CoreAudio (4.2.1 - 4.2.1) <BE13E840-FB45-3BC2-BCF5-031629754FD5> /System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio
    0x7fff8792e000 -     0x7fff87938ff7  com.apple.bsd.ServiceManagement (2.0 - 2.0) <9556885C-22DD-3392-ACCB-2B413434D8D3> /System/Library/Frameworks/ServiceManagement.framework/Versions/A/ServiceManagement
    0x7fff87fc9000 -     0x7fff87fd2fff  com.apple.speech.synthesis.framework (4.7.1 - 4.7.1) <383FB557-E88E-3239-82B8-15F9F885B702> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/SpeechSynthesis.framework/Versions/A/SpeechSynthesis
    0x7fff87fd9000 -     0x7fff88050fff  com.apple.CoreServices.OSServices (600.4 - 600.4) <C63562F5-6DF5-3EE9-8897-FF61A44C8251> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/OSServices
    0x7fff88072000 -     0x7fff880d7ffb  com.apple.Heimdal (4.0 - 2.0) <F34D6627-9F80-3823-8B57-DB629307DF87> /System/Library/PrivateFrameworks/Heimdal.framework/Versions/A/Heimdal
    0x7fff8913d000 -     0x7fff89140ffc  com.apple.IOSurface (91.1 - 91.1) <D00EEB0C-8AA8-3986-90C1-C97B2486E8FA> /System/Library/Frameworks/IOSurface.framework/Versions/A/IOSurface
    0x7fff89141000 -     0x7fff8915aff7  com.apple.Kerberos (3.0 - 1) <59427E11-37D6-34C9-95BB-D4438BFACA5B> /System/Library/Frameworks/Kerberos.framework/Versions/A/Kerberos
    0x7fff8915b000 -     0x7fff8919afff  libGLU.dylib (9.6.1) <AE032555-3E2F-3DBF-A26D-EA4576061605> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib
    0x7fff8919b000 -     0x7fff891b6ff7  libPng.dylib (1044) <151BA92C-6E7C-3B69-8024-FDD1E2C89DD3> /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libPng.dylib
    0x7fff891cb000 -     0x7fff891cefff  com.apple.TCC (1.0 - 1) <F25B5875-081A-3877-B70E-374D54B54C5F> /System/Library/PrivateFrameworks/TCC.framework/Versions/A/TCC
    0x7fff891cf000 -     0x7fff891cfffd  libOpenScriptingUtil.dylib (157) <19F0E769-0989-3062-9AFB-8976E90E9759> /usr/lib/libOpenScriptingUtil.dylib
    0x7fff891d9000 -     0x7fff891daffb  libremovefile.dylib (33) <26266E3F-FDDC-3CFC-B27F-78B49BDC9BDC> /usr/lib/system/libremovefile.dylib
    0x7fff8925c000 -     0x7fff89280fff  libxpc.dylib (300.90.2) <AB40CD57-F454-3FD4-B415-63B3C0D5C624> /usr/lib/system/libxpc.dylib
    0x7fff8931e000 -     0x7fff89327ffd  com.apple.CommonAuth (4.0 - 2.0) <32BA436F-6319-3A0B-B5D2-2EB75FF36B5B> /System/Library/PrivateFrameworks/CommonAuth.framework/Versions/A/CommonAuth
    0x7fff8944c000 -     0x7fff8944cfff  com.apple.Accelerate (1.9 - Accelerate 1.9) <CFEF9CBE-4A1A-33FD-9174-D44314BB28F3> /System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate
    0x7fff8944d000 -     0x7fff89457fff  libcommonCrypto.dylib (60049) <79B8E80F-E596-3302-8243-EC479B9546CA> /usr/lib/system/libcommonCrypto.dylib
    0x7fff89458000 -     0x7fff8945bff7  libdyld.dylib (239.4) <7C9EC3B7-DDE3-33FF-953F-4067C743951D> /usr/lib/system/libdyld.dylib
    0x7fff8945e000 -     0x7fff89465ff8  liblaunch.dylib (842.92.1) <A40A0C7B-3216-39B4-8AE0-B5D3BAF1DA8A> /usr/lib/system/liblaunch.dylib
    0x7fff894bf000 -     0x7fff898a0ffe  libLAPACK.dylib (1094.5) <7E7A9B8D-1638-3914-BAE0-663B69865986> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib
    0x7fff898a1000 -     0x7fff89b05ffd  com.apple.security (7.0 - 55471.14.18) <83A9E8C8-06A1-3F6D-8514-C35CD0DBD370> /System/Library/Frameworks/Security.framework/Versions/A/Security
    0x7fff89cbc000 -     0x7fff89d6cff7  libvMisc.dylib (423.32) <049C0735-1808-39B9-943F-76CB8021744F> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvMisc.dylib
    0x7fff89d6d000 -     0x7fff89dbbfff  libcorecrypto.dylib (161.1) <F3973C28-14B6-3006-BB2B-00DD7F09ABC7> /usr/lib/system/libcorecrypto.dylib
    0x7fff8a0f1000 -     0x7fff8a17aff7  libsystem_c.dylib (997.90.3) <6FD3A400-4BB2-3B95-B90C-BE6E9D0D78FA> /usr/lib/system/libsystem_c.dylib
    0x7fff8a17b000 -     0x7fff8a180fff  com.apple.DiskArbitration (2.6 - 2.6) <A4165553-770E-3D27-B217-01FC1F852B87> /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration
    0x7fff8a185000 -     0x7fff8a215ff7  com.apple.Metadata (10.7.0 - 800.28) <E85AEB1B-CB17-38BC-B5C6-AAB50B47AF05> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Metadata.framework/Versions/A/Metadata
    0x7fff8a611000 -     0x7fff8a66afff  libTIFF.dylib (1044) <FBC5800B-7F34-3755-A44E-7B37B3E0B32E> /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libTIFF.dylib
    0x7fff8a66b000 -     0x7fff8a66dff7  libquarantine.dylib (71) <973BE51D-6465-392F-9099-D4AB21BF0D25> /usr/lib/system/libquarantine.dylib
    0x7fff8a694000 -     0x7fff8a6c3fd2  libsystem_m.dylib (3047.16) <9D96AACD-5870-3A5C-B849-7F9C0F6EBB09> /usr/lib/system/libsystem_m.dylib
    0x7fff8a742000 -     0x7fff8a789fff  libFontRegistry.dylib (127) <401FA61F-4276-3296-9BFF-EC6EA7D7EDDE> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/Resources/libFontRegistry.dylib
    0x7fff8a78a000 -     0x7fff8a791fff  libcompiler_rt.dylib (35) <2A890004-0A78-3E33-9AC5-A7D63BD4F879> /usr/lib/system/libcompiler_rt.dylib
    0x7fff8b1d5000 -     0x7fff8b1f1fff  libresolv.9.dylib (54) <11C2C826-F1C6-39C6-B4E8-6E0C41D4FA95> /usr/lib/libresolv.9.dylib
    0x7fff8b1f2000 -     0x7fff8b20dff7  libCRFSuite.dylib (34) <FFAE75FA-C54E-398B-AA97-18164CD9789D> /usr/lib/libCRFSuite.dylib
    0x7fff8b27d000 -     0x7fff8b348fff  libvDSP.dylib (423.32) <3BF732BE-DDE0-38EB-8C54-E4E3C64F77A7> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvDSP.dylib
    0x7fff8b355000 -     0x7fff8b53afff  com.apple.CoreFoundation (6.9 - 855.17) <729BD6DA-1F63-3E72-A148-26F21EBF52BB> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
    0x7fff8b53b000 -     0x7fff8b53cff7  libSystem.B.dylib (1197.1.1) <E303F2F8-A8CF-3DF3-84B3-F2D0EE41CCF6> /usr/lib/libSystem.B.dylib
    0x7fff8b56a000 -     0x7fff8b571ffb  libcopyfile.dylib (103.92.1) <CF29DFF6-0589-3590-834C-82E2316612E8> /usr/lib/system/libcopyfile.dylib
    0x7fff8b575000 -     0x7fff8b575fff  com.apple.Accelerate.vecLib (3.9 - vecLib 3.9) <F8D0CC77-98AC-3B58-9FE6-0C25421827B6> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/vecLib
    0x7fff8b576000 -     0x7fff8b665fff  libFontParser.dylib (111.1) <835A8253-6AB9-3AAB-9CBF-171440DEC486> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/Resources/libFontParser.dylib
    0x7fff8bccd000 -     0x7fff8bcd0fff  libCoreVMClient.dylib (58.1) <EBC36C69-C896-3C3D-8589-3E9023E7E56F> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libCoreVMClient.dylib
    0x7fff8bdf0000 -     0x7fff8bdf8ffc  libGFXShared.dylib (9.6.1) <25BBF325-AC57-3BAA-9427-2D14CC243AE6> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGFXShared.dylib
    0x7fff8be20000 -     0x7fff8c10afff  com.apple.CoreServices.CarbonCore (1077.17 - 1077.17) <3A2E92FD-DEE2-3D45-9619-11500801A61C> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/CarbonCore
    0x7fff8c159000 -     0x7fff8c1c6fff  com.apple.SearchKit (1.4.0 - 1.4.0) <33298263-5B12-340D-BB9D-D52303849561> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SearchKit.framework/Versions/A/SearchKit
    0x7fff8c1c7000 -     0x7fff8c1c7ff7  libkeymgr.dylib (28) <D7045F25-BFA4-3840-847D-AF95DF8B6CCA> /usr/lib/system/libkeymgr.dylib
    0x7fff8c49a000 -     0x7fff8c4c2ffb  libxslt.1.dylib (13) <C9794936-633C-3F0C-9E71-30190B9B41C1> /usr/lib/libxslt.1.dylib
    0x7fff8c4c3000 -     0x7fff8c4c5fff  libRadiance.dylib (1044) <461482C9-CADB-3B36-B023-597C64AD4B00> /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libRadiance.dylib
    0x7fff8c788000 -     0x7fff8c7afff7  libsystem_network.dylib (241.3) <A499D688-9165-3776-8C8E-C018897B5B13> /usr/lib/system/libsystem_network.dylib
    0x7fff8c833000 -     0x7fff8c842ff8  com.apple.LangAnalysis (1.7.0 - 1.7.0) <2777524A-E7EF-3B7B-B15D-F58CDEEFC736> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/LangAnalysis.framework/Versions/A/LangAnalysis
    0x7fff8cb88000 -     0x7fff8cc6fff7  libxml2.2.dylib (26) <A1DADD11-89E5-3DE4-8802-07186225967F> /usr/lib/libxml2.2.dylib
    0x7fff8cc99000 -     0x7fff8cca1fff  libsystem_dnssd.dylib (522.92.1) <17B03FFD-92C5-3282-9981-EBB28B456207> /usr/lib/system/libsystem_dnssd.dylib
    0x7fff8cca2000 -     0x7fff8cca9fff  com.apple.NetFS (6.0 - 4.0) <D4FE0F16-3085-34AF-B860-3D46B98FAD2A> /System/Library/Frameworks/NetFS.framework/Versions/A/NetFS
    0x7fff8ccaa000 -     0x7fff8ccceff7  libJPEG.dylib (1044) <BE0ED4E1-F7FC-3038-86D3-0456DD173FCB> /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libJPEG.dylib
    0x7fff8cccf000 -     0x7fff8ccddfff  com.apple.opengl (9.6.1 - 9.6.1) <B22FA400-5824-36AF-9945-5FEC31995A0E> /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL
    0x7fff8cf89000 -     0x7fff8cff5fff  com.apple.framework.IOKit (2.0.1 - 907.100.13) <057FDBA3-56D6-3903-8C0B-849214BF1985> /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit
    0x7fff8d098000 -     0x7fff8d0d6ff7  libGLImage.dylib (9.6.1) <5E02B38C-9F36-39BE-8746-724F0D8BBFC0> /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLImage.dylib
    0x7fff8d0d7000 -     0x7fff8d0e2fff  libkxld.dylib (2422.115.4) <3C678B75-F7C5-3DBB-8DBD-48483AD54D5C> /usr/lib/system/libkxld.dylib
    0x7fff8d0e3000 -     0x7fff8d0fdfff  libdispatch.dylib (339.92.1) <C4E4A18D-3C3B-3C9C-8709-A4270D998DE7> /usr/lib/system/libdispatch.dylib
    0x7fff8d0fe000 -     0x7fff8d14bff2  com.apple.print.framework.PrintCore (9.0 - 428) <A2F7B9D2-7907-31D8-8462-E2E2E7C3AF2E> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/PrintCore.framework/Versions/A/PrintCore
    0x7fff8d18d000 -     0x7fff8d193ff7  libsystem_platform.dylib (24.90.1) <3C3D3DA8-32B9-3243-98EC-D89B9A1670B3> /usr/lib/system/libsystem_platform.dylib
    0x7fff8d194000 -     0x7fff8d1e6fff  libc++.1.dylib (120) <2CB96D10-1E3E-39B1-B90D-C56C3818321E> /usr/lib/libc++.1.dylib
    0x7fff8d1fa000 -     0x7fff8d205ff7  com.apple.NetAuth (5.0 - 5.0) <C811E662-9EC3-3B74-808A-A75D624F326B> /System/Library/PrivateFrameworks/NetAuth.framework/Versions/A/NetAuth
    0x7fff8d206000 -     0x7fff8d22dffb  libsystem_info.dylib (449.1.3) <395D8CD6-616A-3BD3-A195-C6D68EB9AB22> /usr/lib/system/libsystem_info.dylib
    0x7fff8d22e000 -     0x7fff8d2b7fff  com.apple.ColorSync (4.9.0 - 4.9.0) <E7E0D542-D77A-3E32-B146-4D0FEAF282D3> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ColorSync.framework/Versions/A/ColorSync
    0x7fff8d2b8000 -     0x7fff8d2fdff6  com.apple.HIServices (1.23 - 468) <5970AF5C-F5BD-3B6A-97C9-95B2CA98D71D> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/HIServices
    0x7fff8d2fe000 -     0x7fff8d32dff9  com.apple.GSS (4.0 - 2.0) <44E914BE-B0D0-3E05-9451-CA9E539AFA52> /System/Library/Frameworks/GSS.framework/Versions/A/GSS
    0x7fff8d32e000 -     0x7fff8d3f8ff7  com.apple.LaunchServices (572.28 - 572.28) <FC72C089-A069-3374-B80A-E041AF149F24> /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/LaunchServices
    0x7fff8d51e000 -     0x7fff8d522ff7  libheimdal-asn1.dylib (323.92.1) <CAE21FFF-5763-399C-B7C5-EEBFFEEF2242> /usr/lib/libheimdal-asn1.dylib
    0x7fff8d528000 -     0x7fff8de47797  com.apple.CoreGraphics (1.600.0 - 599.35.4) <C8CBC664-0CD2-3C7D-A301-9B3BA731250C> /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics
    0x7fff8ded9000 -     0x7fff8dfcaff9  libiconv.2.dylib (41) <BB44B115-AC32-3877-A0ED-AEC6232A4563> /usr/lib/libiconv.2.dylib
    0x7fff8e2d1000 -     0x7fff8e2d5ff7  libcache.dylib (62) <8C1EFC4F-3F51-3DE9-A973-360B461F3D65> /usr/lib/system/libcache.dylib
    0x7fff8e320000 -     0x7fff8e4cdf27  libobjc.A.dylib (551.1) <F21C5742-7B9C-31F1-BBAE-1717BC6C2F1B> /usr/lib/libobjc.A.dylib
    0x7fff8e5b5000 -     0x7fff8e5b6fff  libunc.dylib (28) <C3737C9A-C06F-310C-B78C-7D8D882A35DE> /usr/lib/system/libunc.dylib
    0x7fff8e68c000 -     0x7fff8e6a3ff7  com.apple.CFOpenDirectory (10.9 - 173.90.1) <7BC0194E-1B40-3FCA-ACD2-235CE5D65DFA> /System/Library/Frameworks/OpenDirectory.framework/Versions/A/Frameworks/CFOpenDirectory.framework/Versions/A/CFOpenDirectory
    0x7fff8e7c3000 -     0x7fff8e7d0ff7  libxar.1.dylib (202) <5572AA71-E98D-3FE1-9402-BB4A84E0E71E> /usr/lib/libxar.1.dylib
    0x7fff8e7d8000 -     0x7fff8e990ffb  libicucore.A.dylib (511.35) <6F097DA7-147C-32A1-93D2-728A64CF0DC2> /usr/lib/libicucore.A.dylib
    0x7fff8e9dd000 -     0x7fff8e9ddfff  com.apple.ApplicationServices (48 - 48) <F250170A-8805-3731-9097-78CAD04481F0> /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 1
    thread_create: 0
    thread_set_state: 0
  Calls made by this process:
    task_for_pid: 0
    thread_create: 0
    thread_set_state: 0
  Calls made by all processes on this machine:
    task_for_pid: 8051
    thread_create: 1
    thread_set_state: 0

VM Region Summary:
ReadOnly portion of Libraries: Total=121.3M resident=60.9M(50%) swapped_out_or_unallocated=60.4M(50%)
Writable regions: Total=46.2M written=324K(1%) resident=496K(1%) swapped_out=0K(0%) unallocated=45.7M(99%)

REGION TYPE                      VIRTUAL
===========                      =======
Dispatch continuations             8192K
Kernel Alloc Once                     4K
MALLOC                             27.3M
MALLOC (admin)                       32K
STACK GUARD                        56.0M
Stack                              10.6M
VM_ALLOCATE                         328K
__DATA                             4472K
__LINKEDIT                         66.1M
__TEXT                             55.2M
__UNICODE                           544K
shared memory                         4K
===========                      =======
TOTAL                             228.6M
mikemorris commented 10 years ago

Oh that's interesting @springmeyer - I wasn't seeing any crashes on my machine but Error pixel format: invalid CoreGraphics connection was the same error I was hitting in the full node-mapbox-gl-native stack.

mikemorris commented 10 years ago

Huh, so I actually hit that same segfault on the first run today @springmeyer.

jfirebaugh commented 10 years ago

Huh, I would certainly expect CGLChoosePixelFormat to be threadsafe. I wasn't able to replicate the "invalid CoreGraphics connection" error after checking out https://github.com/mikemorris/headless-gl-multithreaded/commit/22d47c30562e695b172e3f28c55f3b185ce13520.

The segfault is an expected follow on given that the context failed to initialize.

kkaefer commented 10 years ago

I'm not getting any crashes on that program. Maybe this is device driver specific? I am using a nVidia GeForce GT 650M, and a Intel HD Graphics 4000. I ran the program with both GPUs (using gfxCardStatus) and didn't see any crashes/segfaults.

mikemorris commented 10 years ago

Interesting. I'm on a rMBP with the integrated Intel Iris onboard graphics and was seeing this on my machine, a similar GLX error on an older MBP running Linux, and on Travis. Breaking out HeadlessDisplay and sharing a single connection in mapbox/mapbox-gl-native/issues/478 seems to have resolved this though.