httpd-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 23051] New: - bug in apr_file_dup2() under Win32
Date Wed, 10 Sep 2003 08:42:24 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23051>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23051

bug in apr_file_dup2()  under Win32

           Summary: bug in apr_file_dup2()  under Win32
           Product: APR
           Version: HEAD
          Platform: Other
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Major
          Priority: Other
         Component: APR
        AssignedTo: bugs@httpd.apache.org
        ReportedBy: emild@cs.technion.ac.il


There is a problem with the apr_file_dup2() function in Windows. I think that 
apr_file_dup() has a similar problem. If old_file has an attached mutex, it 
won't be created in the new file. Therefore attempting to access the file mutex
(e.g from within apr_file_write()) will cause the application to crash. The 
easiest way to reproduce the problem is to install a copy of apache 2.0.47 and 
then run it like this:

apache -e debug -E temp.log

This should cause stderr to be redirected to temp.log, but instead of doing 
this apache crashes with an access violation.



The following patch fixes this problem with apr_file_dup2():

---BEGIN-PATCH---

--- httpdw-old/srclib/apr/file_io/win32/filedup.c	2003-09-09 
20:07:10.000000000 +0300
+++ httpdw/srclib/apr/file_io/win32/filedup.c	2003-09-09 20:36:44.000000000 
+0300
@@ -103,6 +103,7 @@
     HANDLE hproc = GetCurrentProcess();
     HANDLE newhand = NULL;
     apr_int32_t newflags;
+    apr_thread_mutex_t *new_mutex = NULL;
 
     /* dup2 is not supported literaly with native Windows handles.
      * We can, however, emulate dup2 for the standard i/o handles,
@@ -141,10 +142,26 @@
         newflags = old_file->flags & ~APR_INHERIT;
     }
 
+    if (old_file->mutex != NULL) {
+        apr_status_t rc = apr_thread_mutex_create(&new_mutex,
+                                                  APR_THREAD_MUTEX_DEFAULT,
+                                                  new_file->pool);
+        if (rc != APR_SUCCESS) {
+            CloseHandle(newhand);
+            return rc;
+        }
+    }
+
+
     if (new_file->filehand && (new_file->filehand != INVALID_HANDLE_VALUE))
{
         CloseHandle(new_file->filehand);
     }
 
+    if (new_file->mutex != NULL) {
+        apr_thread_mutex_destroy(new_file->mutex);
+    }
+
+    new_file->mutex = new_mutex;
     new_file->flags = newflags;
     new_file->filehand = newhand;
     new_file->fname = apr_pstrdup(new_file->pool, old_file->fname);


---END-PATCH---

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


Mime
View raw message