public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: libstdc++/9964: filebuf::close() sometimes fails to close file.
@ 2003-03-22  9:21 paolo
  0 siblings, 0 replies; 2+ messages in thread
From: paolo @ 2003-03-22  9:21 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, peturr02

Synopsis: filebuf::close() sometimes fails to close file.

State-Changed-From-To: open->closed
State-Changed-By: paolo
State-Changed-When: Sat Mar 22 09:21:56 2003
State-Changed-Why:
    Fixed for 3.3 and 3.4.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9964


^ permalink raw reply	[flat|nested] 2+ messages in thread

* libstdc++/9964: filebuf::close() sometimes fails to close file.
@ 2003-03-05 12:56 peturr02
  0 siblings, 0 replies; 2+ messages in thread
From: peturr02 @ 2003-03-05 12:56 UTC (permalink / raw)
  To: gcc-gnats


>Number:         9964
>Category:       libstdc++
>Synopsis:       filebuf::close() sometimes fails to close file.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Mar 05 12:56:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     peturr02@ru.is
>Release:        gcc-3.2.1
>Organization:
>Environment:
Red Hat Linux 8.0
>Description:
It seems that if the call to _M_really_overflow in filebuf::close() fails, then close() doesn't close the file and doesn't delete the buffer.
>How-To-Repeat:
See attachment.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="closebug.cc"
Content-Disposition: inline; filename="closebug.cc"

#include <unistd.h>
#include <signal.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fstream>

#undef NDEBUG
#include <cassert>

int main()
{
	using namespace std;

	signal(SIGPIPE, SIG_IGN);
	unlink("xxx");
  
	if (0 != mkfifo("xxx", S_IRWXU))
	{
		assert(false);
	}
	
	int fval = fork();
	if (fval == -1)
	{
		unlink("xxx");
		assert(false);
	}
	else if (fval == 0)
	{
		filebuf fbin;
		fbin.open("xxx", ios_base::in);
		sleep(1);
		fbin.close();
		exit(0);
	}

	filebuf fb;
	fb.open("xxx", ios_base::out | ios_base::trunc);
	assert(fb.is_open());
	sleep(2);
	fb.sputc('a');
	filebuf* p = fb.close();
	assert(!p);
	assert(!fb.is_open());

	return 0;
}


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-03-22  9:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-22  9:21 libstdc++/9964: filebuf::close() sometimes fails to close file paolo
  -- strict thread matches above, loose matches on Subject: below --
2003-03-05 12:56 peturr02

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).