Le Mercredi  1 Novembre 2000 14:49, vous avez �rit :
>Hello,
>
>I have found something that is probably a Midgard bug.
>I get a seg fault while executing a code fragment which create entries
>in an associative array. The same fragment works fine when call from
> an ordinary PHP page instead of a Midgard page.
>
>I'm using Apache 1.3.12, and Midgard 1.4beta5e on a Linux Mandrake 7.1
>Pentium.
>I tried to patch Midgard to PHP 3.0.18 and still have the same
> problem.
>
>I compiled both Midgard and Apache with debug option (-g), and started
>Apache from the debugger. Unfortunately I do not get something
>interesting.
>
>GNU gdb 5.0
>Copyright 2000 Free Software Foundation, Inc.
>GDB is free software, covered by the GNU General Public License, and
> you are welcome to change it and/or distribute copies of it under
> certain conditions. Type "show copying" to see the conditions.
>There is absolutely no warranty for GDB.  Type "show warranty" for
> details. This GDB was configured as "i586-mandrake-linux"...
>(gdb) set args -X
>(gdb) run
>Starting program: /usr/local/BUILD/apache_1.3.12/src/httpd -X
>warning: Unable to find dynamic linker breakpoint function.
>GDB will be unable to debug shared library initializers
>and track explicitly loaded dynamic code.
>
>Program received signal SIGSEGV, Segmentation fault.
>0x403fc8e6 in ?? ()
>(gdb) bt
>#0  0x403fc8e6 in ?? ()
>#1  0x1400008 in ?? ()
>Cannot access memory at address 0x4
>
>What else should I try? Should I wait for next beta?
>Thanks in advance for your help.

Some of you may remember this (very) old bug report.
For the new year, I come back with some solution.

I finally track the bug, It's not a midgard bug but a PHP 3 bug.
There is a bug in PHP up to 3.0.18 (fixed in 4.0.1) number_format function 
which appear on some systems using non "C" locale.

Here is a patch that I successfully tried of last midgard release 1.4.

Happy new year
-- 
Ronan-Yann Lorin                t�l: +33 617 960 627
3, All�e des Hirondelles        t�l: +33 134 506 034
95220 Herblay                   mailto:[EMAIL PROTECTED]
France                          http://www.les-lorin.com
--- midgard-php-1.4/functions/math.c    Sun Dec 24 17:52:59 2000
+++ midgard-php-1.4beta7/functions/math.c       Thu Dec 28 19:47:11 2000
@@ -608,49 +608,45 @@
        int tmplen,reslen=0;
        int count=0;
        int is_negative=0;
-       
+
        if (d<0) {
                is_negative=1;
                d = -d;
        }
        dec = MAX(0,dec);
-       tmpbuf = (char *) emalloc(32+dec);
-       
-       tmplen=_php3_sprintf(tmpbuf,"%.*f",dec,d);
-       
-       if (!isdigit(tmpbuf[0])) {
+       tmpbuf = (char *) emalloc(1+DBL_MAX_10_EXP+1+dec+1);
+
+       tmplen=sprintf(tmpbuf,"%.*f",dec,d);
+
+       if (!isdigit((int)tmpbuf[0])) {
                return tmpbuf;
        }
 
-       for (t=tmpbuf; *t; t++) {
-               if (*t=='.') {
-                       *t = dec_point;
-               }
-       }
        if (dec) {
-               reslen = dec+1 + (tmplen-dec-1) + (tmplen-1-dec-1)/3;
+               reslen = dec+1 + (tmplen-dec-1) + ((thousand_sep) ? (tmplen-1-dec-1)/3 
+: 0);
        } else {
-               reslen = tmplen+(tmplen-1)/3;
+               reslen = tmplen+((thousand_sep) ? (tmplen-1)/3 : 0);
        }
        if (is_negative) {
                reslen++;
        }
        resbuf = (char *) emalloc(reslen+1);
-       
+
        s = tmpbuf+tmplen-1;
        t = resbuf+reslen;
        *t-- = 0;
-       
+
        if (dec) {
-               while (*s!=dec_point) {
+               while (isdigit((int)*s)) {
                        *t-- = *s--;
                }
-               *t-- = *s--;  /* copy that dot */
+               *t-- = dec_point;  /* copy that dot */
+               s--;
        }
-       
+
        while(s>=tmpbuf) {
                *t-- = *s--;
-               if ((++count%3)==0 && s>=tmpbuf) {
+               if (thousand_sep && (++count%3)==0 && s>=tmpbuf) {
                        *t-- = thousand_sep;
                }
        }
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to