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

Crash when using spdlog as shared library - libstd++ complains #2663

Closed
DinoMalpera opened this issue Mar 1, 2023 · 2 comments
Closed

Crash when using spdlog as shared library - libstd++ complains #2663

DinoMalpera opened this issue Mar 1, 2023 · 2 comments

Comments

@DinoMalpera
Copy link

DinoMalpera commented Mar 1, 2023

Steps to reproduce

  1. Clone spdlog (d07e8cb)
  2. cmake -DSPDLOG_BUILD_SHARED=ON -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug -B build -S .
  3. cd build
    sudo cmake --build . --target install
  4. CMakeLists.txt:
cmake_minimum_required(VERSION 3.22)
project(untitled9 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_DEBUG")

find_package(spdlog REQUIRED)

add_executable(untitled9 main.cpp)

target_link_libraries( untitled9
        PRIVATE spdlog::spdlog )
  1. main.cpp:
#include <spdlog/spdlog.h>
#include <spdlog/sinks/basic_file_sink.h>

int
main()
{
    auto logger = spdlog::basic_logger_st("mylogger", "log.txt");
    logger->error( "Haowhe" );

    return 0;
}

Error on run

untitled9: malloc.c:2617: sysmalloc: Assertion `(old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)' failed.

Packages

g++-12 (Ubuntu 12.1.0-2ubuntu1~22.04) 12.1.0
libstdc++-12-dev 12.1.0-2ubuntu1~22.04

Related

Possibly related to #2113

Workaround

Works fine when linking spdlog as a static library.
Works fine when set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_DEBUG") is commented out.

@gabime
Copy link
Owner

gabime commented Mar 1, 2023

possible duplicate of #2145

@DinoMalpera
Copy link
Author

I don't know if it's an fmt issue (as indicated in #2145).
When I debug it crashes here.

@gabime gabime closed this as completed Mar 10, 2023
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

2 participants