php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72680 Variable $i conflict in .gdbinit
Submitted: 2016-07-26 15:05 UTC Modified: -
From: th3s3v3n dot shell at gmail dot com Assigned:
Status: Closed Package: *General Issues
PHP Version: 5.6.24 OS: Ubuntu 14.04
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: th3s3v3n dot shell at gmail dot com
New email:
PHP Version: OS:

 

 [2016-07-26 15:05 UTC] th3s3v3n dot shell at gmail dot com
Description:
------------
In the gdb script .gdbinit , the life cycle of a variable is the whole calling procedure as soon as it is declared, instead of the block of function where it is declared in .
in the print_cvs , variable $i is used to count the offset of the CVs.
(If you want to use print_cvs , maybe you must use the EX_CV_NUM() macro to fix the bug 70008 [ https://bugs.php.net/bug.php?id=70008 ] )
Then it call `printzv`. But in the function printzv , when the zvalue's type is 4 (array) or 5 (object) , the function ____printzv_contents will execute code:
while $i > 0
    printf "  "
    set $i = $i - 1
end

$i will become 0.
So the loop in the print_cvs will be endless.

Test script:
---------------
aa.php

<?php
$a = 'vdf';
$b = array(1);
$c = array(2);
sleep(1);

# gdb php
(gdb) b sleep
(gdb) b sleep
(gdb) source .gdbinit
(gdb) r aa.php
(gdb) print_cvs

Expected result:
----------------
Compiled variables count: 3
0 = a
[0xf7bfd5d4] (refcount=1) string(3): "vdf"
1 = b
[0xf7bfd59c] (refcount=1) array(1): {
    0 => [0xf7bfd5b8] (refcount=1) long: 1
  }
2 = c
[0xf7bfe79c] (refcount=1) array(1): {
    0 => [0xf7bfe72c] (refcount=1) long: 2
  }


Actual result:
--------------
in the 5.6.24:

(gdb) print_cvs
Compiled variables count: 3
0 = a
[0xf7bfd5d4] (refcount=1) string(3): "vdf"
1 = b
[0xf7bfd59c] (refcount=1) array(1): {
    0 => [0xf7bfd5b8] (refcount=1) long: 1
  }0
1 = b
[0xf7bfd59c] (refcount=1) array(1): {
    0 => [0xf7bfd5b8] (refcount=1) long: 1
  }0
1 = b
[0xf7bfd59c] (refcount=1) array(1): {
    0 => [0xf7bfd5b8] (refcount=1) long: 1
  }0
1 = b
[0xf7bfd59c] (refcount=1) array(1): {
    0 => [0xf7bfd5b8] (refcount=1) long: 1
  }0
1 = b
[0xf7bfd59c] (refcount=1) array(1): {
    0 => [0xf7bfd5b8] (refcount=1) long: 1
  }0
1 = b
[0xf7bfd59c] (refcount=1) array(1): {
    0 => [0xf7bfd5b8] (refcount=1) long: 1
  }0
1 = b
[0xf7bfd59c] (refcount=1) array(1): {
    0 => [0xf7bfd5b8] (refcount=1) long: 1
  }0
1 = b
[0xf7bfd59c] (refcount=1) array(1): {
    0 => [0xf7bfd5b8] (refcount=1) long: 1
  }0
1 = b
[0xf7bfd59c] (refcount=1) array(1): {
    0 => [0xf7bfd5b8] (refcount=1) long: 1
  }0
1 = b
[0xf7bfd59c] (refcount=1) array(1): {
    0 => [0xf7bfd5b8] (refcount=1) long: 1
  }0
1 = b
[0xf7bfd59c] (refcount=1) array(1): {
    0 => [0xf7bfd5b8] (refcount=1) long: 1
  }0
1 = b
[0xf7bfd59c] (refcount=1) array(1): {
    0 => [0xf7bfd5b8] (refcount=1) long: 1
  }0
1 = b
[0xf7bfd59c] (refcount=1) array(1): {
---Type <return> to continue, or q <return> to quit---

in the old version (for example 5.4.34):

Compiled variables count: 3
0 = a
[0xf7bfd5d4] (refcount=1) string(3): "vdf"
1 = b
[0xf7bfd59c] (refcount=1) array(1): {
    0 => [0xf7bfd5b8] (refcount=1) long: 1
  }
1 = b
Structure has no component named operator!=.

Patches

EX_CV_NUM_and_Variable_i_conflict_patch (last revision 2016-07-26 15:08 UTC by th3s3v3n dot shell at gmail dot com)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-12 09:12 UTC] krakjoe@php.net
Automatic comment on behalf of mhagstrand@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=1ee1f79e27fb4006d0400b38163b2ec0786fd130
Log: Fixed bug #72680 gdbinit print_cvs not prepared for PHP 7
 [2017-01-12 09:12 UTC] krakjoe@php.net
-Status: Open +Status: Closed
 [2017-01-12 09:24 UTC] krakjoe@php.net
Automatic comment on behalf of mhagstrand@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=1ee1f79e27fb4006d0400b38163b2ec0786fd130
Log: Fixed bug #72680 gdbinit print_cvs not prepared for PHP 7
 [2017-01-12 20:17 UTC] nikic@php.net
Automatic comment on behalf of mhagstrand@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=1ee1f79e27fb4006d0400b38163b2ec0786fd130
Log: Fixed bug #72680 gdbinit print_cvs not prepared for PHP 7
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Jun 20 23:01:31 2025 UTC