[php-maint] Bug#245934: marked as done (php4: array_walk() crashes)

Debian Bug Tracking System owner at bugs.debian.org
Wed Aug 10 10:33:21 UTC 2005


Your message dated Wed, 10 Aug 2005 12:17:51 +0200
with message-id <1123669071.7396.58.camel at maple.active24.cz>
and subject line recursive array_walk ends with correct message
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--------------------------------------
Received: (at submit) by bugs.debian.org; 26 Apr 2004 09:28:19 +0000
>From paul at wurtel.net Mon Apr 26 02:28:19 2004
Return-path: <paul at wurtel.net>
Received: from cust.88.114.adsl.cistron.nl (gw.wurtel.net) [195.64.88.114] (mail)
	by spohr.debian.org with esmtp (Exim 3.35 1 (Debian))
	id 1BI2PS-0003Tq-00; Mon, 26 Apr 2004 02:28:18 -0700
Received: from wurtel ([192.168.1.1] helo=wurtel.net)
	by gw.wurtel.net with esmtp (Exim 3.36 #1 (Debian))
	id 1BI2PG-0004Z6-00; Mon, 26 Apr 2004 11:28:06 +0200
Received: from paul by wurtel.net with local (Exim 4.30 #1 (Debian))
	id 1BI2PG-00081G-7A; Mon, 26 Apr 2004 11:28:06 +0200
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
From: Paul Slootman <paul at debian.org>
To: Debian Bug Tracking System <submit at bugs.debian.org>
Subject: php4: array_walk() crashes
X-Mailer: reportbug 2.37
Date: Mon, 26 Apr 2004 11:28:06 +0200
Message-Id: <E1BI2PG-00081G-7A at wurtel.net>
X-Scanner: exiscan *1BI2PG-0004Z6-00*tVaRZePCsSk*Wurtel
Delivered-To: submit at bugs.debian.org
X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2004_03_25 
	(1.212-2003-09-23-exp) on spohr.debian.org
X-Spam-Status: No, hits=-5.0 required=4.0 tests=BAYES_01,BODY_8BITS,
	HAS_PACKAGE autolearn=no version=2.60-bugs.debian.org_2004_03_25
X-Spam-Level: 
X-CrossAssassin-Score: 1

Package: php4
Version: 4:4.3.3-4
Severity: important

When trying to dump an array structure to a format suitable for
generating XML (there aren't any PHP modules for generating XML that I
could find, only for parsing XML), I found that php was crashing after I
had extended the array a bit.

I use array_walk() recursively, to a max depth of about 6.
Any self-respecting programming language should be able to handle that
:-)  Below is a script that contains the core of what I was doing, and
that shows the crash. Note that that script is more suited to running
with the php4-cgi php4 executable (which also shows the problem).

I found some vague references that php4 doesn't support recursion,
however I can't find any evidence of this in the manual. If it indeed
doesn't support recursion, perhaps that should be told explicitly in the
array_walk() manual entry. The online annotated manual page actually has
plentiful user examples of recursion...

Paul Slootman

-- System Information:
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux wurtel 2.6.5-rc2 #1 Sat Mar 20 14:10:58 CET 2004 i686
Locale: LANG=C, LC_CTYPE=C

Versions of packages php4 depends on:
ii  apache-common               1.3.29.0.1-3 Support files for all Apache webse
ii  debconf                     1.4.22       Debian configuration management sy
ii  libbz2-1.0                  1.0.2-1      A high-quality block-sorting file 
ii  libc6                       2.3.2.ds1-11 GNU C Library: Shared libraries an
ii  libdb4.1                    4.1.25-10    Berkeley v4.1 Database Libraries [
ii  libexpat1                   1.95.6-6     XML parsing C library - runtime li
ii  libmm13                     1.3.0-1      Shared memory library - runtime
ii  libpam0g                    0.76-14.1    Pluggable Authentication Modules l
ii  libpcre3                    4.5-1.1      Perl 5 Compatible Regular Expressi
ii  mime-support                3.23-1       MIME files 'mime.types' & 'mailcap
ii  zlib1g                      1:1.2.1-4    compression library - runtime


<?php

    $order = array(
        "DocID"			=>	"1",
        "DocDate"		=>	date("d.m.y"),
        "ReSubmissionDate"	=>	"",
        "DocTyp"		=>	"Stapelauftrag",
        "CustID"		=>	"00000",
        "CustomerAddress" => array(
            array(
                "Name1"		=>	'name1',
                "Name2"		=>	'name2',
                "Name3"		=>	"",
                "City"		=>	'city',
                "Street"	=>	'street',
                "Postal"	=>	'postcode',
                "IATA"		=>	"90",
                "Country"	=>	"Deutschland",
                "ShortName"	=>	'short',
                "ContactKey"	=>	"",
                "EMail"		=>	'email at example.com',
            )
        ),
        "Text1"			=>	"",
        "Text2"			=>	"",
        "Wildcard1"		=>	"",
        "Wildcard2"		=>	"",
        "Dispatch"		=>	"Paketdienst",
        "Weight"		=>	"0,0",
        "BillingCustID"		=>	"4300200000",
        "ExtDocNr"		=>	"00000000003",
        "AnalysisLock"		=>	"",
        "PrintFlag"		=>	"",
        "FormType"		=>	"0",
        "Curr"			=>	"EUR",
        "ExChangeRate"		=>	"1,0000",
        "WIRRate"		=>	"0",
        "OneTimeCustomer" => array(
            array(
                "BankCode"	=>	"",
                "BankAccount"	=>	""
            )
        ),
        "Language"		=>	"0",
        "PriceGroup"		=>	"1",
        "PrFlag"		=>	"0",
        "SalesTaxKey"		=>	"1",
        "ProceedKey"		=>	"0",
        "CustDiscountGroup"	=>	"0",
        "Discount" => array(
            array(
                "FinDisc1"	=>	"0,00",
                "Disc1Base"	=>	"145,72",
                "Disc1Value"	=>	"0,00",
                "FinDisc2"	=>	"0,00",
                "Disc2Base"	=>	"145,72",
                "Disc2Value"	=>	"0,00",
                "FinDisc3"	=>	"0,00",
                "Disc3Base"	=>	"145,72",
                "Disc3Value"	=>	"0,00",
                "ValueSummary"	=>	"0,00"
            )
        ),
        "Contact" => array(
            array(
                "Repr"		=>	"999",
                "Region"	=>	"99",
                "Commission"	=>	"0,00",
                "Agent"		=>	"000000"
            )
        ),
        "Booking" => array(
            array(
                "CostUnit"	=>	"0000000000",
                "CostCentre"	=>	"0000000000",
                "AccountingArea"=>	"01"
            )
        ),
        "InvoiceCycleKey"	=>	"0",
        "AnalysisKey"		=>	"",
        "OrderNumber"		=>	"",
        "OrderDate"		=>	"",
        "OrderCode"		=>	"",
        "DocItems" => array(
            "DocItem" => array(
                "PosType"		=>	"1",
                "ItemRef"		=>	"ÚÚÚÚÚÚÚÚÚÚÚÚÚÚÚÚ1002",
                "CRef"			=>	"",
                "Desc1"			=>	"Präsentation Niederlande per",
                "Desc2"			=>	"",
                "ArticleGroup"		=>	"102",
                "PosTypeVersion"	=>	"E",
                "Delivery" => array(
                    array(
                        "DelWeek"	=>	"",
                        "DelDay"	=>	"",
                        "DelTime"	=>	""
                    )
                ),
        "PricePu"		=>	"145,72",
        "PriceUnit"		=>	"0",
        "PriceCalculation"	=>	"0",
        "ItemVal"		=>	"145,72",
        "InputKey"		=>	"0",
        "AveragePurchasePrice"	=>	"0",
                "Tax" => array(
                    array(
                        "TaxCode"	=>	"00",
                        "TaxBra"	=>	"000",
                        "TaxBraAccess"	=>	"0",
                        "TaxSumIndex"	=>	"0"
                    )
                ),
                "DiscountArticle" => array(
                    array(
                        "DiscPC"	=>	"0,00",
                        "DiscKey"	=>	"1"
                    )
                ),
                "ProceedKeyArticle"	=>	"01",
                "ActionKey"		=>	"00",
                "ContactCommissionArticle"=>	"0,00",
                "QuantDependantPriceKey"=>	"",
                "Quant"			=>	"1",
                "QuantUnit"		=>	"",
                "Meas" => array(
                    array(
                        "Count"		=>	"1",
                        "Length"	=>	"0,000",
                        "Width"		=>	"0,000",
                        "Height"	=>	"0,000"
                    )
                ),
                "DecimalPlace"		=>	"0",
                "MultiplierQuant"	=>	"1,000000",
                "DifferingQuantUnit"	=>	"",
                "DecimalPlaceConversion"=>	"0",
                "WeightArticle" => array(
                    array(
                        "Amount"	=>	"0",
                        "Unit"		=>	"0"
                    )
                ),
                "Wreath"		=>	"0,000",
                "Stock"			=>	"1",
                "CostUnitArticle"	=>	"",
                "SerialNbKey"		=>	"0",
                "TextComplementKey"	=>	"0",
                "PartsListPrintKey"	=>	"",
                "Prod"			=>	"0000000000"
            )
        ),
        "Payment" => array(
            "PaymentKey"		=>	"0",
            "ReminderKey"		=>	"00",
            "PayTerms" => array(
                array(
                    "PayTerm"		=>	"1",
                    "PayDays"		=>	"000",
                    "CashDiscDays1"	=>	"000",
                    "CashDiscDays2"	=>	"000",
                    "CashDiscPer1"	=>	"0,00",
                    "CashDiscPer2"	=>	"0,00"
                ),
                array(
                    "PayTerm"		=>	"2",
                    "PayDays"		=>	"000",
                    "CashDiscDays1"	=>	"000",
                    "CashDiscDays2"	=>	"000",
                    "CashDiscPer1"	=>	"0,00",
                    "CashDiscPer2"	=>	"0,00"
                )
            )
        ),
        "NetAmountByTurnOverTax" => array(
            array(
                "TurnOverTaxFree"	=>	"145,72",
                "TurnOverTax1"		=>	"0,00",
                "TurnOverTax2"		=>	"0,00",
                "TurnOverTax3"		=>	"0,00",
                "TurnOverTax4"		=>	"0,00",
                "TurnOverTax5"		=>	"0,00",
                "TurnOverTax6"		=>	"0,00",
                "TurnOverTax7"		=>	"0,00",
                "TurnOverTax8"		=>	"0,00"
            ),
        ),
        "GrossAmount"			=>	"145,72",
        "ProceedAmount"			=>	"145,72",
        "NetAmountByPayTerm2" => array(
            array(
                "Sum0"			=>	"0,00",
                "Sum1"			=>	"0,00",
                "Sum2"			=>	"0,00",
                "Sum3"			=>	"0,00",
                "Sum4"			=>	"0,00",
                "Sum5"			=>	"0,00",
                "Sum6"			=>	"0,00",
                "Sum7"			=>	"0,00",
                "Sum8"			=>	"0,00"
            ),
        ),
        "TaxCodes" => array(
            array(
                "TaxCode1"		=>	"0",
                "TaxCode2"		=>	"0",
                "TaxCode3"		=>	"0",
                "TaxCode4"		=>	"0",
                "TaxCode5"		=>	"0",
                "TaxCode6"		=>	"0",
                "TaxCode7"		=>	"0",
                "TaxCode8"		=>	"0"
            )
        )
    );
    $docs = array(
        array(
            "Version"			=>	"1.0",
            "ProducerName"			=>	"xxxxxxxx",
            "ProductName"			=>	"Classic Line",
            "xmlns"				=>	"x-schema:CL310_DezABFSchema.XML"
        ),
        "Company" => array(
            array(
                "MandateNumber"		=>	"111",
                "MandateName"  		=>	"xxx xxxxxxx-xxxxx xxxxxxx",
                "MandateCurr"  		=>	"EUR"
            ),
        ),
        "Doc" => $order
    );

    dump2xml($docs);


function dump2xml($array) {
    // output of this goes through 2xml
    array_walk(&$array, "gen_xml", "/Docs/");
}
function gen_xml($val, $key, $prefix)
{
    global $xml_fd;
    print "gen_xml(prefix=$prefix)\n";
    if (is_array($val)) {
	if (preg_match('/^\d+$/', $key)) {
	    if ($key == 1) {
		print substr($prefix, 0, $x-1) . "\n";
	    }
	    array_walk(&$val, "gen_xml", "$prefix@");
	}
	else {
	    array_walk(&$val, "gen_xml", "$prefix$key/");
	}
    }
    else {
	    if (strlen($val) > 0)
		print "$prefix$key=$val\n";
	    else
		print "$prefix$key\n";
    }
    print "gen_xml(prefix=$prefix) end\n";
}
?>


---------------------------------------
Received: (at 245934-done) by bugs.debian.org; 10 Aug 2005 10:17:43 +0000
>From ondrej at sury.org Wed Aug 10 03:17:43 2005
Return-path: <ondrej at sury.org>
Received: from mail.active24.cz [81.95.104.4] 
	by spohr.debian.org with esmtp (Exim 3.36 1 (Debian))
	id 1E2neZ-0007jp-00; Wed, 10 Aug 2005 03:17:43 -0700
Received: from maple.active24.cz (maple.office.active24.cz [81.95.104.250])
	by mail.active24.cz (Postfix) with ESMTP id B267A28000AF
	for <245934-done at bugs.debian.org>; Wed, 10 Aug 2005 12:20:33 +0200 (CEST)
Subject: recursive array_walk ends with correct message
From: Ondrej Sury <ondrej at sury.org>
To: 245934-done at bugs.debian.org
Content-Type: text/plain
Date: Wed, 10 Aug 2005 12:17:51 +0200
Message-Id: <1123669071.7396.58.camel at maple.active24.cz>
Mime-Version: 1.0
X-Mailer: Evolution 2.3.6.1 
Content-Transfer-Encoding: 7bit
Delivered-To: 245934-done at bugs.debian.org
X-Spam-Checker-Version: SpamAssassin 2.60-bugs.debian.org_2005_01_02 
	(1.212-2003-09-23-exp) on spohr.debian.org
X-Spam-Level: 
X-Spam-Status: No, hits=-3.0 required=4.0 tests=BAYES_00 autolearn=no 
	version=2.60-bugs.debian.org_2005_01_02

php4 4.4.0-1 gives following error message when I try to run your
script:

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to
allocate 138060825 bytes) in /tmp/bug.php on line 252

Which is IMHO correct behaviour.  Feel free to reopen this bug if you
have some arguments.

This bug still applies to php5 which gives Segmentation fault.

Ondrej.
-- 
Ondrej Sury <ondrej at sury.org>




More information about the pkg-php-maint mailing list