Search code examples
gccsegmentation-faultlldb

lldb not running - c


Hey I've recently downloaded lldb and haven't been able to get it working properly. I'm compiling a c program with a segmentation fault and want to use lldb to help me solve the problem.

This is the error message I recieve:

charlielamb@Charlies-MacBook-Air jackCompiler % lldb compiled             
(lldb) target create "compiled"
Current executable set to '/Users/charlielamb/Documents/Uni/cs/compliterDesignAndConstruction/comp/jackCompiler/compiled' (x86_64).
(lldb) run
Process 3378 launched: '/Users/charlielamb/Documents/Uni/cs/compliterDesignAndConstruction/comp/jackCompiler/compiled' (x86_64)
Process 3378 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x00007ff80f9cc6b2 libsystem_platform.dylib`_platform_strlen + 18
libsystem_platform.dylib`:
->  0x7ff80f9cc6b2 <+18>: pcmpeqb (%rdi), %xmm0
    0x7ff80f9cc6b6 <+22>: pmovmskb %xmm0, %esi
    0x7ff80f9cc6ba <+26>: andq   $0xf, %rcx
    0x7ff80f9cc6be <+30>: orq    $-0x1, %rax
Target 0: (compiled) stopped.

I've looked around online and couldn't find anything that helps. Does anyone know how to fix this problem?


Solution

  • lldb's running fine, it's just telling you your program crashed while running strlen. EXC_BAD_ACCESS means you tried to read or write from invalid memory. The exception message also tells you what the address was:

    EXC_BAD_ACCESS (code=1, address=0x0)

    The code means it was a read access. The address you tried to read from was 0x0.

    That looks a lot like your code passed a NULL pointer to strlen.