Agent skill

Debug Php Wasm Side Modules

by WordPress in WordPress/wordpress-playground

Debug WASM side modules (dynamic PHP extensions) including dlopen failures, SIDEMODULE loading, JSPI suspension crashes in extensions, C++ weak symbol issues, and extension runtime errors.

GPL-2.0Auto-check passedDevelopment

Install Debug Php Wasm Side Modules

skills CLI
$ npx skills add WordPress/wordpress-playground --skill debug-php-wasm-side-modules -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install WordPress/wordpress-playground debug-php-wasm-side-modules --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/WordPress/wordpress-playground.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/debug-php-wasm-side-modules .claude/skills/debug-php-wasm-side-modules && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
debug-php-wasm-side-modules
GitHub stars
2k
Token cost
~2.5k tokens
SKILL.md length
1,048 words
Files
1
Skills in repo
5
Repo updated
First seen
Licence
GPL-2.0

At a glance

Debug WASM side modules (dynamic PHP extensions) including dlopen failures, SIDEMODULE loading, JSPI suspension crashes in extensions, C++ weak symbol issues, and extension runtime errors.

  • Works in 3 steps: JS wrapper in… → JSPI_IMPORTS — add wasm_recv to the… → Preprocessor redirect — compile the side…
  • Working with dynamic extensions like Xdebug
  • SKILL.md covers _dlopen_js Must Be Synchronous, Side Module JSPI Suspension…, Extension Loading Lifecycle and Asyncify + SIDE_MODULE:…, plus 7 more sections
  • Calls node

What it does

Debug Php Wasm Side Modules is an agent skill from WordPress/wordpress-playground. Debug WASM side modules (dynamic PHP extensions) including dlopen failures, SIDEMODULE loading, JSPI suspension crashes in extensions, C++ weak symbol issues, and extension runtime errors. Use when working with dynamic extensions like Xdebug, intl, or GD built as WASM side modules.

Its SKILL.md is about 2.5k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in Development, covering Debugging. It works with WebAssembly, PHP, C++ and WordPress. The repository describes itself as: Run WordPress in the browser via WebAssembly PHP. The licence is GPL-2.0.

When your agent uses it

  • Working with dynamic extensions like Xdebug
  • GD built as WASM side modules

Example prompts

  • “/debug-php-wasm-side-modules”

Requirements

  • Node.js

Workflow steps

3 steps, taken from the first numbered list in SKILL.md.

  1. JS wrapper in phpwasm-emscripten-library.js
  2. JSPI_IMPORTS — add wasm_recv to the Dockerfile so the main
  3. Preprocessor redirect — compile the side module with

What it can do on your machine

Read from SKILL.md and the folder at commit 4d39322. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • node

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Debug Php Wasm Side Modules loads about 2.5k tokens when it runs. Until then it costs about 78 tokens; SKILL.md has 1,048 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~78
When it runs · the whole SKILL.md, loaded when a task matches
~2.5k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from WordPress/wordpress-playground at commit 4d39322, republished under its GPL-2.0 licence (© WordPress). 1,048 words, ~2,481 tokens.

Download SKILL.mdSave it as .claude/skills/debug-php-wasm-side-modules/SKILL.md (or your agent's skills folder).
name
debug-php-wasm-side-modules
description
Debug WASM side modules (dynamic PHP extensions) including dlopen failures, SIDE_MODULE loading, JSPI suspension crashes in extensions, C++ weak symbol issues, and extension runtime errors. Use when working with dynamic extensions like Xdebug, intl, or GD built as WASM side modules.

Debugging PHP.wasm Side Modules

Patterns for diagnosing and fixing issues with dynamic PHP extensions built as WASM side modules and loaded via dlopen.

_dlopen_js Must Be Synchronous

Emscripten marks _dlopen_js as async by default (isAsync = true). With JSPI, this wraps the import with WebAssembly.Suspending. Even when the implementation returns a plain value (not a Promise), the JSPI wrapper corrupts the WASM call stack — V8's native stack bookkeeping desynchronizes __stack_pointer in linear memory, causing heap corruption that manifests later as zend_mm_panic in _efree.

Fix: Set _dlopen_js__async: false in the Emscripten JS library (phpwasm-emscripten-library-dynamic-linking.js).

Symptoms: zend_extension= in php.ini crashes PHP on ANY subsequent code. dl() at runtime works fine. Neutering _dlopen_js to return 0 still crashes — the corruption is in the JSPI wrapping, not the function's implementation.

Side Module JSPI Suspension Pattern

Side modules import functions from the main module. When a side module calls a blocking C function (e.g. recv), the call resolves to the main module's compiled WASM implementation — NOT a JS import, so it cannot be wrapped with WebAssembly.Suspending. The call returns immediately (EAGAIN) instead of waiting for data.

The general fix has three parts:

  1. JS wrapper in phpwasm-emscripten-library.js:

    js
    wasm_recv: function(sockfd, buf, len, flags) {
        // Try synchronous recv; if EAGAIN, return Promise
    },
    wasm_recv__async: true,
  2. JSPI_IMPORTS — add wasm_recv to the Dockerfile so the main module imports it from JS.

  3. Preprocessor redirect — compile the side module with -Drecv=wasm_recv so C recv() calls become wasm_recv(), resolving to the JS import instead of the main module's WASM function.

This pattern applies to ANY blocking C function a side module needs to suspend on: recv, select, sleep, read, connect, etc.

Extension Loading Lifecycle

Files (.so binary, ini config) must be written at a specific point:

loadNodeRuntime()  →  WASM loads, FS ready
new PHP(runtime)   →  initializeRuntime(), writes default php.ini
                      *** WRITE FILES HERE ***
php.run()          →  php_wasm_init() → php_module_startup() → reads ini

Two traps:

  • loadNodeRuntime overwrites onRuntimeInitialized — it spreads user options then sets its own callback AFTER the spread. Files written in a user-provided callback are silently lost. No error, the extension just never loads.
  • preRun fires before initRuntime() / FS init. Writing files there crashes.

Use php.writeFile() / php.readFileAsText() after new PHP(runtime).

Asyncify + SIDE_MODULE: ASYNCIFY_IMPORTS Is Required

When compiling a side module with -sASYNCIFY and the module uses custom renamed imports (e.g. -Drecv=wasm_recv), you MUST pass -sASYNCIFY_IMPORTS=<custom_name>.

Binaryen's Asyncify pass only knows about its default async imports (emscripten_sleep, etc.). Custom import names are unknown to it. Without -sASYNCIFY_IMPORTS, Binaryen won't instrument the call sites — no save/restore of locals around the call.

dockerfile
export EMCC_FLAGS="-sSIDE_MODULE -sASYNCIFY -sASYNCIFY_IMPORTS=wasm_recv"

Symptom: table index is out of bounds during Asyncify rewind (not unwind) at a side module offset that doesn't appear in the original stack trace. Corrupt locals used as call_indirect table indices.

Do NOT add ASYNCIFY_EXPORTS for imported functions — that flag is for functions the module exports.

Verifying instrumentation

Disassemble the .so before and after adding ASYNCIFY_IMPORTS:

bash
wasm-opt --print module.so | grep -c '__asyncify_state'

A correctly instrumented module has significantly more __asyncify_state checks than an uninstrumented one.

Asyncify Shared Globals

Side modules need to import __asyncify_state and __asyncify_data as shared globals from the main module. The main module provides them as WebAssembly.Global objects. Verify with:

js
WebAssembly.Module.imports(mod)
    .filter(i => i.name.includes('asyncify'))

If these imports are missing, the side module's Asyncify instrumentation has no shared state with the main module — unwind/rewind will silently malfunction.

JSPI + C++ Side Modules: Weak Symbol Crashes

C++ libraries may call syscalls like close() during internal operations (e.g. after memory-mapping data files). When a side module makes such a call, it can trigger JSPI suspension. This fails with SuspendError: trying to suspend JS frames because C++ weak symbol env imports are resolved through JS closure stubs in the dynamic linker, and those JS frames block JSPI suspension.

Root cause

When a side module imports C++ weak symbols (templates, inline functions, virtual destructors) NOT present in the main module, Emscripten's dynamic linker creates JS closure stubs that resolve lazily. Any JSPI suspension in a call chain that includes these stubs fails.

Show full SKILL.md (441 more words)Show less
Fix: two-pass instantiation (JSPI only)
  1. Instantiate the side module to get its exports
  2. Add exports to wasmImports
  3. Instantiate again with the enriched imports

This pre-populates weak-symbol GOT entries, eliminating JS stubs.

Fix: patch C/C++ source (alternative)

If the triggering syscall is non-essential (e.g. close(fd) on a file descriptor only needed temporarily for mmap), patch the source to remove it. Apply the patch in the extension's Dockerfile before compilation.

Asyncify is NOT affected

Asyncify's unwind/rewind mechanism operates within WASM code only — JS closure stubs on the native call stack don't interfere. C++ side modules with weak symbol env imports work correctly under Asyncify without two-pass instantiation or source patching.

Web Platform: Dynamic Extension Loading

On the web, .so files cannot be read from the filesystem. They must be fetched via HTTP and written to the WASM virtual FS:

typescript
const extensionUrl = await getExtensionModule(version);
const extension = await (await fetch(extensionUrl)).arrayBuffer();
phpRuntime.FS.writeFile(
    '/internal/shared/extensions/extension.so',
    new Uint8Array(extension)
);

Key differences from Node.js:

  • fetch() instead of fs.readFileSync() for loading .so bytes
  • URL resolution via bundler — use assetsInclude: ['**/*.so'] in Vite config so the bundler serves .so files
  • MAIN_MODULE required — web builds need it too (was previously node-only)
  • ENVIRONMENT=web,worker — include worker so the PHP runtime works in Web Workers

Verifying Extensions Actually Work

extension_loaded() returning true only means MINIT succeeded. It does NOT mean runtime features work. Always test actual functionality:

  • Debugger (Xdebug): set a breakpoint, verify it hits
  • intl: run a collation or formatting operation
  • GD: create an image, verify output bytes

Simple operations may pass while complex ones crash. Different code paths exercise different internal functions.

Version Coupling

Each PHP version needs its own side module build. Zend API version mismatch gives a clear error: "Extension requires Zend Engine API version X, installed version is Y."

The main module and side module MUST be compiled with the same Emscripten version. Version mismatch causes function table corruption after dlopen.

Debugging Commands

bash
# Inspect side module symbols
wasm-objdump -x extension.so

# Check what a side module imports/exports
node -e "
  const fs = require('fs');
  const mod = new WebAssembly.Module(fs.readFileSync('extension.so'));
  console.log('exports:', WebAssembly.Module.exports(mod).map(e => e.name));
  console.log('imports:', WebAssembly.Module.imports(mod).map(i => i.name));
"

# Verify Asyncify shared globals are imported
node -e "
  const fs = require('fs');
  const mod = new WebAssembly.Module(fs.readFileSync('extension.so'));
  console.log(WebAssembly.Module.imports(mod)
    .filter(i => i.name.includes('asyncify')));
"

# Check object files in C++ library build (libtool often misses subdirs)
find . -path '*/.libs/*.o' -print

# Verify the extension loads
node -e "
  const { PHP } = require('@php-wasm/node');
  // ... load runtime, write .so, run php.run({ code: '<?php var_dump(extension_loaded(\"xdebug\")); ?>' })
"

Diagnostic Cheat Sheet

SituationAction
zend_mm_panic after zend_extension= in ini_dlopen_js is wrongly async — set __async: false
dl() works but ini loading crashesSame cause — _dlopen_js async wrapping
SuspendError: trying to suspend JS frames from side moduleC++ weak symbol stubs — use two-pass instantiation (JSPI) or patch source
table index is out of bounds during Asyncify rewindMissing ASYNCIFY_IMPORTS in side module EMCC_FLAGS
extension_loaded() true but features crashTest actual functionality, not just MINIT
bad export type during dlopenSide module missing required symbol exports (get_module, zif_*)
Extension silently not loadedCheck file writing lifecycle — files may be written too early or overwritten
Zend Engine API version mismatchRebuild side module for the correct PHP version
Function table corruption after dlopenEmscripten version mismatch between main and side module
R_WASM_MEMORY_ADDR_SLEB relocation errorPre-built archive not PIC — rebuild from source

© WordPress, GPL-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/debug-php-wasm-side-modules of WordPress/wordpress-playground.

Open the folder on GitHubat commit 4d39322

Compare with similar skills

Debug Php Wasm Side Modules next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Debug Php Wasm Side Modules compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Debug Php Wasm Side Modules this skillWordPress/wordpress-playground2k—~2.5kAutomated safety check: PassGPL-2.0
Wp Interactivity APIAutomattic/agent-skills2113 repos~1.5kAutomated safety check: PassNone
Wp PlaygroundAutomattic/agent-skills2112 repos~1.2kAutomated safety check: PassNone
Wasm Emscriptenmohitmishra786/low-level-dev-skills253—~1.7kAutomated safety check: PassMIT
WooCommerce Code Reviewwoocommerce/woocommerce11k3 repos~1.1kAutomated safety check: PassCustom licence
Extempore JIT Debugging Guidedigego/extempore1.5k—~4.4kAutomated safety check: PassNone

Similar skills

  • Wp Interactivity API

    Automattic/agent-skills

    A skill your agent uses when building or debugging WordPress Interactivity API features (data-wp- directives, @wordpress/interactivity store/state/actions, block viewScriptModule integration…

    211 GitHub starsUsed in 3 repos~1.5k tokens
    DevelopmentAuto-check passed
  • Wp Playground

    Automattic/agent-skills

    A skill your agent uses for WordPress Playground workflows: fast disposable WP instances in the browser or locally via @wp-playground/cli (server, run-blueprint, build-snapshot), auto-mounting…

    211 GitHub starsUsed in 2 repos~1.2k tokens
    DevelopmentAuto-check passed
  • Wasm Emscripten

    mohitmishra786/low-level-dev-skills

    WebAssembly with Emscripten skill for C/C++ to WASM compilation.

    253 GitHub stars~1.7k tokensUpdated 3 mo ago
    DevelopmentAuto-check passed
  • WooCommerce Code Review

    woocommerce/woocommerce

    Reviews WooCommerce code changes against the project's standards, flagging backend PHP architecture, naming, documentation, data integrity and testing violations.

    11k GitHub starsUsed in 3 repos~1.1k tokens
    DevelopmentAuto-check passed
  • Debugging guide for Extempore covering its three layers, compilation paths, startup sequence and the batch, eval and interactive modes used to isolate JIT problems.

    1.5k GitHub stars~4.4k tokensUpdated 14 days ago
    DevelopmentAuto-check passed
  • OpenROAD Bug Fixer

    The-OpenROAD-Project/OpenROAD

    Fixes an OpenROAD bug from a GitHub issue or error code: finds the root cause, implements the fix, adds a regression test and prepares a signed-off commit.

    3.2k GitHub stars~784 tokensUpdated today
    DevelopmentAuto-check passed

More from WordPress/wordpress-playground

  • Doc Screenshots

    WordPress/wordpress-playground

    Annotate UI screenshots with documentation callouts in Fellyph's established visual style — uniform-width orange arrows with white halos, double-stroke target outlines, numbered callout cards, dim…

    2k GitHub stars~1.8k tokensUpdated today
    Auto-check passed
  • Compile Php Wasm

    WordPress/wordpress-playground

    Compile PHP.wasm main modules and side modules (dynamic extensions) for Node.js and web platforms.

    2k GitHub stars~2.8k tokensUpdated today
    Auto-check passed
  • Debug Php Wasm Main Module

    WordPress/wordpress-playground

    Debug PHP.wasm main module crashes including Asyncify errors (unreachable, memory access out of bounds), JSPI errors (SuspendError, trying to suspend JS frames), WASM memory growth bugs, and runtime…

    2k GitHub stars~3.1k tokensUpdated today
    Auto-check passed
  • Playground Website Debugging

    WordPress/wordpress-playground

    Debug the WordPress Playground website by running the dev server from source and interacting with it via Playwright MCP.

    2k GitHub stars~1.9k tokensUpdated today
    Auto-check passed

Categories

Questions about Debug Php Wasm Side Modules

What does Debug Php Wasm Side Modules do?

Debug WASM side modules (dynamic PHP extensions) including dlopen failures, SIDEMODULE loading, JSPI suspension crashes in extensions, C++ weak symbol issues, and extension runtime errors. Debug Php Wasm Side Modules is an agent skill from WordPress/wordpress-playground. Debug WASM side modules (dynamic PHP extensions) including dlopen failures, SIDEMODULE loading, JSPI suspension crashes in extensions, C++ weak symbol issues, and extension runtime errors.

When should I use Debug Php Wasm Side Modules?

Debug Php Wasm Side Modules fits situations like: working with dynamic extensions like Xdebug; GD built as WASM side modules.

How do I install Debug Php Wasm Side Modules in Claude Code?

Run `npx skills add WordPress/wordpress-playground --skill debug-php-wasm-side-modules -a claude-code`. Or copy the skill folder (.agents/skills/debug-php-wasm-side-modules in WordPress/wordpress-playground) into .claude/skills/debug-php-wasm-side-modules in your project. Claude Code loads it when a task matches its description.

How do I install Debug Php Wasm Side Modules in Codex?

Run `npx skills add WordPress/wordpress-playground --skill debug-php-wasm-side-modules -a codex`. Or copy the skill folder (.agents/skills/debug-php-wasm-side-modules in WordPress/wordpress-playground) into .agents/skills/debug-php-wasm-side-modules in your project. Codex loads it when a task matches its description.

Can I use Debug Php Wasm Side Modules in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add WordPress/wordpress-playground --skill debug-php-wasm-side-modules -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/debug-php-wasm-side-modules, .gemini/skills/debug-php-wasm-side-modules, .github/skills/debug-php-wasm-side-modules and .opencode/skills/debug-php-wasm-side-modules in your project.

What does Debug Php Wasm Side Modules need to run?

Going by SKILL.md and its folder, Debug Php Wasm Side Modules needs the command-line tools its instructions call (node). Our summary lists: Node.js.

Does Debug Php Wasm Side Modules access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Debug Php Wasm Side Modules safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Debug Php Wasm Side Modules use?

Debug Php Wasm Side Modules is published under the GPL-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Debug Php Wasm Side Modules use?

About 2.5k tokens (SKILL.md is roughly 9.9k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Debug Php Wasm Side Modules?

Skills that share tags, products or a category with Debug Php Wasm Side Modules: Wp Interactivity API (Automattic/agent-skills, 211 stars), Wp Playground (Automattic/agent-skills, 211 stars), Wasm Emscripten (mohitmishra786/low-level-dev-skills, 253 stars) and WooCommerce Code Review (woocommerce/woocommerce, 11k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Debug Php Wasm Side Modules?

WordPress (a GitHub organization) maintains it in WordPress/wordpress-playground, which has 1,973 GitHub stars. The repository holds 5 skills in this directory. The repository was last updated on October 7, 2026.

Source: WordPress/wordpress-playground on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.