apr-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 55912] New: Pipe creation may fail on Windows in apr_file_pipe_create_ex
Date Thu, 19 Dec 2013 14:34:59 GMT

            Bug ID: 55912
           Summary: Pipe creation may fail on Windows in
           Product: APR
           Version: HEAD
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: APR
          Assignee: bugs@apr.apache.org
          Reporter: gzahm@wanadoo.fr

apr_file_pipe_create_ex creates a pipe with a unique name:

file_io/win32/pipe.c :

static unsigned long id = 0;
sprintf(name, "\\\\.\\pipe\\apr-pipe-%u.%lu", getpid(), id++);

(*in)->filehand = CreateNamedPipe(name,

This code is not reliable in multilthread (id++ is not an atomic operation):
two threads can increment id at the same time.
As a result, the second creation fails: CreateNamedPipe returns
INVALID_HANDLE_VALUE and sets the error to ERROR_PIPE_BUSY (the first pipe was
already created and it still exists in most cases).

The testcase is complicated: the request server must be under heavy load (the
error was triggered around the 988000th request to a CGI script (which was
checking its stdin validity)).

I think that replacing "id++" by a call to "InterlockedIncrement" fixes the
InterlockedIncrement is available for all the Windows versions from Windows 95
(at least).
InterlockedIncrement is not strictly equivalent to "id++": InterlockedIncrement
is equivalent to "++id", but it actually means that no pipe is created with the
id 0.

You are receiving this mail because:
You are the assignee for the bug.

To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org

View raw message