Coder Social home page Coder Social logo

Resource deadlock would ocur about spdlog HOT 6 CLOSED

usser0134 avatar usser0134 commented on September 18, 2024
Resource deadlock would ocur

from spdlog.

Comments (6)

tt4g avatar tt4g commented on September 18, 2024

I don't know because the source code is incomplete.
For example, if m2error() is calling the default logger, it would report error resource deadlock would occur because it re-enters HourlyRotatedFileSinkMt which is not re-entrant, but I can't be sure because your code is incomplete.

from spdlog.

usser0134 avatar usser0134 commented on September 18, 2024

I don't know because the source code is incomplete. For example, if m2error() is calling the default logger, it would report error resource deadlock would occur because it re-enters HourlyRotatedFileSinkMt which is not re-entrant, but I can't be sure because your code is incomplete.

Thank you for reply, i updated first post with m2error

from spdlog.

usser0134 avatar usser0134 commented on September 18, 2024

log.hpp is included in stdafx.h and stdafx.h is included in over 100 cpp files

from spdlog.

tt4g avatar tt4g commented on September 18, 2024

std::mutex in HourlyRotatedFileSinkMt is deadlocked because it is accessing the same HourlyRotatedFileSinkMt instance through the default logger from at least m2errror().
Do not access loggers from sink.

from spdlog.

usser0134 avatar usser0134 commented on September 18, 2024

So then, should i create functions for m2error and m2info ?
Log.h

#pragma once

#include <string>

void m2info(const std::string& message);
void m2error(const std::string& message);

template<typename... Args>
void m2info(const std::string& fmt, Args&&... args);

template<typename... Args>
void m2error(const std::string& fmt, Args&&... args);

log.cpp
#include "log.h"
#include <spdlog/spdlog.h>

void m2info(const std::string& message) {
spdlog::info(message);
}

void m2error(const std::string& message) {
spdlog::error(message);
}

template<typename... Args>
void m2info(const std::string& fmt, Args&&... args) {
spdlog::info(fmt, std::forward(args)...);
}

template<typename... Args>
void m2error(const std::string& fmt, Args&&... args) {
spdlog::error(fmt, std::forward(args)...);
}

Should be enough ?

from spdlog.

tt4g avatar tt4g commented on September 18, 2024

The design must be such that loggers are not accessed from inside the sink.

from spdlog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.