ID:               49244
 Updated by:       sjo...@php.net
 Reported By:      ronlentjes at yahoo dot com dot au
-Status:           Open
+Status:           Verified
 Bug Type:         Scripting Engine problem
 Operating System: Linux Fedora 8
 PHP Version:      5.3.0


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

[2009-08-20 19:19:13] sjoerd-php at linuxonly dot nl

The problem is with calling php_sprintf_appendstring. Its 9th parameter
is not precision, it is length.

Index: ext/standard/formatted_print.c
===================================================================
--- ext/standard/formatted_print.c      (revision 287513)
+++ ext/standard/formatted_print.c      (working copy)
@@ -232,14 +232,14 @@
        if (zend_isnan(number)) {
                is_negative = (number<0);
                php_sprintf_appendstring(buffer, pos, size, "NaN", 3, 0, 
padding,
-                                                                alignment, 
precision, is_negative, 0, always_sign);
+                                                                alignment, 3, 
is_negative, 0, always_sign);
                return;
        }
 
        if (zend_isinf(number)) {
                is_negative = (number<0);
                php_sprintf_appendstring(buffer, pos, size, "INF", 3, 0, 
padding,
-                                                                alignment, 
precision, is_negative, 0, always_sign);
+                                                                alignment, 3, 
is_negative, 0, always_sign);
                return;
        }

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

[2009-08-20 11:15:47] sjoerd-php at linuxonly dot nl

Could reproduce with PHP 5.2.10.

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

[2009-08-14 04:25:22] ronlentjes at yahoo dot com dot au

Perhaps you test it differently than I do. I'll give you the easiest
way to see it happen:

put this in a file called test.php:
---
<?
$d = pow(-1.0, 0.3);
printf ("%f\n", $d);
?>
---

Output will be (bash, Fedora 8, Linux):

# php test.php
---
NaN*A
---

Output for browser will be NaN??? or NaN???F or other variations of
that.

This is reporducable on versions 4.2.2 (crash), 5.2.4, 5.3.0 (as
indicated previously).

I just retried this now.

Cheers,
Ron Lentjes
LC CLS.

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

[2009-08-13 14:29:39] ras...@php.net

I am unable to reproduce this in neither 5.2 nor 5.3, and Valgrind is
clean on Debian.

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

[2009-08-13 14:14:51] ronlentjes at yahoo dot com dot au

Description:
------------
This has been an issue since 4.2.2 and still in 5.3.0.

$d = pow (-1.0, 0.3);  // or anything causing NaN
echo "$d\n";
 -> NAN
printf ("%f\n", $d);
(4.2.2) -> crash
(5.2.4) -> NaN<big-box><little-box><E-with-backslash-on-top>
(5.3.0) -> NaN<hex EF BF BD><hex EF BF BD><hex EF BF BD>
             (viewed in browser as NaN???)

Two issues here:
Inconsistent display of NAN for echo and NaN for printf.
Output of bogus characters after the 3 letters NaN for printf.

I think you are missing a '\0' null termination after the NaN
characters which probably cause a runaway to crash 4.2.2 but is just
'hanging' in there for the newer versions.

Cheers,
Ron Lentjes
LC CLS.


Reproduce code:
---------------
$d = pow (-1.0, 0.3);
echo "$d\n";
printf ("%f\n", $d);


Expected result:
----------------
NaN
NaN

Actual result:
--------------
(4.2.2)
NAN
crash

(5.2.4)
NAN
NaN<big-box><little-box><E-with-backslash-on-top>

(5.3.0)
NAN
NaN<hex EF BF BD><hex EF BF BD><hex EF BF BD>
      (viewed in browser as NaN???)



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


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

Reply via email to