WordPress / wordpress-playground

Run WordPress in the browser via WebAssembly PHP
https://w.org/playground/
GNU General Public License v2.0
1.64k stars 257 forks source link

WooCommerce crash #967

Closed adamziel closed 6 months ago

adamziel commented 9 months ago

Navigating to https://playground.wordpress.net/?php=8.0&wp=6.4&storage=none&networking=yes&networking=yes&php-extension-bundle=kitchen-sink&networking=yes&plugin=pagbank-connect&plugin=woocommerce&plugin=woocommerce-extra-checkout-fields-for-brazil and poking around in the admin dashboard for a while causes the following crash:

CleanShot 2024-01-22 at 17 48 12@2x

I don't have the exact reproduction steps. I've been navigating through Woo products, orders, and the "checkout fields" plugin in wp-admin.

Potentially related:

adamziel commented 9 months ago

Ricardo Martins shared the following related resources:

playground.wordpress.net-1705617535236.log image

adamziel commented 9 months ago

I was still able to trigger the crash even with HPOS disabled.

adamziel commented 9 months ago

I built PHP with -g2 -O0 and couldn't reproduce the issue anymore. Weird!

adamziel commented 9 months ago

I managed to get some unminified error information:

CleanShot 2024-01-22 at 18 19 45@2x CleanShot 2024-01-22 at 18 19 16@2x

adamziel commented 9 months ago

The woocommerce-extra-checkout-fields-for-brazil lives at https://github.com/claudiosanches/woocommerce-extra-checkout-fields-for-brazil/

adamziel commented 9 months ago

The crash also happens without the woocommerce-extra-checkout-fields-for-brazil plugin.

adamziel commented 9 months ago

I couldn't reproduce it on vanilla woocommerce, too, which makes me think it's related to the pagbank-connect plugin. Also noteworthy, post_message_to_js used by the fetch() HTTP transport showed up in a bunch of the stack traces logged around the time of the crash which makes me think the crash occurred when processing a response to some HTTP request.

adamziel commented 9 months ago

Here's a different stacktrace I got with vanilla WooCommerce, likely related to an out of memory error:

Uncaught RangeError: Maximum call stack size exceeded
    at runtime.asm.<computed> (wasm-error-reporting.ts:60:14)
    at invoke_viii (php_8_0.js?t=1705943705634:6822:3)
    at zend_mm_safe_error (027ecb4e:0xe637f)
    at zend_mm_alloc_pages (027ecb4e:0x1f09db)
    at zend_mm_alloc_small_slow (027ecb4e:0x409b5)
    at _emalloc (027ecb4e:0x78f7)
    at smart_str_erealloc (027ecb4e:0x87c8)
    at xbuf_format_converter (027ecb4e:0x2d31b6)
    at php_printf_to_smart_str (027ecb4e:0x515a12)
    at zend_error_va_list (027ecb4e:0x29887d)

Here's the call cycle:

CleanShot 2024-01-22 at 18 38 24@2x

adamziel commented 9 months ago

Ricardo said:

I see the Pagbank plugin has an issue with the CORS. Meaning that the backend calls doesn’t work when called with fetch/frontend ajax calls. Probably it is related to that matter.

adamziel commented 7 months ago

I managed to get some unminified error information:

CleanShot 2024-01-22 at 18 19 45@2x ![CleanShot 2024-01-22 at 18 19 16@2x]

This error was fixed by @bgrgicak in https://github.com/WordPress/wordpress-playground/pull/1104. That being said, I ran into another one:

CleanShot 2024-03-22 at 00 23 47@2x

Before it was triggered, I saw the following debug output:

[21-Mar-2024 23:22:27 UTC] PHP Fatal error:  Out of memory (allocated 65011712) (tried to allocate 4194304 bytes) in /wordpress/wp-content/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-webhook-deliveries-v2-controller.php on line 143
[21-Mar-2024 23:22:28 UTC] PHP Fatal error:  Out of memory (allocated 62914560) (tried to allocate 4194304 bytes) in /wordpress/wp-content/plugins/woocommerce/includes/rest-api/Controllers/Version2/class-wc-rest-webhook-deliveries-v2-controller.php on line 143
[21-Mar-2024 23:22:28 UTC] PHP Fatal error:  Out of memory (allocated 58720256) (tried to allocate 2097152 bytes) in /wordpress/wp-content/plugins/woocommerce/includes/wc-deprecated-functions.php on line 373
[21-Mar-2024 23:22:28 UTC] PHP Fatal error:  Out of memory (allocated 41943040) (tried to allocate 2097152 bytes) in /wordpress/wp-content/plugins/woocommerce/includes/wc-deprecated-functions.php on line 373
[21-Mar-2024 23:22:28 UTC] PHP Fatal error:  Out of memory (allocated 33554432) (tried to allocate 2097152 bytes) in /wordpress/wp-content/plugins/woocommerce/includes/wc-deprecated-functions.php on line 373
[21-Mar-2024 23:22:28 UTC] PHP Fatal error:  Out of memory (allocated 29360128) (tried to allocate 2097152 bytes) in /wordpress/wp-content/plugins/woocommerce/includes/wc-deprecated-functions.php on line 373
[21-Mar-2024 23:22:29 UTC] PHP Fatal error:  Out of memory (allocated 27262976) (tried to allocate 2097152 bytes) in /wordpress/wp-content/plugins/woocommerce/includes/wc-deprecated-functions.php on line 373

Perhaps auto-rotating the PHP instance on an Out of memory error would help here.

bgrgicak commented 7 months ago

@adamziel do you have any instructions on how to recreate this?

adamziel commented 7 months ago

@bgrgicak nothing more than what I described in other comments – install those plugins, browse for a prolonged period of time, hope the crash happens.

adamziel commented 6 months ago

This is likely a duplicate of https://github.com/WordPress/wordpress-playground/issues/1332, except #1332 has a clear reproduction. I'll close this one.