-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Segfault on OS X when providing a custom formatting function #276
Comments
FWIW, I can't replicate the segfault using the current master (f64ea62). The example program compiled as shown does not result in a crash. I'm using Xcode 7.2.1:
|
Thanks, @LogicalKnight. Looks like this only occurs on an old Clang:
|
Narrowed it further to an invalid
Prints |
To be more specific, the problem is in std::printf("%p\n", fmt::internal::ArgArray<1>::make<fmt::BasicFormatter<char> >(Foo()).custom.format); prints |
Clang miscompiles __ZN3fmt8internal8ArgArrayILj1ELb1EE4makeINS_14BasicFormatterIcEE3FooEENS0_5ValueERKT0_: ## @_ZN3fmt8internal8ArgArrayILj1ELb1EE4makeINS_14BasicFormatterIcEE3FooEENS0_5ValueERKT0_
.cfi_startproc
## BB#0:
pushq %rbp
Ltmp12:
.cfi_def_cfa_offset 16
Ltmp13:
.cfi_offset %rbp, -16
movq %rsp, %rbp
Ltmp14:
.cfi_def_cfa_register %rbp
subq $32, %rsp
movq %rdi, %rax
leaq -32(%rbp), %rdi
movq %rax, %rsi
xorl %edx, %edx
callq __ZN3fmt8internal9MakeValueINS_14BasicFormatterIcEEEC1I3FooEERKT_NS0_8EnableIfIXsr3NotIXsr12ConvertToIntIS7_EE5valueEEE5valueEiE4typeE
movq -32(%rbp), %rax
movzwl -24(%rbp), %edx
addq $32, %rsp
popq %rbp
ret
.cfi_endproc Note that it emits |
Implemented a workaround in 209748f. The bug seems to have been fixed in newer versions of clang. |
Compiling and running the following code
results in segfault:
Only occurs if optimization enabled and with
-std=c++11
.The text was updated successfully, but these errors were encountered: