Skip to content
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

Update for AMP v3 #36

Merged
merged 2 commits into from
Aug 10, 2022
Merged

Update for AMP v3 #36

merged 2 commits into from
Aug 10, 2022

Conversation

iggyvolz
Copy link

Updates the library to use AMP v3 instead of v2. Should go on a v2 branch or similarly named.

Right now the following tests fail when run as part of the test suite, but pass when run individually (might be some kind of race condition?):

  • ConnectTest::testCryptoConnect
  • Http01VerificationTest::failsOnWrongPayload

@iggyvolz
Copy link
Author

It looks like there's some sort of issue where everything is working correctly it's segfaulting on program close. Was showing up periodically on phpunit executions: boiled it down to the following script (only happens sometimes, doesn't appear to matter with local boulder or let's encrypt staging instance):

<?php

require_once __DIR__ . "/vendor/autoload.php";
$key = (new \Kelunik\Acme\Crypto\RsaKeyGenerator())->generateKey();
$client = new \Kelunik\Acme\AcmeClient("https://acme-staging-v02.api.letsencrypt.org/directory", $key);
$service = new \Kelunik\Acme\AcmeService($client);
$account = $service->register("iggyvolz@gmail.com", true);

Backtrace (generated with latest PHP master ff76694f2831783486f5c29f71b0fe63f6b9a182, also tested with PHP 8.1.3 and 8.1.2):

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff78c379b in kill () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007ffff78c379b in kill () from /usr/lib/libc.so.6
#1  0x00005555559ec30e in zend_mm_panic (message=0x555555dae605 "zend_mm_heap corrupted") at /home/katie/php-src/Zend/zend_alloc.c:365
#2  0x00005555559ede33 in zend_mm_get_debug_info (heap=0x7ffff7600040, ptr=0x55555621fc58 <executor_globals+888>) at /home/katie/php-src/Zend/zend_alloc.c:1307
#3  0x00005555559edf7c in zend_mm_alloc_heap (heap=0x7ffff7600040, size=224, __zend_filename=0x555555dab4f0 "/home/katie/php-src/Zend/zend_string.h", __zend_lineno=150, __zend_orig_filename=0x0, __zend_orig_lineno=0)
    at /home/katie/php-src/Zend/zend_alloc.c:1337
#4  0x00005555559f0d2d in _emalloc (size=192, __zend_filename=0x555555dab4f0 "/home/katie/php-src/Zend/zend_string.h", __zend_lineno=150, __zend_orig_filename=0x0, __zend_orig_lineno=0) at /home/katie/php-src/Zend/zend_alloc.c:2549
#5  0x00005555559c77eb in zend_string_alloc (len=161, persistent=false) at /home/katie/php-src/Zend/zend_string.h:150
#6  0x00005555559c785e in zend_string_init (
    str=0x7ffff533de20 "/**\n * Will be thrown from {@see Queue::push()} or used to fail the future returned from {@see Queue::pushAsync()}\n * if the associated iterator is disposed.\n */\nfinal class DisposedException extends "..., len=161, persistent=false) at /home/katie/php-src/Zend/zend_string.h:172
#7  0x00005555559cf7ad in lex_scan (zendlval=0x7ffff3ffd620, elem=0x7ffff3ffd680) at Zend/zend_language_scanner.l:2437
#8  0x00005555559f77e6 in zendlex (elem=0x7ffff3ffd680) at /home/katie/php-src/Zend/zend_compile.c:1751
--Type <RET> for more, q to quit, c to continue without paging--
#9  0x00005555559c191b in zendparse () at /home/katie/php-src/Zend/zend_language_parser.c:5027
#10 0x00005555559c934d in zend_compile (type=2) at Zend/zend_language_scanner.l:599
#11 0x00005555559c959f in compile_file (file_handle=0x7ffff3ffe360, type=2) at Zend/zend_language_scanner.l:653
#12 0x0000555555801086 in phar_compile_file (file_handle=0x7ffff3ffe360, type=2) at /home/katie/php-src/ext/phar/phar.c:3346
#13 0x00005555559c97bc in compile_filename (type=2, filename=0x7ffff77dcaa0) at Zend/zend_language_scanner.l:704
#14 0x0000555555a6c6f6 in zend_include_or_eval (inc_filename_zv=0x7ffff52cbd90, type=2) at /home/katie/php-src/Zend/zend_execute.c:4546
#15 0x0000555555ac73d3 in ZEND_INCLUDE_OR_EVAL_SPEC_CV_HANDLER () at /home/katie/php-src/Zend/zend_vm_execute.h:38605
#16 0x0000555555aea737 in execute_ex (ex=0x7ffff52cbca0) at /home/katie/php-src/Zend/zend_vm_execute.h:58857
#17 0x0000555555a171da in zend_call_function (fci=0x7ffff3ffe910, fci_cache=0x7ffff3ffe8f0) at /home/katie/php-src/Zend/zend_execute_API.c:903
#18 0x0000555555a17652 in zend_call_known_function (fn=0x7ffff7603c78, object=0x7ffff767c400, called_scope=0x7ffff7602610, retval_ptr=0x0, param_count=1, params=0x7ffff3ffe9c0, named_params=0x0)
    at /home/katie/php-src/Zend/zend_execute_API.c:992
#19 0x00005555558427b3 in spl_perform_autoload (class_name=0x7ffff5205300, lc_name=0x7ffff52056c0) at /home/katie/php-src/ext/spl/php_spl.c:433
--Type <RET> for more, q to quit, c to continue without paging--
#20 0x0000555555a17de9 in zend_lookup_class_ex (name=0x7ffff5205300, key=0x7ffff52056c0, flags=512) at /home/katie/php-src/Zend/zend_execute_API.c:1158
#21 0x0000555555a18b24 in zend_fetch_class_by_name (class_name=0x7ffff5205300, key=0x7ffff52056c0, fetch_type=512) at /home/katie/php-src/Zend/zend_execute_API.c:1618
#22 0x0000555555a85aef in ZEND_NEW_SPEC_CONST_UNUSED_HANDLER () at /home/katie/php-src/Zend/zend_vm_execute.h:10151
#23 0x0000555555ae7f8f in execute_ex (ex=0x7ffff52cb070) at /home/katie/php-src/Zend/zend_vm_execute.h:56402
#24 0x0000555555a171da in zend_call_function (fci=0x7ffff7099928, fci_cache=0x7ffff7099968) at /home/katie/php-src/Zend/zend_execute_API.c:903
#25 0x0000555555b339f3 in zend_fiber_execute (transfer=0x7ffff3ffefc0) at /home/katie/php-src/Zend/zend_fibers.c:478
#26 0x0000555555b33364 in zend_fiber_trampoline (data=...) at /home/katie/php-src/Zend/zend_fibers.c:290
#27 0x000055555598711f in make_fcontext () at make_x86_64_sysv_elf_gas.S:71
#28 0x0000000000000000 in ?? ()

Looks like an issue with PHP upstream that's just getting hit through amp? Will work on reporting that upstream but the library seems to function as normally (just occasionally dies with a segfault?)

src/AcmeClient.php Outdated Show resolved Hide resolved
src/AcmeService.php Outdated Show resolved Hide resolved
src/AcmeService.php Outdated Show resolved Hide resolved
src/AcmeService.php Outdated Show resolved Hide resolved
composer.json Outdated Show resolved Hide resolved
@kelunik kelunik changed the base branch from master to v2 August 10, 2022 18:16
src/AcmeClient.php Outdated Show resolved Hide resolved
@kelunik kelunik merged commit 78a8ff7 into kelunik:v2 Aug 10, 2022
@kelunik
Copy link
Owner

kelunik commented Aug 10, 2022

Thanks a lot!

@iggyvolz
Copy link
Author

Tests all pass at this point and there's no segfault - it may have either gotten fixed somewhere upstream or it was something with my environment.

@iggyvolz iggyvolz deleted the v2 branch August 10, 2022 23:54
@kelunik
Copy link
Owner

kelunik commented Aug 11, 2022

18c8e26 fixed the test failures.

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

Successfully merging this pull request may close these issues.

2 participants