-
Notifications
You must be signed in to change notification settings - Fork 479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WARN: Segmentation fault: address not mapped in llama.cpp #1949
Comments
Here is the backtrace.
|
Looks like a memory corruption on the stack. I've added a debug message and the problem was gone. :( |
It seems the |
I think I found the reason.. Strangely, it seems the llama binary didn't followed the x86_64 calling convention and used
The The following patch seems to work well for diff --git a/arch/x86_64/mcount.S b/arch/x86_64/mcount.S
index dd32b0a6..8f0f07e0 100644
--- a/arch/x86_64/mcount.S
+++ b/arch/x86_64/mcount.S
@@ -57,9 +57,13 @@ GLOBAL(mcount)
/* save rax (implicit argument for variadic functions) */
push %rax
+ push %r10
+ push %r11
call mcount_entry
+ pop %r11
+ pop %r10
pop %rax
/* restore original stack pointer */ |
Thanks for the investigation. I see it works fine with
|
How about this too? ENTRY(mcount_return)
.cfi_startproc
- sub $48, %rsp
- .cfi_def_cfa_offset 48
-
- movq %rdi, 32(%rsp)
+ sub $96, %rsp
+ .cfi_def_cfa_offset 96
+
+ /* save all caller-saved registers due to -fipa-ra */
+ movq %r11, 80(%rsp)
+ movq %r10, 72(%rsp)
+ movq %r9, 64(%rsp)
+ movq %r8, 56(%rsp)
+ movq %rdi, 48(%rsp)
+ movq %rsi, 40(%rsp)
+ movq %rcx, 32(%rsp)
+
+ /* below are used to carry return value */
movdqu %xmm0, 16(%rsp)
movq %rdx, 8(%rsp)
movq %rax, 0(%rsp)
@@ -113,14 +129,21 @@ ENTRY(mcount_return)
movq 0(%rsp), %rsp
/* restore original return address in parent */
- movq %rax, 40(%rsp)
+ movq %rax, 88(%rsp)
movq 0(%rsp), %rax
movq 8(%rsp), %rdx
movdqu 16(%rsp), %xmm0
- movq 32(%rsp), %rdi
- add $40, %rsp
+ movq 32(%rsp), %rcx
+ movq 40(%rsp), %rsi
+ movq 48(%rsp), %rdi
+ movq 56(%rsp), %r8
+ movq 64(%rsp), %r9
+ movq 72(%rsp), %r10
+ movq 80(%rsp), %r11
+
+ add $88, %rsp
.cfi_def_cfa_offset 8
retq
.cfi_endproc |
Thanks but still not working.
|
For some reason, I cannot reproduce it within gdb. |
That's weird. Do you mean you cannot reproduce it only when gdb is used? |
Yep, I can reproduce it without gdb. Anyway, I think we can merge what we found so far. |
A couple of fixes and update during investigation of #1949. Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Hmm.. the second change at #1949 (comment) doesn't fix anything. It fails even with and without |
Yeah but I think it should be added together. |
The llama.cpp project already has an option to add
-pg
option withLLAMA_GPROF=1
.But it gets crashed when
llama-cli
is traced with uftrace as follows.It still gets crashed even with
-e
option.The text was updated successfully, but these errors were encountered: