Skip to content
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

PR 4286 causes segfault - please revert #4289

Closed
ja11sop opened this issue Jan 3, 2025 · 5 comments
Closed

PR 4286 causes segfault - please revert #4289

ja11sop opened this issue Jan 3, 2025 · 5 comments

Comments

@ja11sop
Copy link

ja11sop commented Jan 3, 2025

Recent PR #4286 causes segfault.

The following code:

std::ostringstream Stream;
std::string Line = "";
Stream << fmt::format( "{}", fmt::styled( Line, fmt::fg( fmt::terminal_color::blue ) ) ) << "\n";

segfaults with backtrace:

#0  0x000055555568bbf3 in fmt::v11::detail::buffer<char>::append<char> (this=0x0, begin=begin@entry=0x7fffffffb400 "\033[34m", end=end@entry=0x7fffffffb405 "")
    at /home/user/_download/git_https_github.com__fmtlib_fmt.git/include/fmt/base.h:1797
#1  0x00005555556a69e3 in fmt::v11::detail::copy<char, char const*, fmt::v11::basic_appender<char>, 0> (begin=0x7fffffffb400 "\033[34m", end=0x7fffffffb405 "", out=...)
    at /home/user/_download/git_https_github.com__fmtlib_fmt.git/include/fmt/base.h:2008
#2  0x00005555556984d2 in fmt::v11::formatter<fmt::v11::detail::styled_arg<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, char, void>::format<fmt::v11::context> (
    this=0x7fffffffb480, arg=..., ctx=...) at /home/user/_download/git_https_github.com__fmtlib_fmt.git/include/fmt/color.h:574
#3  0x000055555568bcf1 in fmt::v11::detail::value<fmt::v11::context>::format_custom<fmt::v11::detail::styled_arg<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, fmt::v11::formatter<fmt::v11::detail::styled_arg<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, char, void> > (arg=0x7fffffffbaf0, parse_ctx=..., ctx=...)
    at /home/user/_download/git_https_github.com__fmtlib_fmt.git/include/fmt/base.h:2240
#4  0x000055555570f6af in fmt::v11::basic_format_arg<fmt::v11::context>::handle::format (this=<optimized out>, parse_ctx=..., ctx=...)
    at /home/user/_download/git_https_github.com__fmtlib_fmt.git/include/fmt/base.h:2444
#5  0x000055555570d9bd in fmt::v11::detail::default_arg_formatter<char>::operator() (this=0x7fffffffb608, h=...) at /home/user/_download/git_https_github.com__fmtlib_fmt.git/include/fmt/format.h:3488
#6  0x000055555570c767 in fmt::v11::basic_format_arg<fmt::v11::context>::visit<fmt::v11::detail::default_arg_formatter<char> > (this=this@entry=0x7fffffffb5c0, vis=...)
    at /home/user/_download/git_https_github.com__fmtlib_fmt.git/include/fmt/base.h:2484
#7  0x000055555570a4b3 in fmt::v11::detail::vformat_to (buf=..., fmt=..., args=..., loc=...) at /home/user/_download/git_https_github.com__fmtlib_fmt.git/include/fmt/format-inl.h:1454
#8  0x000055555570a387 in fmt::v11::vformat[abi:cxx11](fmt::v11::basic_string_view<char>, fmt::v11::basic_format_args<fmt::v11::context>) (fmt=..., args=...)
    at /home/user/_download/git_https_github.com__fmtlib_fmt.git/include/fmt/format-inl.h:1444
#9  0x000055555568269d in fmt::v11::format<fmt::v11::detail::styled_arg<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > (fmt=...)
    at /home/user/_download/git_https_github.com__fmtlib_fmt.git/include/fmt/format.h:4186
@phprus
Copy link
Contributor

phprus commented Jan 3, 2025

Please, test last release: https://github.com/fmtlib/fmt/releases/tag/11.1.1

PR #4286 does not change formatting using fmt::styled.

@ja11sop
Copy link
Author

ja11sop commented Jan 4, 2025

Latest release works fine - latest commits breaks this.

@ja11sop
Copy link
Author

ja11sop commented Jan 4, 2025

As a note - we build off head and we noticed this as tests all were passing until the related PR was merged to master, then everything broke. It was only after investigating and seeing this PR that it became apparent what had happened. We verified by rolling back to the latest release which then works as normal.

@phprus
Copy link
Contributor

phprus commented Jan 4, 2025

@ja11sop
Copy link
Author

ja11sop commented Jan 5, 2025

As noted on the PR I cloned and ran against this PR and code worked as expected. PR is a nice simplification!

@vitaut vitaut closed this as completed Jan 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants