Bug 20934 - fstream deadlock
fstream deadlock
Status: CLOSED DUPLICATE of bug 18339
Product: Red Hat Linux
Classification: Retired
Component: libstdc++ (Show other bugs)
7.0
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2000-11-15 19:51 EST by Mitsuhiro Kobungyo
Modified: 2008-05-01 11:37 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2000-11-15 19:51:03 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Mitsuhiro Kobungyo 2000-11-15 19:51:00 EST
Hi.
This is Kobungyo.

Following Program is deadlocked under RedHat 7.0 when dynamic linked.
But it work correctly under RedHat6.2 in both dynamic link and static link.
Can I use fstream class from 2 or more threads simultaneously ?

$ c++ a.cc -lpthread  <- does not work
$ c++ -static a.cc -lpthread <- ok. but the object is too large.

--

#include <iostream>
#include <fstream>
#include <pthread.h>

using namespace std;
ofstream file;

void *func(void *){
    file << "Hello, again!" << endl;
    pthread_exit(NULL);
}

int main(){
    file.open("a.txt");
    file << "Hello, Wordl!" << endl;
    
    pthread_t t1;
    pthread_create(&t1, NULL, func, NULL);
    pthread_join(t1, NULL);
}
Comment 1 Jakub Jelinek 2000-11-16 06:17:31 EST

*** This bug has been marked as a duplicate of 18339 ***

Note You need to log in before you can comment on or make changes to this bug.