https://bugs.kde.org/show_bug.cgi?id=477705

            Bug ID: 477705
           Summary: A program being executed under callgrind terminates as
                    soon as using fmt::format() in case of being compiled
                    as RelWithDebInfo.
    Classification: Developer tools
           Product: valgrind
           Version: 3.22.0
          Platform: Debian stable
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: callgrind
          Assignee: josef.weidendor...@gmx.de
          Reporter: kde3...@a.anjels.de
  Target Milestone: ---

Created attachment 163604
  --> https://bugs.kde.org/attachment.cgi?id=163604&action=edit
demo program to reproduce the issue

SUMMARY
A program being executed under callgrind terminates as soon as using
fmt::format() in case of being compiled as RelWithDebInfo. 

STEPS TO REPRODUCE
1) unzip the attachment callgrind_demo.zip to ~
2) cd ~/callgrind_demo; rm -rf build/;  mkdir build; cd build/; conan install
--profile=../linux_x86_release .. hello-world/0.0.1@siemens-energy/stable;
cmake ..; cmake --build . --verbose; /usr/local/bin/valgrind --tool=callgrind
--callgrind-out-file=callgrind.$RANDOM.log
~/callgrind_demo/build/bin/callgrind_demo

OBSERVED RESULT
The RelWithDebInfo version of "callgrind_demo" program terminates unexpectedly
when being executed under callgrind:

==17794== Callgrind, a call-graph generating cache profiler
==17794== Copyright (C) 2002-2017, and GNU GPL'd, by Josef Weidendorfer et al.
==17794== Using Valgrind-3.22.0 and LibVEX; rerun with -h for copyright info
==17794== Command: /root/callgrind_demo/build/bin/callgrind_demo
==17794==
==17794== For interactive control, run 'callgrind_control -h'.
terminate called after throwing an instance of 'fmt::v9::format_error'
  what():  string pointer is null
==17794==
==17794== Process terminating with default action of signal 6 (SIGABRT)
==17794==    at 0x401B3E2: _dl_sysinfo_int80 (in
/usr/lib/i386-linux-gnu/ld-linux.so.2)
==17794==    by 0x4C1F296: __pthread_kill_implementation (pthread_kill.c:43)
==17794==    by 0x4BCE100: raise (raise.c:26)
==17794==    by 0x4BB7269: abort (abort.c:79)
==17794==    by 0x48C59D5: ??? (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.30)
==17794==    by 0x48D3143: ??? (in /usr/lib/i386-linux-gnu/libstdc++.so.6.0.30)
==17794==    by 0x48D31BC: std::terminate() (in
/usr/lib/i386-linux-gnu/libstdc++.so.6.0.30)
==17794==    by 0x48D34BB: __cxa_throw (in
/usr/lib/i386-linux-gnu/libstdc++.so.6.0.30)
==17794==    by 0x10A52B: fmt::v9::detail::throw_format_error(char const*)
(src/include/fmt/format-inl.h:44)
==17794==    by 0x10BEEF: void
fmt::v9::detail::vformat_to<char>(fmt::v9::detail::buffer<char>&,
fmt::v9::basic_string_view<char>,
fmt::v9::basic_format_args<fmt::v9::basic_format_context<std::conditional<std::is_same<fmt::v9::type_identity<char>::type,
char>::value, fmt::v9::appender,
std::back_insert_iterator<fmt::v9::detail::buffer<fmt::v9::type_identity<char>::type>
> >::type, fmt::v9::type_identity<char>::type> >, fmt::v9::detail::locale_ref)
(src/include/fmt/format.h:3322)
==17794==    by 0x10AA79:
fmt::v9::vformat[abi:cxx11](fmt::v9::basic_string_view<char>,
fmt::v9::basic_format_args<fmt::v9::basic_format_context<fmt::v9::appender,
char> >) (src/include/fmt/format-inl.h:1472)
==17794==    by 0x10A33B: main (core.h:3206)
==17794==
==17794== Events    : Ir
==17794== Collected : 1985341
==17794==
==17794== I   refs:      1,985,341
Aborted

EXPECTED RESULT
Successful execution (as well as it is successful for the debug version)

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Debian GNU/Linux 12 (bookworm) in a WSL

ADDITIONAL INFORMATION
If callgrind_demo is compiled as debug version everything works fine.

The simple program to reproduce the issue can be found in the attachment as
well:

#include <fmt/core.h>
int main() {
  auto test = fmt::format("{}", "Hello world.");
  return 0;
}

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to