Skip to content

Out of memory on import with CORS issues. #2138

Open

Description

@bph

Trying to open the blueprint from the gallery theme-ally-test in Playground multiple errors occurred:

Error message: 'https://wpthemetestdata.files.wordpress.com/2008/06/dcp_2082.jpg' from origin 'https://playground.wordpress.net/' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Error: Error when executing the blueprint step #3 ({"step":"importWxr","file":{"resource":"url","url":"https://github.com/WordPress/theme-test-data/blob/master/themeunittestdata.wordpress.xml"}}) : memory access out of bounds

To double-check on the import file, the content imported after a while into a new site in Studio locally.
It never got to the "All done" screen, but all 37 images, 23 pages and 57 posts made it into the site.

Activity

  1. bgrgicak commented on Feb 10, 2025

    @bgrgicak
    Collaborator

    This is caused by the WP.com server not allowing CORS requests.

    @brandonpayton do you maybe know what's the standard way of enabling CORS on WP.com sites like https://wpthemetestdata.wordpress.com/?

  2. brandonpayton commented on Feb 14, 2025

    @brandonpayton
    Member

    @brandonpayton do you maybe know what's the standard way of enabling CORS on WP.com sites like https://wpthemetestdata.wordpress.com/?

    @bgrgicak I don't know of a standard way to do this with a wpcom simple site. I would think we could use the CORS proxy to work around the CORS errors.

  3. brandonpayton commented on Feb 14, 2025

    @brandonpayton
    Member

    I would think we could use the CORS proxy to work around the CORS errors.

    @bgrgicak it turns out we are indeed asking the CORS proxy for the files and getting them. When I look in the dev tools Network tab for some of the CORS errors, I see requests like these that receive an image with a 200 response status.
    https://wordpress-playground-cors-proxy.net/?https://wpthemetestdata.wordpress.com/wp-content/uploads/2014/01/dsc20050315_145007_132.jpg

    So it seems like the CORS errors might be a red herring.

  4. brandonpayton commented on Feb 15, 2025

    @brandonpayton
    Member

    It turns out that, after @bgrgicak's work on "Move DNS polyfills to a PHP extension and add missing constants", there is no more memory-access-out-of-bounds-error. That is interesting. 🤔 I wonder what might have been going wrong before.

    @adamziel, this is an interesting thing to know about.

  5. adamziel commented on Feb 19, 2025

    @adamziel
    Collaborator

    Oh huh, interesting. I wonder whether the problem was about the DNS implementation OR if the DNS work shifted the memory layout in some way that will make the issue pop up in another place. Since it was a CORS-related problem, I'm happy with assuming it was the former and closing this issue. Let's keep an eye out for related problems, though.

  6. brandonpayton commented on Mar 26, 2025

    @brandonpayton
    Member

    I'm going to reopen this for now because merging the DNS implementation change hasn't landed yet in #2165. There are some CI failures I need to look into. When that PR lands, it is marked to close this issue again automatically.

  7. adamziel commented on Jun 13, 2025

    @adamziel
    Collaborator
  8. brandonpayton commented on Jun 19, 2025

    @brandonpayton
    Member

    I'll grab this one. Thanks for reopening, @adamziel.

  9. adamziel commented on Jul 3, 2025

    @adamziel
    Collaborator

    Just ran into another one today. Unfortunately, the reproduction is non-trivial:

    
    RuntimeError: memory access out of bounds
        at php.wasm.std::__2::basic_ostream<char, std::__2::char_traits<char>>::flush() (wasm://wasm/php.wasm-073c60e6:wasm-function[37251]:0xef5e52)
        at php.wasm.std::__2::DoIOSInit::~DoIOSInit() (wasm://wasm/php.wasm-073c60e6:wasm-function[37604]:0xf02b29)
        at php.wasm.__cxx_global_array_dtor.1 (wasm://wasm/php.wasm-073c60e6:wasm-function[37606]:0xf02ba0)
        at php.wasm.__funcs_on_exit (wasm://wasm/php.wasm-073c60e6:wasm-function[34854]:0xe97f70)
        at ret.<computed> (file:///Users/cloudnik/www/Automattic/core/plugins/playground/packages/php-wasm/node/jspi/php_8_0.js:18190:14)
        at runtime.wasmExports.<computed> (/Users/cloudnik/www/Automattic/core/plugins/playground/packages/php-wasm/universal/src/lib/wasm-error-reporting.ts:59:13)
        at ___funcs_on_exit (file:///Users/cloudnik/www/Automattic/core/plugins/playground/packages/php-wasm/node/jspi/php_8_0.js:34097:54)
        at exitRuntime (file:///Users/cloudnik/www/Automattic/core/plugins/playground/packages/php-wasm/node/jspi/php_8_0.js:305:3)
        at exitJS (file:///Users/cloudnik/www/Automattic/core/plugins/playground/packages/php-wasm/node/jspi/php_8_0.js:8623:4)
        at php.wasm.main (wasm://wasm/php.wasm-073c60e6:wasm-function[9292]:0x6c1456) {
      cause: Error
          at Asyncify.handleSleep (file:///Users/cloudnik/www/Automattic/core/plugins/playground/packages/php-wasm/node/jspi/php_8_0.js:34262:41)
          at _emscripten_sleep (file:///Users/cloudnik/www/Automattic/core/plugins/playground/packages/php-wasm/node/jspi/php_8_0.js:16705:19)
          at php.wasm.__wrap_select (wasm://wasm/php.wasm-073c60e6:wasm-function[8802]:0x691240)
          at php.wasm.Curl_socket_check (wasm://wasm/php.wasm-073c60e6:wasm-function[21472]:0xb185f9)
          at php.wasm.curl_multi_perform (wasm://wasm/php.wasm-073c60e6:wasm-function[21437]:0xb14551)
          at php.wasm.zif_curl_multi_exec (wasm://wasm/php.wasm-073c60e6:wasm-function[897]:0x394b7b)
          at php.wasm.ZEND_DO_FCALL_BY_NAME_SPEC_RETVAL_USED_HANDLER (wasm://wasm/php.wasm-073c60e6:wasm-function[7982]:0x6509eb)
          at php.wasm.execute_ex (wasm://wasm/php.wasm-073c60e6:wasm-function[7208]:0x605419)
          at php.wasm.zend_execute (wasm://wasm/php.wasm-073c60e6:wasm-function[7210]:0x605684)
          at php.wasm.zend_execute_scripts (wasm://wasm/php.wasm-073c60e6:wasm-function[6745]:0x5e565a)
    }
    
  10. adamziel commented on Jul 14, 2025

    @adamziel
    Collaborator

    @zaerl I'm curious if your stack size insight would resolve this issue

  11. zaerl commented on Jul 15, 2025

    @zaerl
    Contributor

    @zaerl I'm curious if your stack size insight would resolve this issue

    I am testing it in my PR with 1MB and can't reproduce. Usually, the "out of bounds" has been the problem I found with the default stack. By having a relatively deep call, the runtime tries to free() a segment of memory that it has not initialized. This is because a segment of memory has another segment immediately after, and it appears to be one. If you are lucky enough to catch the error, it is usually a Corrupt region! Size marker at the end of the region does not match or an error of the same family. So later it try to access the same "region" (the stdout buffer?), that has been removed before.

    The default size is tiny, which is okay for small apps, but not for what I consider a big app (playground). From the code, I see the object is flushing during the destructor, which is a must-do in C++ to keep the stream synced.

    It can be other reasons, but a fix that worked in other similar parts can do the same here, with a bit of luck.

  12. brandonpayton commented on Jul 17, 2025

    @brandonpayton
    Member

    🤔 I haven't been able to reproduce this error using any of the links mentioned above. Is there any other place you are seeing this error?

  13. adamziel commented on Jan 17, 2026

    @adamziel
    Collaborator

    @JanJakes @mho22 maybe this will produce an interesting memory profile re: safari-related memory crashes? 🤔

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

Metadata

Metadata

Assignees

Type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions