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

Memory overflow warning in pattern_formatter-inl.h #3069

Closed
sketch34 opened this issue Apr 17, 2024 · 1 comment
Closed

Memory overflow warning in pattern_formatter-inl.h #3069

sketch34 opened this issue Apr 17, 2024 · 1 comment

Comments

@sketch34
Copy link

sketch34 commented Apr 17, 2024

spdlog 1.13.0#0 (via spdlog::spdlog_header_only)
gcc 13.2.0

The warning appears to originate from pattern_formatter-inl.h line 804. It only occurs for me when compiling with RelWithDebInfo. Release and Debug builds do not output this warning. It may be an issue in fmt.

image

writing between 2 and 9223372036854775807 bytes into a region of size 1 overflows the destination [-Wstringop-overflow=]

[build]     inlined from 'virtual void spdlog::details::full_formatter::format(const spdlog::details::log_msg&, const tm&, spdlog::memory_buf_t&)' at /home/jarrod/Dev/jinker/out/build/linux-relwithdeb-wsl2/vcpkg_installed/x64-linux/include/spdlog/pattern_formatter-inl.h:804:39:
[build] /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/bits/stl_algobase.h:437:30: warning: 'void* __builtin_memmove(void*, const void*, long unsigned int)' writing between 2 and 9223372036854775807 bytes into a region of size 1 overflows the destination [-Wstringop-overflow=]
[build]   437 |             __builtin_memmove(__result, __first, sizeof(_Tp) * _Num);
[build]       |             ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Full output:

