Last active
March 16, 2019 20:41
-
-
Save jido/4a6de9088033294bb21cf24cf57760fc to your computer and use it in GitHub Desktop.
Why do I get libdyld.dylib`stack_not_16_byte_aligned_error ?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-> 0x100000ee4 <+5>: callq 0x100000f74 ; symbol stub for: malloc | |
0x100000ee9 <+10>: addq $0x10, %rsp | |
0x100000eed <+14>: cmpq $0x0, %rax | |
0x100000ef1 <+18>: je 0x100000f3b ; Integer_bits_32_outofmemory | |
Target 0: (int32) stopped. | |
(lldb) reg read rbp rsp | |
rbp = 0x00007ffeefbff9e0 | |
rsp = 0x00007ffeefbff9d8 | |
(lldb) n | |
Process 23851 stopped | |
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT) | |
frame #0: 0x00007fff6b12ac92 libdyld.dylib`stack_not_16_byte_aligned_error | |
libdyld.dylib`stack_not_16_byte_aligned_error: | |
-> 0x7fff6b12ac92 <+0>: movdqa %xmm0, (%rsp) | |
0x7fff6b12ac97 <+5>: int3 | |
libdyld.dylib`_dyld_fast_stub_entry: | |
0x7fff6b12ac98 <+0>: pushq %rbp | |
0x7fff6b12ac99 <+1>: movq %rsp, %rbp | |
Target 0: (int32) stopped. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.intel_syntax noprefix | |
_plus: | |
mov eax, edi | |
add eax, esi | |
jo plus_overflow | |
jmp r8 | |
plus_overflow: | |
jmp r9 | |
_times: | |
mov eax, edi | |
imul eax, esi | |
jo times_overflow | |
jmp r8 | |
times_overflow: | |
jmp r9 | |
_minus: | |
mov eax, edi | |
sub eax, esi | |
jo minus_overflow | |
jmp r8 | |
minus_overflow: | |
jmp r9 | |
_over: | |
cmp esi, 0 | |
je over_dividebyzero | |
mov eax, edi | |
cdq ## expand eax to edx:eax | |
idiv esi ## result in eax, remainder in edx | |
jmp r8 | |
over_dividebyzero: | |
mov eax, 0x80000000 | |
jmp r9 | |
_opposite: | |
mov esi, edi | |
mov edi, 0 | |
jmp _minus | |
_instance: | |
mov eax, 0[rip + _int32] | |
jmp r8 | |
_Integer_bits_32: | |
and rsp, ~0xf ## ensure stack pointer is 16-aligned | |
## push r8 | |
## push r9 | |
mov edi, (6 * 8) ## allocate memory for 6 pointers | |
call _malloc | |
## pop r9 | |
## pop r8 | |
cmp rax, 0 | |
je Integer_bits_32_outofmemory | |
lea rsi, [rip + _instance] | |
lea rdi, [rip + _plus] | |
lea rcx, [rip + _times] | |
lea rdx, [rip + _minus] | |
lea r10, [rip + _over] | |
lea r11, [rip + _opposite] | |
mov [rax], rsi | |
mov [rax + 8], rdi | |
mov [rax + 2 * 8], rcx | |
mov [rax + 3 * 8], rdx | |
mov [rax + 4 * 8], r10 | |
mov [rax + 5 * 8], r11 | |
jmp r8 | |
Integer_bits_32_outofmemory: | |
mov rax, [rip + outofmemory_message] | |
jmp r9 | |
.globl _main ## -- Begin function main | |
.p2align 4 | |
_main: ## @main | |
.cfi_startproc | |
## %bb.0: | |
mov edi, 2000000001 | |
mov esi, 500000000 | |
lea r8, [rip + next] | |
lea r9, [rip + zero] | |
.cfi_def_cfa_offset 32 | |
## mov edi, (6 * 8) | |
## call _malloc | |
jmp _Integer_bits_32 | |
zero: | |
mov eax, -1 | |
next: | |
ret | |
.cfi_endproc | |
## -- End function | |
.data | |
.globl _int32 | |
_int32: | |
.long 0 | |
outofmemory_message: | |
.asciz "ERROR: Out of memory" | |
.subsections_via_symbols |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment