Skip to content

Codex App freezes when pasting JSON stack traces with escaped backslashes into composer #25865

Description

@iwbtamkn47

What version of the Codex App are you using (From “About Codex” dialog)?

26.527.60818 (3437)

What subscription do you have?

Enterprise

What platform is your computer?

Darwin 24.6.0 arm64 arm

What issue are you seeing?

Codex Desktop freezes when I paste a medium-sized JSON stack trace into the composer.

The renderer process stays near 100% CPU and the UI becomes unresponsive. This happens in a new chat as the first pasted input, so it does not appear to be caused by thread history size.

The trigger is a JSON array such as stackTrace: [ containing many escaped stack-frame strings with sequences like \" and \n. This is common when copying AWS Lambda / Python stack traces as JSON:

{
  "stackTrace": [
    "  File \"/var/task/src/application/services.py\", line 688, in fetch_events\n    events = future.result()\n"
  ]
}

Important observations:

  • Pasting random ASCII text of the same length does not freeze.
  • Pasting multiline random ASCII text of the same length does not freeze.
  • Pasting JSON-like text without escaped backslashes does not freeze.
  • Pasting File \"...\", line ... text outside a JSON/bracketed structure does not freeze.
  • Pasting text at or above 5000 characters does not freeze because Codex converts it into Pasted text.txt.
  • Pasting under 5000 characters freezes because it is inspected and inserted directly into the composer.

This looks like catastrophic backtracking in the paste-time Markdown link / rich prompt detection regex, not a backend/Lambda issue or spellcheck issue.

What steps can reproduce the bug?

  1. Open Codex Desktop.
  2. Open a new chat.
  3. Paste a generated text under 5000 characters that contains:
    • an opening [
    • many backslash escape sequences such as \"
    • no valid Markdown link terminator ](...)
  4. Observe that Codex Desktop becomes unresponsive and a renderer process pegs CPU near 100%.

Minimal generator:

const target = 4991;
let text = '{\n  "stackTrace": [\n';
let i = 0;

while (text.length < target) {
  text += `    "alpha beta gamma \\"quoted\\" delta epsilon ${i}",\n`;
  i += 1;
}

text = text.slice(0, target);
console.log(text);

I also reproduced the core slowdown outside Codex Desktop in Node/V8 with the same regex shape used by the composer paste path:

const markdownLink = /\[((?:\\.|[^\]])+)\]\(((?:\\.|[^)])+)\)/g;

Measured results for a JSON-stack-trace-like string:

1200 chars: ~21 ms
1400 chars: ~262 ms
1600 chars: ~1.47 s
1800 chars: >5 s timeout

Measured results with a fixed 2000-character string:

[`... 16 backslash escapes ...]` without `](`: ~207 ms
[`... 20 backslash escapes ...]` without `](`: ~3 s
[`... 24 backslash escapes ...]` without `](`: >5 s timeout
same 40 backslash escapes with valid `](target)`: ~0.04 ms

What is the expected behavior?

Pasting this text should not freeze the composer.

If Codex needs to inspect pasted text for rich links or mentions, that detection should be bounded and should not block the renderer. If the pasted text is too expensive to inspect safely, Codex should treat it as plain text or convert it into a pasted-text attachment.

Additional information

Environment details:

  • macOS 15.7 (24G222)
  • Apple Silicon
  • Bundle ID: com.openai.codex
  • app.asar SHA-256: de59889d6501fc863a825c3e1c05a902ce5e001dff4d1e65474d5ae73768c0ae

The likely root cause is the Markdown link detection regex used during paste handling:

/\[((?:\\.|[^\]])+)\]\(((?:\\.|[^)])+)\)/g

The subpattern (?:\\.|[^\]])+ is ambiguous because a backslash can match both alternatives:

  • \\.
  • [^\]]

When a string contains [ followed by many escaped backslashes or escaped quotes, but does not form a valid Markdown link ](...), V8 spends a long time backtracking.

Making the fallback character classes exclude backslash removes the slowdown in my local reproduction:

/\[((?:\\.|[^\\\]])+)\]\(((?:\\.|[^\\)])+)\)/g

With that safer pattern, the same 4991-character heavy cases complete in about 0.06-0.10 ms.

Possible fixes:

  • Make Markdown link detection regexes unambiguous by excluding backslash from fallback character classes.
  • Add a length/time guard around paste-time rich prompt parsing.
  • Skip rich prompt parsing for stack-trace-like pasted JSON under 5000 characters, or convert medium-sized pasted text to an attachment before running expensive detection.

Workarounds:

  • Paste stack traces as .txt attachments.
  • Paste at or above 5000 characters so Codex converts the content into Pasted text.txt.
  • Decode escaped JSON stack-trace strings before pasting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    appIssues related to the Codex desktop appbugSomething isn't workingperformance

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions