#23396 [Opn]: Fix for debug mode assertion failure in the Win2000 native libraries of fdopen

From: Date: Tue, 29 Apr 2003 04:28:41 +0000
Subject: #23396 [Opn]: Fix for debug mode assertion failure in the Win2000 native libraries of fdopen
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-38674@lists.php.net to get a copy of this message
 ID:               23396
 User updated by:  ed000001 at hotmail dot com
 Reported By:      ed000001 at hotmail dot com
 Status:           Open
 Bug Type:         Reproducible crash
 Operating System: Win2000 - Debug Mode
 PHP Version:      4.3.1
 New Comment:

comment


Previous Comments:
------------------------------------------------------------------------

[2003-04-28 23:24:57] ed000001 at hotmail dot com

Problem:

Initialization phase (before script) debug mode assertion failure in
the Win32 native libraries where "fdopen.c" is implemented when
compiling "php4ts_cli" in "Win32 Debug_TS".

Development Environment "Fix":

Do not call dup() for the Win32 platform -- I have not check the
implications as this is not my prod environment.

File php_fopen_wrapper.c:
=========================

#ifdef PHP_WIN32
 #define FIX_DUP(a)    (a)
#else
 #define FIX_DUP(a)    (dup((a))
#endif

php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, char
*path, char *mode, int options, char **opened_path, php_stream_context
*context STREAMS_DC TSRMLS_DC)
{
    FILE * fp = NULL;
    php_stream * stream = NULL;

    if (!strncasecmp(path, "php://", 6))
        path += 6;
    
    if (!strcasecmp(path, "output")) {
        return php_stream_alloc(&php_stream_output_ops, NULL, 0,
"wb");
    }
    
    if (!strcasecmp(path, "input")) {
        return php_stream_alloc(&php_stream_input_ops, NULL, 0, "rb");
    }  
    
    if (!strcasecmp(path, "stdin")) {
        fp = fdopen(FIX_DUP(STDIN_FILENO), mode);
    } else if (!strcasecmp(path, "stdout")) {
        fp = fdopen(FIX_DUP(STDOUT_FILENO), mode);
    } else if (!strcasecmp(path, "stderr")) {
        fp = fdopen(FIX_DUP(STDERR_FILENO), mode);
    }

    if (fp)    {
        stream = php_stream_fopen_from_file(fp, mode);
        if (stream == NULL)
            fclose(fp);
    }
    return stream;
}

Thanks for the great tool!

Ed

------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=23396&edit=1



Thread (6 messages)

« previous php.bugs (#38674) next »