Bug #76510 [Opn]: file_exists() stopped working for phar:// in PHP 7.3

From: Date: Mon, 06 Aug 2018 15:16:17 +0000
Subject: Bug #76510 [Opn]: file_exists() stopped working for phar:// in PHP 7.3
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-216639@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76510&edit=1

 ID:                 76510
 Updated by:         sebastian@php.net
 Reported by:        sebastian@php.net
 Summary:            file_exists() stopped working for phar:// in PHP 7.3
 Status:             Open
 Type:               Bug
 Package:            PHAR related
 Operating System:   Linux
 PHP Version:        7.3Git-2018-06-21 (Git)
 Block user comment: N
 Private report:     N

 New Comment:

As requested by Nikita on the mailinglist, here is the Valgrind logfile:

==21544== Memcheck, a memory error detector
==21544== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==21544== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==21544== Command: /usr/local/php-7.3/bin/php ../../../phpunit
==21544== Parent PID: 19592
==21544== 
==21544== Conditional jump or move depends on uninitialised value(s)
==21544==    at 0x4072122: ???
==21544==    by 0x1BEB2267: ???
==21544==    by 0x1BEB2267: ???
==21544==    by 0x1BEB228C: ???
==21544==    by 0xEB577AF: ???
==21544==    by 0x1BEB2267: ???
==21544== 
==21544== Conditional jump or move depends on uninitialised value(s)
==21544==    at 0x4072122: ???
==21544==    by 0x1BEB6637: ???
==21544==    by 0x1BEB6637: ???
==21544==    by 0x1BEB665C: ???
==21544==    by 0xEB577AF: ???
==21544==    by 0x1BEB6637: ???
==21544== 
==21544== Conditional jump or move depends on uninitialised value(s)
==21544==    at 0x4072122: ???
==21544==    by 0x1BF754E7: ???
==21544==    by 0x1BF754E7: ???
==21544==    by 0x1BF754F3: ???
==21544==    by 0xEB577AF: ???
==21544==    by 0x1BF754E7: ???
==21544== 
==21544== Conditional jump or move depends on uninitialised value(s)
==21544==    at 0x4072122: ???
==21544==    by 0x1BF77167: ???
==21544==    by 0x1BF77167: ???
==21544==    by 0x1BF77173: ???
==21544==    by 0xEB577AF: ???
==21544==    by 0x1BF77167: ???
==21544== 
==21544== Invalid read of size 1
==21544==    at 0x848DF7: destroy_zend_class (in /usr/local/php-7.3/bin/php)
==21544==    by 0x8459F3: shutdown_executor (in /usr/local/php-7.3/bin/php)
==21544==    by 0x853677: zend_deactivate (in /usr/local/php-7.3/bin/php)
==21544==    by 0x7F761A: php_request_shutdown (in /usr/local/php-7.3/bin/php)
==21544==    by 0x8D77D5: do_cli (in /usr/local/php-7.3/bin/php)
==21544==    by 0x47AB55: main (in /usr/local/php-7.3/bin/php)
==21544==  Address 0x1ba482f4 is 4 bytes inside a block of size 56 free'd
==21544==    at 0x4C2FDAC: free (vg_replace_malloc.c:530)
==21544==    by 0x848E05: destroy_zend_class (in /usr/local/php-7.3/bin/php)
==21544==    by 0x8459F3: shutdown_executor (in /usr/local/php-7.3/bin/php)
==21544==    by 0x853677: zend_deactivate (in /usr/local/php-7.3/bin/php)
==21544==    by 0x7F761A: php_request_shutdown (in /usr/local/php-7.3/bin/php)
==21544==    by 0x8D77D5: do_cli (in /usr/local/php-7.3/bin/php)
==21544==    by 0x47AB55: main (in /usr/local/php-7.3/bin/php)
==21544==  Block was alloc'd at
==21544==    at 0x4C2EBAB: malloc (vg_replace_malloc.c:299)
==21544==    by 0x82D278: __zend_malloc (in /usr/local/php-7.3/bin/php)
==21544==    by 0x822E2A: lex_scan (in /usr/local/php-7.3/bin/php)
==21544==    by 0x836668: zendlex (in /usr/local/php-7.3/bin/php)
==21544==    by 0x81C3DD: zendparse (in /usr/local/php-7.3/bin/php)
==21544==    by 0x81E7C2: zend_compile (in /usr/local/php-7.3/bin/php)
==21544==    by 0x81FEE1: compile_file (in /usr/local/php-7.3/bin/php)
==21544==    by 0x6E85F1: phar_compile_file (in /usr/local/php-7.3/bin/php)
==21544==    by 0x81FF68: compile_filename (in /usr/local/php-7.3/bin/php)
==21544==    by 0x893864: zend_include_or_eval (in /usr/local/php-7.3/bin/php)
==21544==    by 0x8C8AA9: ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER (in /usr/local/php-7.3/bin/php)
==21544==    by 0x8CD99E: execute_ex (in /usr/local/php-7.3/bin/php)
==21544==    by 0x8466F5: zend_call_function (in /usr/local/php-7.3/bin/php)
==21544==    by 0x74B54D: zif_spl_autoload_call (in /usr/local/php-7.3/bin/php)
==21544==    by 0x8465B1: zend_call_function (in /usr/local/php-7.3/bin/php)
==21544==    by 0x846A57: zend_lookup_class_ex (in /usr/local/php-7.3/bin/php)
==21544==    by 0x847397: zend_fetch_class_by_name (in /usr/local/php-7.3/bin/php)
==21544==    by 0x89BA8A: ZEND_DECLARE_INHERITED_CLASS_SPEC_CONST_CONST_HANDLER (in
/usr/local/php-7.3/bin/php)
==21544==    by 0x8CF616: execute_ex (in /usr/local/php-7.3/bin/php)
==21544==    by 0x8466F5: zend_call_function (in /usr/local/php-7.3/bin/php)
==21544==    by 0x74B54D: zif_spl_autoload_call (in /usr/local/php-7.3/bin/php)
==21544==    by 0x8465B1: zend_call_function (in /usr/local/php-7.3/bin/php)
==21544==    by 0x846A57: zend_lookup_class_ex (in /usr/local/php-7.3/bin/php)
==21544==    by 0x847397: zend_fetch_class_by_name (in /usr/local/php-7.3/bin/php)
==21544==    by 0x89BA8A: ZEND_DECLARE_INHERITED_CLASS_SPEC_CONST_CONST_HANDLER (in
/usr/local/php-7.3/bin/php)
==21544==    by 0x8CF616: execute_ex (in /usr/local/php-7.3/bin/php)
==21544==    by 0x8D5F41: zend_execute (in /usr/local/php-7.3/bin/php)
==21544==    by 0x853963: zend_execute_scripts (in /usr/local/php-7.3/bin/php)
==21544==    by 0x7F89FF: php_execute_script (in /usr/local/php-7.3/bin/php)
==21544==    by 0x8D83A5: do_cli (in /usr/local/php-7.3/bin/php)
==21544== 
==21544== Invalid read of size 4
==21544==    at 0x848DFD: destroy_zend_class (in /usr/local/php-7.3/bin/php)
==21544==    by 0x8459F3: shutdown_executor (in /usr/local/php-7.3/bin/php)
==21544==    by 0x853677: zend_deactivate (in /usr/local/php-7.3/bin/php)
==21544==    by 0x7F761A: php_request_shutdown (in /usr/local/php-7.3/bin/php)
==21544==    by 0x8D77D5: do_cli (in /usr/local/php-7.3/bin/php)
==21544==    by 0x47AB55: main (in /usr/local/php-7.3/bin/php)
==21544==  Address 0x1ba482f0 is 0 bytes inside a block of size 56 free'd
==21544==    at 0x4C2FDAC: free (vg_replace_malloc.c:530)
==21544==    by 0x848E05: destroy_zend_class (in /usr/local/php-7.3/bin/php)
==21544==    by 0x8459F3: shutdown_executor (in /usr/local/php-7.3/bin/php)
==21544==    by 0x853677: zend_deactivate (in /usr/local/php-7.3/bin/php)
==21544==    by 0x7F761A: php_request_shutdown (in /usr/local/php-7.3/bin/php)
==21544==    by 0x8D77D5: do_cli (in /usr/local/php-7.3/bin/php)
==21544==    by 0x47AB55: main (in /usr/local/php-7.3/bin/php)
==21544==  Block was alloc'd at
==21544==    at 0x4C2EBAB: malloc (vg_replace_malloc.c:299)
==21544==    by 0x82D278: __zend_malloc (in /usr/local/php-7.3/bin/php)
==21544==    by 0x822E2A: lex_scan (in /usr/local/php-7.3/bin/php)
==21544==    by 0x836668: zendlex (in /usr/local/php-7.3/bin/php)
==21544==    by 0x81C3DD: zendparse (in /usr/local/php-7.3/bin/php)
==21544==    by 0x81E7C2: zend_compile (in /usr/local/php-7.3/bin/php)
==21544==    by 0x81FEE1: compile_file (in /usr/local/php-7.3/bin/php)
==21544==    by 0x6E85F1: phar_compile_file (in /usr/local/php-7.3/bin/php)
==21544==    by 0x81FF68: compile_filename (in /usr/local/php-7.3/bin/php)
==21544==    by 0x893864: zend_include_or_eval (in /usr/local/php-7.3/bin/php)
==21544==    by 0x8C8AA9: ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER (in /usr/local/php-7.3/bin/php)
==21544==    by 0x8CD99E: execute_ex (in /usr/local/php-7.3/bin/php)
==21544==    by 0x8466F5: zend_call_function (in /usr/local/php-7.3/bin/php)
==21544==    by 0x74B54D: zif_spl_autoload_call (in /usr/local/php-7.3/bin/php)
==21544==    by 0x8465B1: zend_call_function (in /usr/local/php-7.3/bin/php)
==21544==    by 0x846A57: zend_lookup_class_ex (in /usr/local/php-7.3/bin/php)
==21544==    by 0x847397: zend_fetch_class_by_name (in /usr/local/php-7.3/bin/php)
==21544==    by 0x89BA8A: ZEND_DECLARE_INHERITED_CLASS_SPEC_CONST_CONST_HANDLER (in
/usr/local/php-7.3/bin/php)
==21544==    by 0x8CF616: execute_ex (in /usr/local/php-7.3/bin/php)
==21544==    by 0x8466F5: zend_call_function (in /usr/local/php-7.3/bin/php)
==21544==    by 0x74B54D: zif_spl_autoload_call (in /usr/local/php-7.3/bin/php)
==21544==    by 0x8465B1: zend_call_function (in /usr/local/php-7.3/bin/php)
==21544==    by 0x846A57: zend_lookup_class_ex (in /usr/local/php-7.3/bin/php)
==21544==    by 0x847397: zend_fetch_class_by_name (in /usr/local/php-7.3/bin/php)
==21544==    by 0x89BA8A: ZEND_DECLARE_INHERITED_CLASS_SPEC_CONST_CONST_HANDLER (in
/usr/local/php-7.3/bin/php)
==21544==    by 0x8CF616: execute_ex (in /usr/local/php-7.3/bin/php)
==21544==    by 0x8D5F41: zend_execute (in /usr/local/php-7.3/bin/php)
==21544==    by 0x853963: zend_execute_scripts (in /usr/local/php-7.3/bin/php)
==21544==    by 0x7F89FF: php_execute_script (in /usr/local/php-7.3/bin/php)
==21544==    by 0x8D83A5: do_cli (in /usr/local/php-7.3/bin/php)
==21544== 
==21544== 
==21544== HEAP SUMMARY:
==21544==     in use at exit: 9,484 bytes in 70 blocks
==21544==   total heap usage: 57,160 allocs, 57,090 frees, 10,884,126 bytes allocated
==21544== 
==21544== LEAK SUMMARY:
==21544==    definitely lost: 2,648 bytes in 21 blocks
==21544==    indirectly lost: 5,142 bytes in 26 blocks
==21544==      possibly lost: 640 bytes in 1 blocks
==21544==    still reachable: 1,054 bytes in 22 blocks
==21544==         suppressed: 0 bytes in 0 blocks
==21544== Rerun with --leak-check=full to see details of leaked memory
==21544== 
==21544== For counts of detected and suppressed errors, rerun with: -v
==21544== Use --track-origins=yes to see where uninitialised values come from
==21544== ERROR SUMMARY: 10 errors from 6 contexts (suppressed: 0 from 0)

