Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9028345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:57:48+00:00 2026-06-16T06:57:48+00:00

I’d need a hand in solving today’s multithreading mystery. I have an application that

  • 0

I’d need a hand in solving today’s multithreading mystery.

I have an application that has a mediator, say:

class Mediator{
    ConfigMgr * mgr;
    ....
    Config getConfig(){
    return mgr->getConfig();
    };
};

ConfigMgr is properly initialized, there’s no problem with it whatsoever. It consist of, amongst other things, a Config blueprint, which is a struct that has some booleans and std::strings:

struct Config{
    std::string param1;
    std::string param2;
    ....
}

class ConfigMgr {
    Config blueprint;

    Config getConfig(){
        Lock l(mtx); //wrapper on POSIX mutex and lock, works as expected
        refreshConfig(); // some stuff that might alter Config blueprint
        return config;
    }

}

Finally, I have multiple working threads that once in a while might need to call
mediator->getConfig().param1;

The problem is that every now and then my app crashes with SIGABRT. From what I’ve been able to determine, it crashes on double-delete of string in Config’s destructor:
Config::~Config()
The struct has no methods written by me.

I can’t track the root cause. My Config struct is always passed by copy, not reference. I think every thread should have his own copy of Config ever since invocation of ConfigMgr::getConfig(). This construction should be thread-safe, but there clearly is some sort of race condition. Do you guys have any advice?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T06:57:49+00:00Added an answer on June 16, 2026 at 6:57 am

    I’ve been hit by this. The important things to remember are:

    1. std::string shares its char* buffer when it’s copied.
    2. std::string is not designed for multi-threading.

    Therefore you are hitting multiple std::strings in different threads trying to delete the same buffer, that they think should be deleted due to reference counting variables not being updated correctly.

    You’re probably going to have to be more explicit about the string copies you want, and define a copy constructor for the Config object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
In my XML file chapters tag has more chapter tag.i need to display chapters
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I have an array which has BIG numbers and small numbers in it. I
I need a function that will clean a strings' special characters. I do NOT
I have thousands of HTML files to process using Groovy/Java and I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.