[main] Building folder: jinker 
[build] Starting build
[proc] Executing command: /home/linuxbrew/.linuxbrew/bin/cmake --build /home/jarrod/Dev/jinker/out/build/linux-relwithdeb-wsl2 --parallel 26 --target all
[build] [1/3] Building CXX object CMakeFiles/jinker.dir/src/jinker/aelog.cpp.o
[build] In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/string:51,
[build]                  from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/bits/locale_classes.h:40,
[build]                  from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/bits/ios_base.h:41,
[build]                  from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/ios:44,
[build]                  from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/istream:40,
[build]                  from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/sstream:40,
[build]                  from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/chrono:45,
[build]                  from /home/jarrod/Dev/jinker/out/build/linux-relwithdeb-wsl2/vcpkg_installed/x64-linux/include/spdlog/common.h:10,
[build]                  from /home/jarrod/Dev/jinker/out/build/linux-relwithdeb-wsl2/vcpkg_installed/x64-linux/include/spdlog/sinks/base_sink.h:12,
[build]                  from /home/jarrod/Dev/jinker/src/jinker/details/layered_sink.h:2,
[build]                  from /home/jarrod/Dev/jinker/src/jinker/aelog.h:3,
[build]                  from /home/jarrod/Dev/jinker/src/jinker/aelog.cpp:2:
[build] In static member function 'static constexpr _Up* std::__copy_move<_IsMove, true, std::random_access_iterator_tag>::__copy_m(_Tp*, _Tp*, _Up*) [with _Tp = char; _Up = char; bool _IsMove = false]',
[build]     inlined from 'constexpr _OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = false; _II = char*; _OI = char*]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/bits/stl_algobase.h:506:30,
[build]     inlined from 'constexpr _OI std::__copy_move_a1(_II, _II, _OI) [with bool _IsMove = false; _II = char*; _OI = char*]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/bits/stl_algobase.h:533:42,
[build]     inlined from 'constexpr _OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = false; _II = char*; _OI = char*]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/bits/stl_algobase.h:540:31,
[build]     inlined from 'constexpr _OI std::copy(_II, _II, _OI) [with _II = char*; _OI = char*]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/bits/stl_algobase.h:633:7,
[build]     inlined from 'static _ForwardIterator std::__uninitialized_copy<true>::__uninit_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = char*; _ForwardIterator = char*]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/bits/stl_uninitialized.h:147:27,
[build]     inlined from '_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = char*; _ForwardIterator = char*]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/bits/stl_uninitialized.h:185:15,
[build]     inlined from 'constexpr void fmt::v9::basic_memory_buffer<T, SIZE, Allocator>::grow(size_t) [with T = char; long unsigned int SIZE = 250; Allocator = std::allocator<char>]' at /home/jarrod/Dev/jinker/out/build/linux-relwithdeb-wsl2/vcpkg_installed/x64-linux/include/fmt/format.h:925:26,
[build]     inlined from 'constexpr void fmt::v9::detail::buffer<T>::try_reserve(size_t) [with T = char]' at /home/jarrod/Dev/jinker/out/build/linux-relwithdeb-wsl2/vcpkg_installed/x64-linux/include/fmt/core.h:928:39,
[build]     inlined from 'constexpr void fmt::v9::detail::buffer<T>::try_reserve(size_t) [with T = char]' at /home/jarrod/Dev/jinker/out/build/linux-relwithdeb-wsl2/vcpkg_installed/x64-linux/include/fmt/core.h:927:24,
[build]     inlined from 'constexpr void fmt::v9::detail::buffer<T>::push_back(const T&) [with T = char]' at /home/jarrod/Dev/jinker/out/build/linux-relwithdeb-wsl2/vcpkg_installed/x64-linux/include/fmt/core.h:932:16,
[build]     inlined from 'virtual void spdlog::details::full_formatter::format(const spdlog::details::log_msg&, const tm&, spdlog::memory_buf_t&)' at /home/jarrod/Dev/jinker/out/build/linux-relwithdeb-wsl2/vcpkg_installed/x64-linux/include/spdlog/pattern_formatter-inl.h:804:39:
[build] /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/bits/stl_algobase.h:437:30: warning: 'void* __builtin_memmove(void*, const void*, long unsigned int)' writing between 2 and 9223372036854775807 bytes into a region of size 1 overflows the destination [-Wstringop-overflow=]
[build]   437 |             __builtin_memmove(__result, __first, sizeof(_Tp) * _Num);
[build]       |             ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[build] In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/x86_64-pc-linux-gnu/bits/c++allocator.h:33,
[build]                  from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/bits/allocator.h:46,
[build]                  from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/string:43:
[build] In member function '_Tp* std::__new_allocator<_Tp>::allocate(size_type, const void*) [with _Tp = char]',
[build]     inlined from 'constexpr _Tp* std::allocator< <template-parameter-1-1> >::allocate(std::size_t) [with _Tp = char]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/bits/allocator.h:198:40,
[build]     inlined from 'static constexpr _Tp* std::allocator_traits<std::allocator<_CharT> >::allocate(allocator_type&, size_type) [with _Tp = char]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/bits/alloc_traits.h:482:28,
[build]     inlined from 'constexpr void fmt::v9::basic_memory_buffer<T, SIZE, Allocator>::grow(size_t) [with T = char; long unsigned int SIZE = 250; Allocator = std::allocator<char>]' at /home/jarrod/Dev/jinker/out/build/linux-relwithdeb-wsl2/vcpkg_installed/x64-linux/include/fmt/format.h:923:49,
[build]     inlined from 'constexpr void fmt::v9::detail::buffer<T>::try_reserve(size_t) [with T = char]' at /home/jarrod/Dev/jinker/out/build/linux-relwithdeb-wsl2/vcpkg_installed/x64-linux/include/fmt/core.h:928:39,
[build]     inlined from 'constexpr void fmt::v9::detail::buffer<T>::try_reserve(size_t) [with T = char]' at /home/jarrod/Dev/jinker/out/build/linux-relwithdeb-wsl2/vcpkg_installed/x64-linux/include/fmt/core.h:927:24,
[build]     inlined from 'constexpr void fmt::v9::detail::buffer<T>::push_back(const T&) [with T = char]' at /home/jarrod/Dev/jinker/out/build/linux-relwithdeb-wsl2/vcpkg_installed/x64-linux/include/fmt/core.h:932:16,
[build]     inlined from 'virtual void spdlog::details::full_formatter::format(const spdlog::details::log_msg&, const tm&, spdlog::memory_buf_t&)' at /home/jarrod/Dev/jinker/out/build/linux-relwithdeb-wsl2/vcpkg_installed/x64-linux/include/spdlog/pattern_formatter-inl.h:804:39:
[build] /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/bits/new_allocator.h:147:55: note: destination object of size 1 allocated by 'operator new'
[build]   147 |         return static_cast<_Tp*>(_GLIBCXX_OPERATOR_NEW(__n * sizeof(_Tp)));
[build]       |                                                       ^
[build] [2/3] Linking CXX shared library libjinker.so
[build] [3/3] Linking CXX executable jinker-tests
[driver] Build completed: 00:00:07.014
[build] Build finished with exit code 0
@tt4g
Copy link
Contributor

tt4g commented Apr 17, 2024

Duplicate fmtlib/fmt#3533 (fixed fmt v10.1.0)

And this is GCC bug.
See this comment: fmtlib/fmt#3533 (comment)

@gabime gabime closed this as completed Apr 25, 2024
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