Not sure how useful this is, though, as I cannot compile PHP with --enable-debug as that overrides
"-O2" with "-O0".


Previous Comments:
------------------------------------------------------------------------
[2018-08-05 14:11:33] cmb@php.net

> What I find weird is that you were able to reproduce the issue
> initially but now you no longer can while I am still seeing it.

Initially, I've built PHP “incrementally”, i.e. I started with a
minimal build, and did config.nice … && make to add the required
extensions.  That let the test fail.  If I build with exactly the
same configure options in one go, the test succeeds.

gcc (Debian 6.3.0-18) 6.3.0 20170516

------------------------------------------------------------------------
[2018-08-04 06:37:06] sebastian@php.net

I can confirm that compiling PHP with -fno-optimize-strlen solves the problem for me.

------------------------------------------------------------------------
[2018-08-03 22:45:10] bugs dot php dot net at majkl578 dot cz

Bisect log (bad: php-7.3.0beta1, good: php-7.2.9RC1) if anyone needs to replay:

# bad: [9160e881a6af72691ad034978e5078a8042ee9b6] Update versions for PHP 7.3.0beta1
# good: [09aa799e6448ed2a12b9371f8cdf31683b0c46aa] Update versions for PHP 7.2.9RC1
git bisect start 'php-7.3.0beta1' 'php-7.2.9RC1'
# good: [095a30e11b14dde32aabc002d627301bcbe7a927] Update NEWS [ci skip]
git bisect good 095a30e11b14dde32aabc002d627301bcbe7a927
# good: [095a30e11b14dde32aabc002d627301bcbe7a927] Update NEWS [ci skip]
git bisect good 095a30e11b14dde32aabc002d627301bcbe7a927
# bad: [6e94f943c1943984b55de159404d480f82357f7c] Avoid abs() type mismatch warnings
git bisect bad 6e94f943c1943984b55de159404d480f82357f7c
# bad: [bfe19cb355a82c14e03504f4499f267a51155a85] Merge branch 'PHP-7.2'
git bisect bad bfe19cb355a82c14e03504f4499f267a51155a85
# bad: [a06ba4b9d6621bd4bb7c387cf1439c7a356c8d72] Merge branch 'PHP-7.2'
git bisect bad a06ba4b9d6621bd4bb7c387cf1439c7a356c8d72
# good: [e6bfbb6c9d7524f62366c664ceb5056be7c55195] Merge branch 'PHP-7.2'
git bisect good e6bfbb6c9d7524f62366c664ceb5056be7c55195
# bad: [28fdc1f1c35392d1bbe16d4f8c76a2d661d70b0b] Merge branch 'PHP-7.2'
git bisect bad 28fdc1f1c35392d1bbe16d4f8c76a2d661d70b0b
# bad: [17b39f1216bf213838c7975d266808d4bc7ffb4c] Merge branch 'PHP-7.2'
git bisect bad 17b39f1216bf213838c7975d266808d4bc7ffb4c
# good: [902188e5e3889886d609696a7b5ed8ac12e071e2] Merge branch 'PHP-7.2'
git bisect good 902188e5e3889886d609696a7b5ed8ac12e071e2
# good: [b1cf87a4e6ef58987107709f89470168fd928452] Merge branch 'PHP-7.2'
git bisect good b1cf87a4e6ef58987107709f89470168fd928452
# good: [e20fbd43bad65d10af1e0d648f7bfa0c40baa893] Separate mbfl filters into three categories
git bisect good e20fbd43bad65d10af1e0d648f7bfa0c40baa893
# good: [fea7957d0836d8389c4b5063138277d7a21156b3] Optimize mb_chr()
git bisect good fea7957d0836d8389c4b5063138277d7a21156b3
# bad: [513b0093c2b480bb752fb354012f42c446769486] Refactor php_url struct to save memory dup in
common cases
git bisect bad 513b0093c2b480bb752fb354012f42c446769486
# good: [6546c516dd61f7f9efecbd9144c02218614d4c51] Optimized ucfirst(Avoid duping string if
possible)
git bisect good 6546c516dd61f7f9efecbd9144c02218614d4c51
# first bad commit: [513b0093c2b480bb752fb354012f42c446769486] Refactor php_url struct to save
memory dup in common cases

------------------------------------------------------------------------
[2018-08-03 22:43:33] bugs dot php dot net at majkl578 dot cz

Bisected to commit 513b0093c2b480bb752fb354012f42c446769486: Refactor php_url struct to save memory
dup in common cases [laurence]
https://github.com/php/php-src/commit/513b0093c2b480bb752fb354012f42c446769486

------------------------------------------------------------------------
[2018-08-03 21:37:22] bugs dot php dot net at majkl578 dot cz

Traced down to optimize-strlen GCC optimization (part of -O2).

does not work: -O2
works: -O2 -fno-optimize-strlen

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


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=76510


--
Edit this bug report at https://bugs.php.net/bug.php?id=76510&edit=1


Thread (23 messages)

« previous php.bugs (#216639) next »