GLFW崩溃节点进程

时间:2015-05-22 07:49:43

标签: c++ node.js opengl glfw

我正在实施地图服务,我使用opengl来渲染3d建筑物。我使用glfw来获取opengl上下文。在映射服务中,当有请求获取磁贴时,程序会创建一个不可见的GLFW窗口并使用glfwMakeContextCurrent使其成为当前的。映射核心用c ++编写并封装到nodejs,映射服务是nodejs应用程序。当有许多请求时,节点进程将崩溃,并显示以下错误消息:

Process:               node [18015]
Path:                  /usr/local/bin/node
Identifier:            node
Version:               ???
Code Type:             X86-64 (Native)
Parent Process:        node [18010]
Responsible:           Terminal [682]
User ID:               501

Date/Time:             2015-05-22 14:46:07.665 +0800
OS Version:            Mac OS X 10.10.3 (14D136)
Report Version:        11
Anonymous UUID:        F6351CBD-E434-9570-1B79-B6E999DE965F


Time Awake Since Boot: 14000 seconds

Crashed Thread:        6

Exception Type:        EXC_BREAKPOINT (SIGTRAP)
Exception Codes:       0x0000000000000002, 0x0000000000000000

Thread 0:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib          0x00007fff885b521a kevent + 10
1   node                            0x000000010043ce89 uv_run + 239
2   node                            0x00000001003f766a node::Start(int, char**) + 365
3   node                            0x0000000100001374 start + 52

Thread 1:
0   libsystem_kernel.dylib          0x00007fff885af4de mach_msg_trap + 10
1   libsystem_kernel.dylib          0x00007fff885ae64f mach_msg + 55
2   com.apple.CoreFoundation        0x00007fff92bc0eb4 __CFRunLoopServiceMachPort + 212
3   com.apple.CoreFoundation        0x00007fff92bc037b __CFRunLoopRun + 1371
4   com.apple.CoreFoundation        0x00007fff92bbfbd8 CFRunLoopRunSpecific + 296
5   com.apple.CoreFoundation        0x00007fff92c77671 CFRunLoopRun + 97
6   node                            0x0000000100447f1f uv__cf_loop_runner + 67
7   node                            0x000000010043c54a uv__thread_start + 25
8   libsystem_pthread.dylib         0x00007fff879e1268 _pthread_body + 131
9   libsystem_pthread.dylib         0x00007fff879e11e5 _pthread_start + 176
10  libsystem_pthread.dylib         0x00007fff879df41d thread_start + 13

Thread 2:: Dispatch queue: com.apple.libdispatch-manager
0   libsystem_kernel.dylib          0x00007fff885b5232 kevent64 + 10
1   libdispatch.dylib               0x00007fff8d91ca6a _dispatch_mgr_thread + 52

Thread 3:: SamplerThread
0   libsystem_kernel.dylib          0x00007fff885af51a semaphore_wait_trap + 10
1   node                            0x00000001003ed7f8 v8::internal::MacOSSemaphore::Wait() + 24
2   node                            0x00000001002fba49 v8::internal::RuntimeProfilerRateLimiter::SuspendIfNecessary() + 121
3   node                            0x00000001003ed8c8 v8::internal::SamplerThread::Run() + 88
4   node                            0x00000001003ed08c v8::internal::ThreadEntry(void*) + 60
5   libsystem_pthread.dylib         0x00007fff879e1268 _pthread_body + 131
6   libsystem_pthread.dylib         0x00007fff879e11e5 _pthread_start + 176
7   libsystem_pthread.dylib         0x00007fff879df41d thread_start + 13

Thread 4:
0   libsystem_kernel.dylib          0x00007fff885b4136 __psynch_cvwait + 10
1   node                            0x0000000100445578 uv_cond_wait + 9
2   node                            0x0000000100445dfc worker + 207
3   node                            0x000000010043c54a uv__thread_start + 25
4   libsystem_pthread.dylib         0x00007fff879e1268 _pthread_body + 131
5   libsystem_pthread.dylib         0x00007fff879e11e5 _pthread_start + 176
6   libsystem_pthread.dylib         0x00007fff879df41d thread_start + 13

