#23396 [Fbk->Opn]: Fix for debug mode assertion failure in the Win2000 native libraries of fdopen
ID: 23396
User updated by: ed000001 at hotmail dot com
Reported By: ed000001 at hotmail dot com
-Status: Feedback
+Status: Open
Bug Type: Reproducible crash
Operating System: Win2000 - Debug Mode
PHP Version: 4.3.1
New Comment:
I run Win2000 5.00.2195 with Service Pack 3. The development
environment is Visual C++ 6.0. I downloaded and installed
php-4.3.1.tar.gz as instructed here
http://php.lamphost.net/manual/en/install.windows.php
I also created an empty C:\work\php-4.3.1\ext\mysql\libmysql\ dll.c as
the php-4.3.1 tree comes with a zero length file, which will no
uncompress under WinZip for Win32.
I followed the remaining instructions in
http://php.lamphost.net/manual/en/install.windows.php
and compiled the
php4ts_cli with the "Win32 Debug_TS" built. Then I created a test
script "a.php" which reads like
<?
echo "hello world";
?>
When I run it in debug mode with the parameter "f a.php" the
assertion triggers (unless I make the modifications described above).
Note that this is a VC++ Win32 library assertion and if you do not have
the debug versions of these libraries in your machine it may not
trigger. Below is the code in fdopen.c that kicks out the assertion.
FILE * __cdecl _tfdopen (
int filedes,
REG2 const _TSCHAR *mode
)
{
REG1 FILE *stream;
int whileflag, tbflag, cnflag;
_ASSERTE(mode != NULL);
#if defined (_WIN32)
_ASSERTE((unsigned)filedes < (unsigned)_nhandle);
_ASSERTE(_osfile(filedes) & FOPEN); <<= assertion triggered
The value for filedes is "4".
If I remember right there will be no error reported if you compile the
Release version of the project, which is something I do not do. I use
the Win32 environment only to develop/debug a php extension.
Thanks
Previous Comments:
------------------------------------------------------------------------
[2003-04-29 04:42:55] wez@php.net
Can you give a little more detail on what error is caused and how it is
triggered?
It works fine here in my dev env under winxp.
Have you tried the source of the latest stable snapshot, or the latest
RC?
http://qa.php.net/
http://snaps.php.net/
------------------------------------------------------------------------
[2003-04-28 23:29:46] ed000001 at hotmail dot com
There is an extra "(" in the "(dup((a))" which should be (dup(a))
------------------------------------------------------------------------
[2003-04-28 23:28:40] ed000001 at hotmail dot com
comment
------------------------------------------------------------------------
[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)