Bug #69371 [NEW]: Hash table collision leads to inaccessible array keys
| From: | berdir@php.net | Date: | Fri, 03 Apr 2015 21:22:07 +0000 |
| Subject: | Bug #69371 [NEW]: Hash table collision leads to inaccessible array keys | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-191809@lists.php.net to get a copy of this message | ||
From: berdir
Operating system: Linux
PHP version: master-Git-2015-04-03 (Git)
Package: Arrays related
Bug Type: Bug
Bug description:Hash table collision leads to inaccessible array keys
Description:
------------
We're working on making Drupal 8 compatible with PHP7.
A few of our tests are failing with very strange array related errors.
A lot of test that have a common base class and call the same method are
failing with the same problem. See
https://www.drupal.org/node/2454439#comment-9788325.
Basically, there are two arrays, both are keyed with the same keys. We
loop over one of them and access the element in the second array. That
results in a undefined index notice. But when comparing with
array_keys() or var_dump(), then the array key exists.
Changing the code to instead do a foreach and look for the matching key
works fine:
- $migration = $migrations[$migration_id];
+ foreach ($migrations as $id => $migration) {
+ // WTF PHP7, you drunk?
+ if ($id === $migration_id) {
+ break;
+ }
+ }
@ircmaxell has been debugging this and tracked it down to a hash
collision between the array entries d6_user and d6_node_type, which then
results in d6_node_type not being accessible. For other tests, it's
other keys.
This only happens in this specific scenario, we haven't been able to
reproduce it in a standalone script.
To run the test, get the latest Drupal 8 (branch 8.0.x), and run the
test like this:
php7 core/scripts/run-tests.sh --sqlite /tmp/test.sqlite --dburl
sqlite://tmp/db.sqlite --class
"Drupal\migrate_drupal\Tests\d6\MigrateCckFieldRevisionTest"
Notes: that needs the curl and gd extensions, and it starts a second
script to actually run the test. To debug with gdb for example, you need
something like this:
gdb --args '/usr/local/bin/php7' './core/scripts/run-tests.sh' --url
''
--sqlite '/tmp/test.sqlite' --dburl 'sqlite://tmp/db.sqlite' --php
'/usr/local/bin/php7' --test-id 1 --execute-test
'Drupal\migrate_drupal\Tests\d6\MigrateCckFieldRevisionTest'
(the first command needs to be run first, to set up the env, look for
proc_open and print the command to get he right now)
--
Edit bug report at https://bugs.php.net/bug.php?id=69371&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69371&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69371&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69371&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69371&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69371&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69371&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69371&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69371&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69371&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69371&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69371&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69371&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69371&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69371&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69371&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69371&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69371&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69371&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69371&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69371&r=mysqlcfg