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 5992839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:35:23+00:00 2026-05-22T23:35:23+00:00

I experience a segfault after the following line: this->my_set.insert(my_string); The set has been initialized

  • 0

I experience a segfault after the following line:

this->my_set.insert(my_string);

The set has been initialized and it contains std::string.
The inserting string is not referring to a dandling pointer and it’s null-terminated.
All the other strings contained in the set are not null and terminate with ‘\0’.

This is the backtrace:

#0  0xb7076bdb in std::_Rb_tree_insert_and_rebalance () from /usr/lib/libstdc++.so.6
#1  0xb7480795 in std::_Rb_tree<std::string, std::string, std::_Identity<std::string>, std::less<std::string>, std::allocator<std::string> >::_M_insert_ (
    this=0x97bf918, __x=0x0, __p=0x980aa78, __v=@0xaabfc1c4) at /usr/include/c++/4.3/bits/stl_tree.h:854<br/>
#2  0xb7480b96 in std::_Rb_tree<std::string, std::string, std::_Identity<std::string>, std::less<std::string>, std::allocator<std::string> >::_M_insert_unique (this=0x97bf918, __v=@0xaabfc1c4) at /usr/include/c++/4.3/bits/stl_tree.h:1148
#3  0xb74fab2d in std::set<std::string, std::less<std::string>, std::allocator<std::string> >::insert (this=0x97bf918, __x=@0xaabfc1c4)
    at /usr/include/c++/4.3/bits/stl_set.h:381

Any idea?


Edit

More code:

set<string> dangerous_messages; //placed in header file

            qpid::client::Message msg;
            msg = (*mylocal_queues)[queue]->get(10*1e9);
            string msgUID = msg.getHeaders().getAsString("UID");
            if(this->dangerous_messages.count(msgUID))
            {
                       warning("(read_local_queue) Duplicate message \""+msgUID+"\" discarded");
           }
           else
           {
                        msg.getHeaders().setString("BID", bid);
                        this->dangerous_messages.insert(msgUID);
            }

Printing with gdb, I’ve not noticed any corruption in the set or in the string.

  • 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-05-22T23:35:24+00:00Added an answer on May 22, 2026 at 11:35 pm

    Since you stated that the code is multi-threaded without locks, this is probably the result of a race condition. (At least a race condition may result in the exact same stack trace.)

    Use proper locks to ensure correct execution. For example, if you are using OpenMP, then change the code you’ve shown us to:

    #pragma omp critical
    {
        if(this->dangerous_messages.count(msgUID))
        {
            warning("(read_local_queue) Duplicate message \""+msgUID+"\" discarded");
        }
        else
        {
            msg.getHeaders().setString("BID", bid);
            this->dangerous_messages.insert(msgUID);
        }
    }
    

    But in general, your code logic is fundamentally flawed if such an error can occur. You must not share state between threads without a clean cross-thread interface. Use predefined cross-thread communication structures to share state between threads, or use read-only state. Cross-thread writes are almost never OK.

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

Sidebar

Related Questions

I experience a segfault on the following code: I have an abstract class A
My experience with it has been that it's a total mess, and causes problems
My experience has been Windows Forms in VB, using SQL Server as a back
I experience the following problem while using legacy VC6. I just cann't switch to
Debugging experience http://www.dmhermitage.org/wtfborders.png This is making me want to kill myself. I have some
This is my first experience using the Zend Framework. I am attempting to follow
I experience the following apparently undocumented issue, and I want to understand if I
Experience level: newbie. The backbone.js Todos demo uses localStorage. This question is about how
I experience a strange problem with iPhone animation blocks. This code: [UIView animateWithDuration:2 delay:
In Visual C++, sometimes when a resource has been destructed it can still be

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.