为什么在OSX上访问D类成员会崩溃?

时间:2016-03-23 12:55:05

标签: macos class crash segmentation-fault d

所以,在我的一个项目遇到意外的段错误之后,我又换了一个新的。

dub init crashtest

然后,我写了这个:

import std.stdio;

class testing
{
    void init()
    {}
}
void main()
{
    testing one;
    one.init();
    writeln("Edit source/app.d to start your project.");
}

段错误似乎源于one.init()。基本上,调用类函数会触发它。 但为什么呢?

我花了几分钟时间添加`writefln(" test");整个计划。代码永远不会到达init函数。不会执行init()中的代码。

当我在OS X上时,我检查了崩溃报告:

Process:               crashtest [40968]
Path:                  /Users/USER/Desktop/*/crashtest
Identifier:            crashtest
Version:               0
Code Type:             X86-64 (Native)
Parent Process:        dub [40962]
Responsible:           Terminal [40321]
User ID:               502

Date/Time:             2016-03-23 20:46:35.822 +0800
OS Version:            Mac OS X 10.11.2 (15C50)
Report Version:        11
Anonymous UUID:        F5455E23-366C-B9FD-16B2-B02588FCBE4A

Sleep/Wake UUID:       FA8990E8-D5F1-423E-A600-67148EB87B24

Time Awake Since Boot: 120000 seconds
Time Since Wake:       3600 seconds

System Integrity Protection: disabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

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

VM Regions Near 0:
--> 
    __TEXT                 000000010b26e000-000000010b29b000 [  180K] r-x/rwx SM=COW  /Users/USER/Desktop/*

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   crashtest                       0x000000010b26ed11 _Dmain + 17 (app.d:11)
1   crashtest                       0x000000010b284684 D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv + 40
2   crashtest                       0x000000010b2845c9 D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ7tryExecMFMDFZvZv + 45
3   crashtest                       0x000000010b284629 D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZv + 45
4   crashtest                       0x000000010b2845c9 D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ7tryExecMFMDFZvZv + 45
5   crashtest                       0x000000010b28453f _d_run_main + 499
6   crashtest                       0x000000010b26edea main + 34
7   libdyld.dylib                   0x00007fff90e8e5ad start + 1

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x0000000000000000  rbx: 0x00007fff54991ab0  rcx: 0x00007fff8e373446  rdx: 0x00007fff549919d8
  rdi: 0x0000000000000000  rsi: 0x00007fff549919d8  rbp: 0x00007fff54991880  rsp: 0x00007fff54991870
   r8: 0x0000000000000008   r9: 0x0000000000000000  r10: 0x00007fff8e373446  r11: 0x0000000000000206
  r12: 0x00007fff54991a08  r13: 0x00007fff549919f3  r14: 0x0000000000000001  r15: 0x00007fff54991a08
  rip: 0x000000010b26ed11  rfl: 0x0000000000010246  cr2: 0x0000000000000000

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


Binary Images:
       0x10b26e000 -        0x10b29afff +crashtest (0) <A987930C-05C4-369D-8DDB-823C515D9BF4> /Users/USER/Desktop/*/crashtest
    0x7fff65b6e000 -     0x7fff65ba4fa7  dyld (360.18) <1A7F8274-FC32-3B86-9979-66B8F2B7B5E2> /usr/lib/dyld
    0x7fff86f6f000 -     0x7fff86f70fff  libsystem_blocks.dylib (65) <49D42329-7DE9-3413-92C3-A473A7E9CF35> /usr/lib/system/libsystem_blocks.dylib
    0x7fff8881e000 -     0x7fff88826fe7  libsystem_platform.dylib (74.10.3) <D3A27E10-7F08-3603-ACC8-7A92B2C04BAB> /usr/lib/system/libsystem_platform.dylib
    0x7fff89e22000 -     0x7fff89e22ff7  liblaunch.dylib (756.20.4) <EDF719D6-D2BB-38DD-8C94-4272BEFDA2CD> /usr/lib/system/liblaunch.dylib
    0x7fff8bcee000 -     0x7fff8bcf7ff7  libsystem_pthread.dylib (138.10.4) <327CECD0-B881-3153-8FCC-4FD4818B7F16> /usr/lib/system/libsystem_pthread.dylib
    0x7fff8be5e000 -     0x7fff8be5eff7  libunc.dylib (29) <1D0F8265-F026-3CBD-93D3-F8DF14FFCE68> /usr/lib/system/libunc.dylib
    0x7fff8c266000 -     0x7fff8c267fff  libDiagnosticMessagesClient.dylib (100) <4243B6B4-21E9-355B-9C5A-95A216233B96> /usr/lib/libDiagnosticMessagesClient.dylib
    0x7fff8c487000 -     0x7fff8c7f2657  libobjc.A.dylib (680) <58CB8CFC-7DBD-3A53-BD72-A42FF799B21E> /usr/lib/libobjc.A.dylib
    0x7fff8cff1000 -     0x7fff8d01afff  libc++abi.dylib (125) <DCCC8177-3D09-35BC-9784-2A04FEC4C71B> /usr/lib/libc++abi.dylib
    0x7fff8d649000 -     0x7fff8d649ff7  libkeymgr.dylib (28) <09397E01-6066-3179-A50C-2CE666FDA929> /usr/lib/system/libkeymgr.dylib
    0x7fff8d64a000 -     0x7fff8d651ff7  libcompiler_rt.dylib (62) <D3C4AB40-23B4-3BC6-8C38-5B8758D14E80> /usr/lib/system/libcompiler_rt.dylib
    0x7fff8e35c000 -     0x7fff8e37afff  libsystem_kernel.dylib (3248.20.55) <0E688457-4915-36DD-8798-5C2EDEE3F1A3> /usr/lib/system/libsystem_kernel.dylib
    0x7fff8eab9000 -     0x7fff8eae2fff  libsystem_info.dylib (477.20.1) <6513635B-4ADE-3B45-BF63-ED7AC565B0C9> /usr/lib/system/libsystem_info.dylib
    0x7fff9023d000 -     0x7fff90242ff7  libmacho.dylib (875.1) <CB745E1F-4885-3F96-B38B-2093DF488FD5> /usr/lib/system/libmacho.dylib
    0x7fff90801000 -     0x7fff9080aff3  libsystem_notify.dylib (150.20.3) <243FADE1-255A-3B78-8033-F336CD64B817> /usr/lib/system/libsystem_notify.dylib
    0x7fff90e8b000 -     0x7fff90e8effb  libdyld.dylib (360.18) <5F3777A7-F07E-3D5F-BFA3-A920FF4170ED> /usr/lib/system/libdyld.dylib
    0x7fff911fb000 -     0x7fff91203ffb  libsystem_dnssd.dylib (625.20.4) <945B5FB1-DA91-3D45-A961-A8FAD53C1E7E> /usr/lib/system/libsystem_dnssd.dylib
    0x7fff916e5000 -     0x7fff916edfff  libsystem_networkextension.dylib (385.20.6) <DC8A102A-BF02-31A4-8914-65C34DF6B592> /usr/lib/system/libsystem_networkextension.dylib
    0x7fff9213a000 -     0x7fff92167fff  libdispatch.dylib (501.20.1) <324C9189-2AF3-3356-847F-6F4CE1C6E901> /usr/lib/system/libdispatch.dylib
    0x7fff922e8000 -     0x7fff922eaff7  libsystem_configuration.dylib (802.20.7) <5FD79070-36CC-3D02-BEA7-BB5D2AE97D5D> /usr/lib/system/libsystem_configuration.dylib
    0x7fff923d9000 -     0x7fff923eaff7  libsystem_trace.dylib (201.10.3) <F0B7622B-FB6B-31E1-8703-38F57BE84553> /usr/lib/system/libsystem_trace.dylib
    0x7fff929db000 -     0x7fff929dcffb  libremovefile.dylib (41) <B8D1A5FC-CFD5-3AAB-8A10-14DDC129710A> /usr/lib/system/libremovefile.dylib
    0x7fff92b8e000 -     0x7fff92b8ffff  libsystem_secinit.dylib (20) <FD6ECF2C-1489-32CA-981B-9045B5EB1FAA> /usr/lib/system/libsystem_secinit.dylib
    0x7fff95027000 -     0x7fff9502bfff  libcache.dylib (75) <6B245C0A-F3EA-383B-A542-5B0D0456A41B> /usr/lib/system/libcache.dylib
    0x7fff95919000 -     0x7fff95990fe7  libcorecrypto.dylib (335.20.1) <C6BD205F-4ECE-37EE-BCAB-A76F39CDCFFA> /usr/lib/system/libcorecrypto.dylib
    0x7fff95b1b000 -     0x7fff95b32fff  libsystem_asl.dylib (322) <3C2D3ACD-0DD1-337A-8247-44A910D67A65> /usr/lib/system/libsystem_asl.dylib
    0x7fff95f3c000 -     0x7fff95f52ff7  libsystem_coretls.dylib (83.20.8) <30AF7134-6CA7-3582-B9D3-507D6ED19A88> /usr/lib/system/libsystem_coretls.dylib
    0x7fff97311000 -     0x7fff97314ff7  libsystem_sandbox.dylib (460.20.9) <1C891336-1B25-365D-B43E-96D5B3BE66B0> /usr/lib/system/libsystem_sandbox.dylib
    0x7fff977ab000 -     0x7fff977c7ff7  libsystem_malloc.dylib (67) <9EECAB18-F025-34C4-8E32-7EFFA6720EFC> /usr/lib/system/libsystem_malloc.dylib
    0x7fff98144000 -     0x7fff981a5ff7  libsystem_network.dylib (583.20.10) <1C0410F3-F66E-3B0D-B8AD-0D49AB15A529> /usr/lib/system/libsystem_network.dylib
    0x7fff99376000 -     0x7fff99377ffb  libSystem.B.dylib (1226.10.1) <54388DF0-3813-33E4-BE8D-7743A81ACF4D> /usr/lib/libSystem.B.dylib
    0x7fff9956c000 -     0x7fff9956eff7  libquarantine.dylib (80) <163CF63A-7455-3D1F-AE57-8C4475A9204C> /usr/lib/system/libquarantine.dylib
    0x7fff9a7c9000 -     0x7fff9a7f2fff  libxpc.dylib (756.20.4) <61AB4610-9304-354C-9E9B-D57198AE9866> /usr/lib/system/libxpc.dylib
    0x7fff9ace5000 -     0x7fff9acedfff  libcopyfile.dylib (127) <F5133269-0B22-388C-A57C-079667B6291E> /usr/lib/system/libcopyfile.dylib
    0x7fff9bae8000 -     0x7fff9bb2eff7  libauto.dylib (186) <999E610F-41FC-32A3-ADCA-5EC049B65DFB> /usr/lib/libauto.dylib
    0x7fff9bc62000 -     0x7fff9bc6dff7  libcommonCrypto.dylib (60075.20.1) <766BC3F5-41F3-3315-BABC-72718A98EA92> /usr/lib/system/libcommonCrypto.dylib
    0x7fff9bf1e000 -     0x7fff9bfabfff  libsystem_c.dylib (1082.20.4) <EAB38A6C-8671-3B13-B500-90EC1B912063> /usr/lib/system/libsystem_c.dylib
    0x7fff9cabd000 -     0x7fff9caecffb  libsystem_m.dylib (3105) <26655445-CA97-321E-B221-801CB378D1AA> /usr/lib/system/libsystem_m.dylib
    0x7fff9caf0000 -     0x7fff9caf2fff  libsystem_coreservices.dylib (19.2) <1B3F5AFC-FFCD-3ECB-8B9A-5538366FB20D> /usr/lib/system/libsystem_coreservices.dylib
    0x7fff9d1e9000 -     0x7fff9d1eeff3  libunwind.dylib (35.3) <124E0F05-2350-3774-A32C-7F5BF38EDE73> /usr/lib/system/libunwind.dylib
    0x7fff9d234000 -     0x7fff9d287ff7  libc++.1.dylib (120.1) <8FC3D139-8055-3498-9AC5-6467CB7F4D14> /usr/lib/libc++.1.dylib

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

VM Region Summary:
ReadOnly portion of Libraries: Total=99.2M resident=0K(0%) swapped_out_or_unallocated=99.2M(100%)
Writable regions: Total=20.4M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=20.4M(100%)

                                VIRTUAL   REGION 
REGION TYPE                        SIZE    COUNT (non-coalesced) 
===========                     =======  ======= 
Activity Tracing                  2048K        2 
Kernel Alloc Once                    4K        2 
MALLOC                            9396K        8 
MALLOC guard page                   16K        4 
STACK GUARD                       56.0M        2 
Stack                             8192K        2 
VM_ALLOCATE                       1028K        3 
__DATA                            1516K       42 
__LINKEDIT                        91.5M        4 
__TEXT                            7836K       43 
shared memory                        8K        3 
===========                     =======  ======= 
TOTAL                            176.8M      104 

Model: MacBookAir5,2, BootROM MBA51.00EF.B04, 2 processors, Intel Core i5, 1.8 GHz, 4 GB, SMC 2.5f7
Graphics: Intel HD Graphics 4000, Intel HD Graphics 4000, Built-In
Memory Module: BANK 0/DIMM0, 2 GB, DDR3, 1600 MHz, 0x802C, 0x384B54463235363634485A2D3147364D3120
Memory Module: BANK 1/DIMM0, 2 GB, DDR3, 1600 MHz, 0x802C, 0x384B54463235363634485A2D3147364D3120
AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0xE9), Broadcom BCM43xx 1.0 (7.21.94.136.1a1)
Bluetooth: Version 4.4.3f4 16616, 3 services, 27 devices, 1 incoming serial ports
Network Service: Wi-Fi, AirPort, en0
Serial ATA Device: APPLE SSD SM256E, 251 GB
USB Device: USB 2.0 Bus
USB Device: Hub
USB Device: Hub
USB Device: Card Reader
USB Device: Apple Internal Keyboard / Trackpad
USB Device: BRCM20702 Hub
USB Device: Bluetooth USB Host Controller
USB Device: USB 2.0 Bus
USB Device: Hub
USB Device: FaceTime HD Camera (Built-in)
USB Device: USB 3.0 Bus
Thunderbolt Bus: MacBook Air, Apple Inc., 23.4

那为什么会这样呢?正在报告EXC_BAD_ACCESS,但它似乎与损坏的指针有关。我不明白这是怎么回事。

1 个答案:

答案 0 :(得分:3)

替换

testing one = new testing();

由:

^(.*?)\s-\s(.*?)$

那应该让你去