Bug 20934 - fstream deadlock
Summary: fstream deadlock
Status: CLOSED DUPLICATE of bug 18339
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: libstdc++   
(Show other bugs)
Version: 7.0
Hardware: i386
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact:
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2000-11-16 00:51 UTC by Mitsuhiro Kobungyo
Modified: 2008-05-01 15:37 UTC (History)
0 users

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


Attachments (Terms of Use)

Description Mitsuhiro Kobungyo 2000-11-16 00:51:00 UTC
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 11:17:31 UTC

*** 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.