Thread 5:
0   org.gdal.gdal                   0x000000010486fb4e SHPReadObject + 2698
1   org.gdal.gdal                   0x00000001047f7e41 OGRShapeLayer::FetchShape(int) + 45
2   org.gdal.gdal                   0x00000001047f7ff4 OGRShapeLayer::GetNextFeature() + 238
3   org.gdal.gdal                   0x0000000104778e1d OGRLayer::GetFeatureCount(int) + 37
4   org.gdal.gdal                   0x00000001047f8ef9 OGRShapeLayer::GetFeatureCount(int) + 235
5   mapping.node                    0x0000000103a38cbb map::OGRDataSourceWrapper::GetLayer(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, int) + 2347 (ogr_data_source.cpp:111)
6   mapping.node                    0x0000000103a07e02 map::Map::Render__(map::Map::DrawType) + 1490 (map.cpp:271)
7   mapping.node                    0x0000000103a07267 map::Map::Render() + 647 (map.cpp:116)
8   mapping.node                    0x00000001039cb966 MappingWrapper::renderWorker(uv_work_s*) + 22 (mapping_wrapper.cc:542)
9   node                            0x0000000100445d87 worker + 90
10  node                            0x000000010043c54a uv__thread_start + 25
11  libsystem_pthread.dylib         0x00007fff879e1268 _pthread_body + 131
12  libsystem_pthread.dylib         0x00007fff879e11e5 _pthread_start + 176
13  libsystem_pthread.dylib         0x00007fff879df41d thread_start + 13

Thread 6 Crashed:
0   com.apple.CoreFoundation        0x00007fff92cb5744 getAtomTarget + 84
1   com.apple.CoreFoundation        0x00007fff92bfaad2 ___forwarding___ + 178
2   com.apple.CoreFoundation        0x00007fff92bfa998 _CF_forwarding_prep_0 + 120
3   mapping.node                    0x0000000103d5b482 _glfwPlatformMakeContextCurrent + 50
4   mapping.node                    0x0000000103d5baf8 glfwCreateWindow + 712
5   mapping.node                    0x0000000103a2d718 map::OpenGLRender::InitOpenGL() + 40 (opengl_render.cpp:289)
6   mapping.node                    0x0000000103a2d618 map::OpenGLRender::Init(boost::shared_ptr<map::MapStyle>) + 24 (opengl_render.cpp:281)
7   mapping.node                    0x0000000103a074aa map::Map::Render() + 1226 (map.cpp:152)
8   mapping.node                    0x00000001039cb966 MappingWrapper::renderWorker(uv_work_s*) + 22 (mapping_wrapper.cc:542)
9   node                            0x0000000100445d87 worker + 90
10  node                            0x000000010043c54a uv__thread_start + 25
11  libsystem_pthread.dylib         0x00007fff879e1268 _pthread_body + 131
12  libsystem_pthread.dylib         0x00007fff879e11e5 _pthread_start + 176
13  libsystem_pthread.dylib         0x00007fff879df41d thread_start + 13

Thread 7:
0   libsystem_kernel.dylib          0x00007fff885b4136 __psynch_cvwait + 10
1   node                            0x0000000100445578 uv_cond_wait + 9
2   node                            0x0000000100445dfc worker + 207
3   node                            0x000000010043c54a uv__thread_start + 25
4   libsystem_pthread.dylib         0x00007fff879e1268 _pthread_body + 131
5   libsystem_pthread.dylib         0x00007fff879e11e5 _pthread_start + 176
6   libsystem_pthread.dylib         0x00007fff879df41d thread_start + 13

Thread 8:
0   libsystem_kernel.dylib          0x00007fff885b494a __workq_kernreturn + 10
1   libsystem_pthread.dylib         0x00007fff879df40d start_wqthread + 13

Thread 9:
0   libsystem_kernel.dylib          0x00007fff885b494a __workq_kernreturn + 10
1   libsystem_pthread.dylib         0x00007fff879df40d start_wqthread + 13

Thread 10:
0   libsystem_kernel.dylib          0x00007fff885b494a __workq_kernreturn + 10
1   libsystem_pthread.dylib         0x00007fff879df40d start_wqthread + 13

Thread 11:
0   libsystem_kernel.dylib          0x00007fff885b494a __workq_kernreturn + 10
1   libsystem_pthread.dylib         0x00007fff879df40d start_wqthread + 13

Thread 6 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x000000000c000000  rcx: 0x0000000000000001  rdx: 0x000000019a05b2c0
  rdi: 0x0000000c00000001  rsi: 0x0000000000000000  rbp: 0x000000010681caa0  rsp: 0x000000010681ca90
   r8: 0x000000010681cb80   r9: 0x000000010681d000  r10: 0x0000000000000001  r11: 0x00007fff92bfa920
  r12: 0x000000010681cb00  r13: 0x00007fff895930c0  r14: 0x0000000100d8aa50  r15: 0x000000010681cb00
  rip: 0x00007fff92cb5744  rfl: 0x0000000000000287  cr2: 0x000000011888dd80

