is open() truly thread-safe?
I'm getting the following race condition detected by DRDT, on SPARC/Solaris 10 6/06:
38 static char random_device_name[] = "/dev/urandom";
68if ((random_fildes = open (random_device_name, O_RDONLY)) < 0)
69 {
70 log_message (APP_FATAL, FILE_LINE "cannot open %s; errno=%d (%s); exiting!",
71 random_device_name, errno, errno_string (errno));
72 exit (EXIT_FAILURE);
73 }
Access 1: Write
isptsfd + 0x00000050
Access 2: Write
isptsfd + 0x00000050
_open + 0x00000050
open + 0x00000064
MessageTransfer::MessageTransfer(const char*,const char*,const char*,const char*,const char*) + 0x0000051C, line 68 in alternate source context "messaging.cc"
MessageServer::MessageServer(const char*,const char*,const char*,const char*,const char*) + 0x00000074, line 393 in alternate source context "messaging.cc"
fragment_request_reader_thread_main + 0x000001CC, line 1384 in "fraggen.cc"
_lwp_start + 0x00000000
Two separate threads are trying to open a file descriptor for the same file. Is that what's causing this conflict, or is it something more general within open()? (random_fildes is local to each thread, so that's not the conflict.)
[1248 byte] By [
herteg] at [2007-11-26 10:11:59]

# 1
Self-diagnosing this problem, it looks as though I've run into bug 6355084: Posix compliant open() of a character device is not MT-safe (http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6355084). It supposedly got fixed in snv_29, and indeed the current OpenSolaris code (http://cvs.opensolaris.org/source/xref/on/usr/src/lib/libc/port/sys/libc_open. c) seems to show this. However, apparently the fix, though made for Nevada back in 2005, never made it into Solaris 10, not even in the 6/06 release (which I'm running). What are the chances of getting this fix rolled into a patch for Solaris 10?
(I guess this is the downside of releasing a powerful tool like DRDT: all your bugs come crawling to the surface.)
# 2
We really have no idea on Solaris plans for releasing patches.
You better ask on [url=http://forum.sun.com/jive/forum.jspa?forumID=298]Solaris[/url] part of this forum.
> I guess this is the downside of releasing a powerful tool like DRDT: all your bugs come crawling to the surface
I do not believe it is a downside. A prime goal of this tool is to expose these kinds of problems. And it really does not matter if it comes down to revealing bugs in our own code. It IS helpful both for us and our customers.
Hopefully it did not ruin your dream about Solaris being completely bug-less? ;)
regards,
__Fedor.
SFV at 2007-7-7 1:59:30 >
