Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 17863 - mod_php produce a strange sprintf behaviour
Summary: mod_php produce a strange sprintf behaviour
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Library (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: PHP Bugs
URL: http://bugs.php.net/bug.php?id=21658
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-03-20 05:18 UTC by Sergio Blanco Cuaresma
Modified: 2003-09-26 17:07 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sergio Blanco Cuaresma 2003-03-20 05:18:19 UTC
Trying to make work FPDF, a php class for the generation of PDFs, I found
several problems. Finally with help of Olivier Plathey (the author of FPDF) we
found this bug related to Gentoo: http://bugs.php.net/bug.php?id=21658

As it is said in that web, this php code:

for($t=0;$t<10;$t++) {
	$r=(float) rand(0,10000)/3;
	echo $r." -> ".sprintf('%.3f',$r)."\n";
}

will produce ...

1975.33333333 -> 
Comment 1 Sergio Blanco Cuaresma 2003-03-20 05:18:19 UTC
Trying to make work FPDF, a php class for the generation of PDFs, I found
several problems. Finally with help of Olivier Plathey (the author of FPDF) we
found this bug related to Gentoo: http://bugs.php.net/bug.php?id=21658

As it is said in that web, this php code:

for($t=0;$t<10;$t++) {
	$r=(float) rand(0,10000)/3;
	echo $r." -> ".sprintf('%.3f',$r)."\n";
}

will produce ...

1975.33333333 -> ç.000
508.333333333 -> ,.000
2483.66666667 -> ã.000
61.6666666667 -> m.000
2514.66666667 -> I00.000
2499.66666667 -> *0.000
1957.33333333 -> ü0000.000
3167.33333333 -> 0.é00
655.666666667 -> 600.000
3321.66666667 -> ).000
2256.33333333 -> 0.S00
383.666666667 -> 0.,00
1565.33333333 -> M.000

I suppose there's something wrong with glibc 2.3.1-r2.

The solution of that bug in the page I have mentioned was:

"The strange behaviour was related to a strange combination of gcc and
glibc. Nothing was usefull (gcc and glibc recompilation). I had to
compile gcc and glibc on another machine, copy binaries of gentoo emerge
binary option system and all now is working fine.
It was a library problem."

Information about my system:

Portage 2.0.47-r10 (default-x86-1.4, gcc-3.2.2, glibc-2.3.1-r2)
=================================================================
System uname: 2.4.20 i686 Intel(R) Pentium(R) 4 CPU 2.00GHz
GENTOO_MIRRORS="ftp://ftp.etse.urv.es/pub/linux/gentoo http://gentoo.oregonstate
.edu/ http://www.ibiblio.org/pub/Linux/distributions/gentoo"
CONFIG_PROTECT="/etc /var/qmail/control /usr/share/config /usr/kde/2/share/confi
g /usr/kde/3/share/config"
CONFIG_PROTECT_MASK="/etc/gconf /etc/env.d"
PORTDIR="/usr/portage"
DISTDIR="/usr/portage/distfiles"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR_OVERLAY="/usr/local/portage"
USE="x86 oss apm crypt gif jpeg libg++ mmx mpeg ncurses nls oggvorbis pdflib png
 xml2 zlib gdbm berkdb slang readline gpm tcpd pam libwww ssl perl python -3dnow
 acpi -arts -avi -cups -encode flash -gnome -gtk -imlib -java -kde -mikmod -moti
f mysql -opengl -qt -qtmt -quicktime -sdl -spell -svga -truetype -X -xmms -xv im
ap"
COMPILER="gcc3"
CHOST="i686-pc-linux-gnu"
CFLAGS="-march=pentium4 -O3 -fforce-addr -fomit-frame-pointer -funroll-loops -fr
erun-cse-after-loop -frerun-loop-opt -falign-functions=4"
CXXFLAGS="-O2 -mcpu=i686 -pipe"
ACCEPT_KEYWORDS="x86"
MAKEOPTS="-j2"
AUTOCLEAN="yes"
SYNC="rsync://rsync1.es.gentoo.org/gentoo-portage"
FEATURES="sandbox ccache"

mod_php 4.3.1
Apache 1.3.27-r3
glibc 2.3.1-r2
gcc 3.2.2

Any ideas?
Comment 2 Roman Weber 2003-04-22 16:30:57 UTC
Look at Bug #18435, had the same problem.
I resoved it with changing the cflags to pentium3 and recompile glibc.
Comment 3 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2003-04-22 16:43:51 UTC
pentium4 FP math is BROKEN under glibc-2.3.1/2. It's an upstream bug. Recompile with -march=pentium3/-mcpu=pentium3 and avoid pentium4. 
Athlon4 has the same problem ATM.

Comment 4 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2003-09-26 17:07:37 UTC
closing as it was the old pentium4 glibc bug.