LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-15-2008, 10:27 AM   #1
Pranay1711
LQ Newbie
 
Registered: May 2008
Posts: 8

Rep: Reputation: 0
Question ofstream issues on RHEL5


I read various different articles on different forums where folks posted a similar issue but never read any resolution for that.
We are in process of porting our application to RHEL5 (from RHEL3), and am encoutering strange behaviors in constructor on ofstream. A simple command like - "ofstream filename" hangs the process.
It's happening "always" when it's been called inside of a thread (note that i wrote a simple program that creates 10 threads and calls the ofstream constructer but that DID NOT give me any issues, so certainly there is something else that's affecting too). Our application use semaphores and shared memory quite rigourously which is one difference from the sample program i had tried. Could that be the difference?
Any ideas why could that be caused in RHEL5? The application on RHEL4 never had any issues like these.

I tend to think that some issue in pthread_once function could be causing that, but that's a guess, if someone has verified this. This function seem to get called from within the ofstream constructor (as per another thread on other forum i read), which could be the issue.

Any pointer would be extremely helpful. There can be heck of things that can affect, so if there are any specific things that someone needs to help me out with this, mention those please.
If this is a known issue, any patches that needs to get installed.
 
Old 11-16-2008, 10:06 PM   #2
jtison
LQ Newbie
 
Registered: Dec 2005
Location: Connecticut, USA
Distribution: Fedora Cores 9, 10, 15, 17; SLES 10 & 11; RHEL 6.x
Posts: 19

Rep: Reputation: 0
linuxthreads to NPTL transition

The likely reason you don't see a (simple) answer posted is that there is no single (simple) answer.

Over the timeframe possibly covered between RHEL 3 and RHEL 5, libstdc++ has undergone a lot of change. It's been moving closer to doing the Right Thing(tm) over time. But you have to remember you could be dealing with as much as a 5-year technology gap covering a critical period in libstdc++'s evolution.

I'm not so sure you're the victim of a compiler or library bug.

One thing you said caught my attention; you said you "use semaphores and shared memory". Those are meant for communications between processes in multiprocessing (IPC), not threads. Do you have an uncommon program that is both multiprocessing and multithreading? If so, you are walking on a very thin line (called "thread safety") that's been shifting over the time period you're talking about ... your answers are almost guaranteed not to be simple or fixable with a single patch.

Misuse of IPC is quite common in programs designed during the linuxthreads era (prior to Linux kernel 2.6). linuxthreads was broken from the start, it's been replaced by NPTL. You need to make sure your code understands the difference. linuxthreads was a decent approximation of true POSIX thread implementation, but there are significant differences between them. linuxthreads aren't threads; they're separate processes made to look like threads. It's likely that your code did come from that era: the Linux kernel didn't implement threads until 2.6.

With linuxthreads, you needed shmem to share volatile data between "threads", and you needed semaphores to serve as mutexes. Today, you don't. Remember that many of IPC functions are of questionable thread safety, depending on whether you picked Sys V or POSIX IPC. Add to that the fact that libstdc++ itself now uses pthreads calls to implement thread safety, and you can see the potential mess you have on your hands. The truly fatal part about this situation is that work on linuxthreads stopped years ago. I'm almost certain you can't even build a linuxthreads-enabled g++ any more. Whether or not the solution to this problem is simple is related to the complexity of your code -- the only thing I know for sure is that you're going to be changing your code.

If your application really doesn't need IPC, get rid of the semaphores and shmem; use mutexes and thread-shared data areas instead. If your app truly does need IPC, you may wish to review your design and make sure that your program takes required steps to observe thread safety, keeping the transition from linuxthreads to NPTL in mind.

Sorry for the bad news.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
I am having issues trying to configure Postfix on RHEL5 Wheddod Linux - Software 9 10-07-2008 06:51 AM
NTP issues RHEL5 adamjohnson01 Red Hat 4 06-06-2008 08:23 AM
What potential issues could we expect in replacing RHEL3 box with RHEL5? jayunplugged Red Hat 4 03-17-2008 09:21 AM
script issues from suse to RHEL5 AS pingpong Linux - Enterprise 1 02-14-2008 07:17 AM
ofstream problem cgifalcon Linux - Software 2 10-19-2003 01:00 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration