Skip to content

Resolve #11099 in case of a debug-zts-asan build #11457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

realFlowControl
Copy link
Contributor

@realFlowControl realFlowControl commented Jun 15, 2023

When building the PHP 8.3 versions with phar support from source with aarch64-linux-gnu tool chain, it will fail with:

/bin/bash: line 1: 11317 Killed                  /tmp/build-php/sapi/cli/php -v 2>&1
Generating phar.php
/bin/bash /tmp/build-php/libtool --silent --preserve-dup-deps --tag CC --mode=link x86_64-linux-gnu-gcc -shared -I/tmp/build-php/include -I/tmp/build-php/main -I/usr/local/src/php -I/tmp/build-php/ext/date/lib -I/usr/local/src/php/ext/date/lib -I/usr/include/libxml2 -I/usr/include/x86_64-linux-gnu -I/usr/local/src/php/ext/mbstring/libmbfl -I/tmp/build-php/ext/mbstring/libmbfl -I/usr/local/src/php/ext/mbstring/libmbfl/mbfl -I/tmp/build-php/ext/mbstring/libmbfl/mbfl -I/usr/include/postgresql -I/usr/include/editline -I/tmp/build-php/TSRM -I/tmp/build-php/Zend -I/usr/local/src/php/main -I/usr/local/src/php/Zend -I/usr/local/src/php/TSRM -I/tmp/build-php/  -D_GNU_SOURCE -D_REENTRANT -pthread  -fno-common -Wformat-truncation -Wlogical-op -Wduplicated-cond -Wno-clobbered -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -fsanitize=address -DZEND_TRACK_ARENA_ALLOC -fvisibility=hidden -pthread -Wimplicit-fallthrough=1 -DZTS -DZEND_MAX_EXECUTION_TIMERS   -fsanitize=address  -o ext/opcache/opcache.la -export-dynamic -avoid-version -prefer-pic -module -rpath /tmp/build-php/modules -avoid-version -module -L/usr/lib/x86_64-linux-gnu ext/opcache/ZendAccelerator.lo ext/opcache/zend_accelerator_blacklist.lo ext/opcache/zend_accelerator_debug.lo ext/opcache/zend_accelerator_hash.lo ext/opcache/zend_accelerator_module.lo ext/opcache/zend_persist.lo ext/opcache/zend_persist_calc.lo ext/opcache/zend_file_cache.lo ext/opcache/zend_shared_alloc.lo ext/opcache/zend_accelerator_util_funcs.lo ext/opcache/shared_alloc_shm.lo ext/opcache/shared_alloc_mmap.lo ext/opcache/shared_alloc_posix.lo ext/opcache/jit/zend_jit.lo ext/opcache/jit/zend_jit_gdb.lo ext/opcache/jit/zend_jit_vm_helpers.lo 
/bin/bash /tmp/build-php/libtool --silent --preserve-dup-deps --tag CC --mode=install cp ext/opcache/opcache.la /tmp/build-php/modules
/bin/bash: line 5: 13654 Killed                  ` if test -x "/tmp/build-php/sapi/cli/php"; then /usr/local/src/php/build/shtool echo -n -- "/tmp/build-php/sapi/cli/php -n"; if test "x/tmp/build-php/modules/zend_test.la" != "x"; then /usr/local/src/php/build/shtool echo -n -- " -d extension_dir=/tmp/build-php/modules"; for i in bz2 zlib phar; do if test -f "/tmp/build-php/modules/$i.la"; then . /tmp/build-php/modules/$i.la; /usr/local/src/php/build/shtool echo -n -- " -d extension=$dlname"; fi; done; fi; else /usr/local/src/php/build/shtool echo -n -- "/tmp/build-php/sapi/cli/php"; fi;` -n -d 'open_basedir=' -d 'output_buffering=0' -d 'memory_limit=-1' -d phar.readonly=0 /usr/local/src/php/ext/phar/build_precommand.php > ext/phar/phar.php
make: [Makefile:444: ext/phar/phar.php] Error 137 (ignored)
/bin/bash: line 1: 13993 Killed                  /tmp/build-php/sapi/cli/php -v 2>&1
Generating phar.phar
/bin/bash: line 8: 14177 Killed                  ` if test -x "/tmp/build-php/sapi/cli/php"; then /usr/local/src/php/build/shtool echo -n -- "/tmp/build-php/sapi/cli/php -n"; if test "x/tmp/build-php/modules/zend_test.la" != "x"; then /usr/local/src/php/build/shtool echo -n -- " -d extension_dir=/tmp/build-php/modules"; for i in bz2 zlib phar; do if test -f "/tmp/build-php/modules/$i.la"; then . /tmp/build-php/modules/$i.la; /usr/local/src/php/build/shtool echo -n -- " -d extension=$dlname"; fi; done; fi; else /usr/local/src/php/build/shtool echo -n -- "/tmp/build-php/sapi/cli/php"; fi;` -n -d 'open_basedir=' -d 'output_buffering=0' -d 'memory_limit=-1' -d phar.readonly=0 ext/phar/phar.php pack -f ext/phar/phar.phar -a pharcommand -c auto -x \\.svn -p 0 -s /usr/local/src/php/ext/phar/phar/phar.php -h sha1 -b "`/usr/local/src/php/build/shtool echo -n -- "/opt//debut-zts-asan/bin/php";`" /usr/local/src/php/ext/phar/phar/
chmod: cannot access 'ext/phar/phar.phar': No such file or directory
make: [Makefile:452: ext/phar/phar.phar] Error 1 (ignored)

Build complete.
Don't forget to run 'make test'.

This PR will add a check for an empty return from php -v to the quickfix from #11243 that resolved #11099

@nielsdos
Copy link
Member

Thanks for your interest in this.

I have two small questions:
I see that the problem is the empty output caused by the crashing of the process. Do you know why the crash occurs in the first place?
Also, I see that you changed the grep -c ... into grep -q ... chained with echos. Why is this change necessary?

@realFlowControl
Copy link
Contributor Author

Hey @nielsdos,

I did not yet find the time to check why it is crashing, but this is one of the next things on my list.
Regarding the grep -c .. thingy: my bash-fu is not the best ;-) but I was not able to express this differently. To me it does the following:

  • thanks to the && echo 1 bash has to evaluate both OR statements before it
  • so if the string is empty or contains the string "Exec format error" it will call echo 1
  • otherwise it will call echo 0

A more explicit version would be:

TEST_PHP_EXECUTABLE_RES = $(shell ([ -z "$(TEST_PHP_EXECUTABLE)" ] || echo "$(TEST_PHP_EXECUTABLE)" | grep -q "Exec format error") && echo 1 || echo 0)

Note the brackets surrounding the OR clause.

If we'd stay with grep -c the result in TEST_PHP_EXECUTABLE_RES will be 1 1 in case the grep matches.

Hope this helps

@nielsdos
Copy link
Member

Thanks for the elaborate explanation! Your patch will make sure that if the process gets killed without generating output, the phar generation won't happen.

The problem with this is that it can hide problems. Even outside of a cross-compile build, it's possible that PHP can crash during phar generation due to a bug. With this patch applied it will in that case erroneously print "Skipping phar generating during cross compilation", which is probably confusing and hides that there's a bug.

I don't think the problem is in the check. I think the actual problem we should look at is why the process gets killed without output. (Side question: do you have qemu-user installed by chance? Is it an old version?).
I could be wrong of course, please let me know if you think differently.

@realFlowControl
Copy link
Contributor Author

You are totally right, this has the potential to hide problems. I played a bit and learned, that if SHELL=sh would be set, than the returned string is not emtpy, but Killed, which would also hide problems.
Now the funny thing is: since after this weekend, I can no longer reproduce the error, so I am closing this PR until I can reproduce again and/or learn more about this topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generating phar.php during cross-compile can't be done
2 participants