Logical CPU:     2
Error Code:      0x00000000
Trap Number:     3


Binary Images:
       0x100000000 -        0x10068bfff +node (???) <500822CB-7EA6-34D2-98D6-BF45AF81E1CB> /usr/local/bin/node
       0x100aec000 -        0x100afbfff  libSimplifiedChineseConverter.dylib (64) <468DE6E1-42B9-3751-ACA5-7D16C550FF84> /System/Library/CoreServices/Encodings/libSimplifiedChineseConverter.dylib
       0x100fc1000 -        0x100fc6fff +DTraceProviderBindings.node (0) <BCAA5EDB-BBF3-3556-98E6-6813F1A5BA72> /Users/USER/*/DTraceProviderBindings.node
       0x100fcf000 -        0x100fd4fff +DTraceProviderBindings.node (0) <1A6ED61C-E715-382E-BF88-2BDA307A51B4> /Users/USER/*/DTraceProviderBindings.node
       0x100fdd000 -        0x100fe1fff  com.apple.agl (3.3.0 - AGL-3.3.0) <83B4076C-BD87-3436-B59F-65184128FEC1> /System/Library/Frameworks/AGL.framework/Versions/A/AGL
       0x100fe8000 -        0x100fedfff  com.apple.JavaVM (15.0.0 - 15.0.0) <67BD63C5-D82F-3A31-BC43-C8810356D524> /System/Library/Frameworks/JavaVM.framework/Versions/A/JavaVM
       0x1039c4000 -        0x103df3ff7 +mapping.node (0) <6CCCCAEB-7D48-38D8-8C21-287A5C7E88BA> /Users/USER/*/mapping.node
       0x104174000 -        0x10424aff7 +org.osgeo.geos (3.4.2 - GEOS 3.4.3) <C28ECCD4-2212-3189-A25A-1A9BEFC07351> 
......

......

......

External Modification Summary:
  Calls made by other processes targeting this process:
    task_for_pid: 4
    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: 17548
    thread_create: 0
    thread_set_state: 168

VM Region Summary:

ReadOnly portion of Libraries: Total=243.9M resident=93.0M(38%) 

swapped_out_or_unallocated=150.9M(62%)

Writable regions: Total=1.2G written=174.7M(14%) resident=389.4M(32%) 

swapped_out=473.2M(39%) unallocated=830.0M(68%)

REGION TYPE                      VIRTUAL

===========                      =======

CG shared images                   4528K

CoreUI image data                     4K

Dispatch continuations             8192K

IOKit                             882.6M

Kernel Alloc Once                     8K

MALLOC                            277.4M

MALLOC (admin)                       32K

MALLOC_LARGE (reserved)            3768K        reserved VM address space 
(unallocated)
Memory Tag 255                    552.5M

Memory Tag 255 (reserved)          1920K        reserved VM address space 
(unallocated)
STACK GUARD                        56.0M

Stack                              12.7M

VM_ALLOCATE                        14.4M

__DATA                             19.6M

__GLSLBUILTINS                     2588K

__IMAGE                             528K

__LINKEDIT                         85.2M

__TEXT                            158.6M

__UNICODE                           552K

mapped file                       207.2M

shared memory                        68K

===========                      =======

TOTAL                               2.2G

TOTAL, minus reserved VM space      2.2G

1 个答案:

答案 0 :(得分:0)

很难说出这里发生了什么。但既然你提到这是在高负荷下发生的,我们可以推测一下。这里可能发生的是,你只是耗尽了可用的系统资源。创建一个窗口会触发一系列分配,如果在很短的时间内发生过多的分配,这些分配可能会失败或更糟,会触发一些错误。

我的建议:不要为每个磁贴创建一个OpenGL。在进程开始时创建一次窗口,并使用一堆渲染缓冲区/纹理来绘制切片。然后,在每个请求时,将图块绘制到预分配的资源中,然后将资源保留在下一个图块中。甚至不打扰尝试多线程渲染; OpenGL驱动程序将在内部为您执行此操作,并且驱动程序开发人员已经挤压干燥;充其量你不会放慢整个事情的速度。只需按顺序处理渲染请求。优化将专注于对渲染进行排序,以便渲染切片所需的资源将合并该切片的渲染。