#26363 [Opn]: preg_replace() crashes PHP

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default #26363 [Opn]: preg_replace() crashes PHP

    ID: 26363
    Updated by: [email]sniper@php.net[/email]
    -Summary: preg_replace crashes PHP
    Reported By: prof_moriarty at veryfast dot biz
    Status: Open
    Bug Type: Regexps related
    Operating System: win 98SE
    PHP Version: 4.3.4
    New Comment:

    Does not crash with linux.



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

    [2003-11-23 13:29:03] scottm at spamcop dot net

    Your regex wont work.

    Your trying to match || followed by a space at the end of the string.

    Where you have space then the double pipes in $string.

    Using
    ------
    $string = "ship_id = '17' ||";

    $string = preg_replace("/ \|\|$/", "", $string);

    echo $string;

    I get no
    ship_id = '17'
    as exepcted

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

    [2003-11-23 09:25:57] prof_moriarty at veryfast dot biz

    Description:
    ------------
    There seem to be some major issues with preg_replace in this version.

    See code actual and reproducable for explanations

    Reproduce code:
    ---------------
    $string = "ship_id = '17' ||";

    $string = preg_replace("/\|\| $/", "", $string);

    echo $string;

    Expected result:
    ----------------
    SHOULD result in

    ship_id = '17'


    being printed to the screen.

    Actual result:
    --------------
    PHP crashes.
    Indeed it would seem absolutely anything i enter as either the regexp,
    or the string will crash it. Even if both are blank.


    Below is the 'details' of the error (as gained from windows thing):

    "
    PHP caused an invalid page fault in
    module <unknown> at 0000:854fd78b.
    Registers:
    EAX=0000004c CS=016f EIP=854fd78b EFLGS=00010246
    EBX=0063f474 SS=0177 ESP=0063f330 EBP=10135328
    ECX=00000000 DS=0177 ESI=0000004c FS=96a7
    EDX=0000008a ES=0177 EDI=007d68cc GS=0000
    Bytes at CS:EIP:
    00 2e 00 05 00 2e 00 05 00 2e 00 05 00 2e 00 05
    Stack dump:
    011750f4 ffffffff 10135328 10135328 01010101 01010101 01010101 00100101
    0000004c 00100010 01820010 00000000 00000000 0102014c 01020102 01020102

    "


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


    --
    Edit this bug report at [url]http://bugs.php.net/?id=26363&edit=1[/url]
    sniper@php.net Guest

  2. Similar Questions and Discussions

    1. #26363 [Opn->Bgs]: preg_replace() crashes PHP
      ID: 26363 User updated by: prof_moriarty at veryfast dot biz Reported By: prof_moriarty at veryfast dot biz -Status: ...
    2. #26363 [Com]: preg_replace crashes PHP
      ID: 26363 Comment by: scottm at spamcop dot net Reported By: prof_moriarty at veryfast dot biz Status: Open...
    3. #26363 [NEW]: preg_replace crashes PHP
      From: prof_moriarty at veryfast dot biz Operating system: win 98SE PHP version: 4.3.4 PHP Bug Type: Regexps related Bug...
    4. preg_replace help
      I'm having some trouble getting this replacement to work efficiently. I have the following code: $thing = preg_replace("(\r\n|\n|\r|\t)", "",...
    5. preg_replace help please
      this is supposed to any occurrence of *something* into <strong>something</strong> $str = preg_replace("!\*(.*?)\*!","...
  3. #2

    Default #26363 [Opn]: preg_replace() crashes PHP

    ID: 26363
    User updated by: prof_moriarty at veryfast dot biz
    Reported By: prof_moriarty at veryfast dot biz
    Status: Open
    Bug Type: Regexps related
    Operating System: win 98SE
    PHP Version: 4.3.4
    New Comment:

    But the regexp DOES work with 3.4.2!!! And earier version too.

    What the regexp ("/\|\| $/") does is:

    \|\| = looking for ||

    " " = looking for space

    $ = the above must be at the end of the string


    No piping or anything else required there.

    And the string it's replacing is something more like:
    $del_str .= "ship_id = '17' || "; (with an extra space at the end (typo
    my missing it out on the original post)). That'd be why you thought it
    wouldn't work. Sorry. ;)


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

    [2003-11-23 21:15:49] [email]sniper@php.net[/email]

    Does not crash with linux.


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

    [2003-11-23 13:29:03] scottm at spamcop dot net

    Your regex wont work.

    Your trying to match || followed by a space at the end of the string.

    Where you have space then the double pipes in $string.

    Using
    ------
    $string = "ship_id = '17' ||";

    $string = preg_replace("/ \|\|$/", "", $string);

    echo $string;

    I get no
    ship_id = '17'
    as exepcted

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

    [2003-11-23 09:25:57] prof_moriarty at veryfast dot biz

    Description:
    ------------
    There seem to be some major issues with preg_replace in this version.

    See code actual and reproducable for explanations

    Reproduce code:
    ---------------
    $string = "ship_id = '17' ||";

    $string = preg_replace("/\|\| $/", "", $string);

    echo $string;

    Expected result:
    ----------------
    SHOULD result in

    ship_id = '17'


    being printed to the screen.

    Actual result:
    --------------
    PHP crashes.
    Indeed it would seem absolutely anything i enter as either the regexp,
    or the string will crash it. Even if both are blank.


    Below is the 'details' of the error (as gained from windows thing):

    "
    PHP caused an invalid page fault in
    module <unknown> at 0000:854fd78b.
    Registers:
    EAX=0000004c CS=016f EIP=854fd78b EFLGS=00010246
    EBX=0063f474 SS=0177 ESP=0063f330 EBP=10135328
    ECX=00000000 DS=0177 ESI=0000004c FS=96a7
    EDX=0000008a ES=0177 EDI=007d68cc GS=0000
    Bytes at CS:EIP:
    00 2e 00 05 00 2e 00 05 00 2e 00 05 00 2e 00 05
    Stack dump:
    011750f4 ffffffff 10135328 10135328 01010101 01010101 01010101 00100101
    0000004c 00100010 01820010 00000000 00000000 0102014c 01020102 01020102

    "


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


    --
    Edit this bug report at [url]http://bugs.php.net/?id=26363&edit=1[/url]
    prof_moriarty at veryfast dot biz Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139