Bug 33394 - Add test case for Thread race segfault in std::string::append with -O and -s
Summary: Add test case for Thread race segfault in std::string::append with -O and -s
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 4.3.0
: P3 enhancement
Target Milestone: 5.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks: 21334 24882 32261
  Show dependency treegraph
 
Reported: 2007-09-11 16:39 UTC by bennet brauer
Modified: 2015-03-25 15:47 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 3.3, 3.3.6
Last reconfirmed: 2012-01-19 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description bennet brauer 2007-09-11 16:39:18 UTC
This is dependant on bug 32261.

g++ -g -O3 gccbug.cpp -pthread -o gccbug -s

#include <pthread.h>
#include <string>

void* thread_function(void*) {
    for (int k = 0; k < 50000; k++) {
        std::string my_str;
        my_str += "foo";
    }
    return 0;
}

int main()
{
    pthread_t thread1, thread2;

    pthread_create(&thread1, NULL, thread_function, NULL);
    pthread_create(&thread2, NULL, thread_function, NULL);

    void* exitcode;
    pthread_join(thread1, &exitcode);
    pthread_join(thread2, &exitcode);

    return 0;
}
Comment 1 Andrew Pinski 2012-01-19 05:31:00 UTC
Confirmed.
Comment 2 Jonathan Wakely 2015-03-24 14:48:04 UTC
Author: redi
Date: Tue Mar 24 14:47:32 2015
New Revision: 221635

URL: https://gcc.gnu.org/viewcvs?rev=221635&root=gcc&view=rev
Log:
	PR libstdc++/33394
	* testsuite/21_strings/basic_string/pthread33394.cc: Add test.

# Auto-generated commit message above this line, original below.
	PR libstdc++/33394
	* testsuite/21_strings/basic_string/pthread33394.cc: Add test.

Added:
    trunk/libstdc++-v3/testsuite/21_strings/basic_string/pthread33394.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
Comment 3 Jonathan Wakely 2015-03-24 14:56:03 UTC
Testcase added.
Comment 4 Alan Lawrence 2015-03-25 15:47:29 UTC
Author: alalaw01
Date: Wed Mar 25 15:46:58 2015
New Revision: 221666

URL: https://gcc.gnu.org/viewcvs?rev=221666&root=gcc&view=rev
Log:
	PR libstdc++/33394
	* testsuite/21_strings/basic_string/pthread33394.cc: Use
	dg-additional-options.

Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/testsuite/21_strings/basic_string/pthread33394.cc