[Windows] LaTeX preview: incomplete temporary USERPROFILE crashes pdfTeX when including PDFs

オープン 初心者向け
#62,533 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
latex, python
領域
desktop, devtools

調査の方向性

tectonic/compiler/compile_desktop.pyから始め、texlive_environment()で一時的なhomeとUSERPROFILEが設定される箇所を調べてください。TeX Liveを起動する前に不足しているプロファイルディレクトリを用意し、新しいWindowsプロファイルで既存のPDFを含む文書とテキストのみの文書を対象とする回帰テストを追加してください。分離されたプレビュー環境で両方のコンパイルが成功すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

app bug sandbox windows-os

Summary

On Windows, Codex's built-in LaTeX preview crashes in the system TeX Live pdflatex.exe when the document includes a PDF image. The same source compiles normally with the same TeX Live installation outside the preview.

A controlled reproduction isolated the trigger to the temporary Windows profile assigned by the desktop compiler helper: USERPROFILE points to a new home directory without AppData\Roaming and AppData\Local. Creating both subdirectories before the compiler starts makes the full document compile under the same restricted filesystem permissions. Preparing those directories for the actual desktop preview also made compile_latex_document return kind: success for the unchanged source.

Environment

  • Codex Windows package: OpenAI.Codex 26.1111.9664.0, x64.
  • Windows 10 Pro, version 10.0.19045, x64.
  • TeX Live 2026: pdfTeX 3.141592653-2.6-1.40.29, Xpdf 4.06.
  • latexmk 4.88.
  • Surface: built-in .tex editor / Compile PDF / compile_latex_document.
  • Verified on 2026-11-19.

Actual behavior

The first compiler attempt processes all pages and fonts, then crashes before printing Output written on .... Windows displays a pdflatex.exe memory-read application error. latexmk surfaces it as:

Can't spawn "pdflatex ...": No error
pdflatex: Command for 'pdflatex' gave return code 255
[texlive] failed (exit 12)

A debugger attached only to a newly launched minimal test process captured 0xc0000005 inside pdftex.dll at module-relative offset 0x127a20 on this installed binary. This is an observed fault location, not proof of the precise underlying C++ defect. A separate test also returned a heap-corruption status.

The preview then tries bundled Tectonic and hits a separate launch problem:

[tectonic] [WinError 5] Access is denied.
(operation=start_compiler winerror=5 executable=windowsapps executable_read=ok)
[bundled tectonic] command/exec failed rpc=-32603 CreateProcessAsUserW failed: 5

That fallback error matches #53757. The primary issue reported here is the pdfTeX crash.

Reproduction

Use any valid small local PDF as figure.pdf and open this document in the built-in editor:

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\includegraphics[width=10cm]{figure.pdf}
\end{document}

On the affected installation, this fails with the same late crash. A text-only document using the same class compiles successfully. Several unrelated PDF figures and a multi-page PDF included using pdfpages reproduced the failure.

To isolate the environment independently of the editor:

  1. Launch the same pdflatex.exe with a fresh output directory and normal inherited environment; the PDF-inclusion example succeeds.
  2. In the child process environment only, set USERPROFILE to an existing, otherwise empty temporary directory; the example crashes.
  3. Keep that same value, but create <temporary profile>\AppData\Roaming and <temporary profile>\AppData\Local before starting the child; it succeeds.

The tests were also run inside a temporary Codex sandbox with the source directory read-only and only a diagnostic output directory writable. The same failure/success distinction held. No global environment variables or permissions were changed for these controls.

Additional controls:

Change Result
Only HOME points to the temporary directory Pass
Only USERPROFILE points to the incomplete temporary directory Crash
TeX-specific home/config/cache variables redirected, without changing USERPROFILE Pass
Temporary-directory variables redirected Pass
openout_any=p Pass
Disable SyncTeX Still fails in the actual desktop compiler
Disable PDF object compression Still fails in the actual desktop compiler
Complete the temporary profile's AppData directories, retaining all preview environment overrides Pass, full 18-page report

Installed helper observation

Read-only inspection of the installed tectonic/compiler/compile_desktop.py shows that texlive_environment() currently creates:

home = output_directory / "home"
cache = output_directory / "tex-cache"
home.mkdir(exist_ok=True)
cache.mkdir(exist_ok=True)

It then sets HOME and USERPROFILE to home, along with isolated TEXMFHOME, TEXMFCONFIG, TEXMFVAR, TEXMFCACHE, and openout_any=p. It does not create the Windows AppData directories in that temporary profile.

Suggested fix

On Windows, synchronously prepare the temporary profile before starting TeX Live, for example:

if os.name == "nt":
    (home / "AppData" / "Roaming").mkdir(parents=True, exist_ok=True)
    (home / "AppData" / "Local").mkdir(parents=True, exist_ok=True)

Keep the existing sandbox, isolated TeX paths, -norc, and -no-shell-escape. Regression coverage should include both a text-only document and a document that includes an existing PDF, with a freshly created temporary Windows profile.

Actual integrated-preview verification

A local directory watcher was used as a compatibility workaround to prepare only the missing directories in newly created Codex preview-* folders. It did not modify Codex's package, source documents, system TeX, ACLs, or sandbox policy.

After this preparation, the original unchanged source compiled via the actual desktop tool:

{
  "kind": "success",
  "message": "The current source compiled successfully with the desktop editor's compiler."
}

The first successful-compilation attempt returned stale-project; retrying returned success. A subsequent event-driven version of the watcher also passed two fresh integrated preview compilations; a temporary comment whitespace change was used to invalidate the cached result, then reverted and compiled again. The final source hash matches the original.

This verifies the actual compiler interface; it does not establish that the separate Tectonic launch-permission issue is fixed. The directory watcher is timing-dependent, so preparation inside the helper before spawning the compiler is the preferable product fix.

Related reports

  • #48311: earlier Windows/Tectonic directory-initialization failures; comments discuss synthetic USERPROFILE and missing AppData directories, but the reported compiler/error and integrated-preview outcomes differ.
  • #53757: same bundled Tectonic CreateProcessAsUserW failed: 5 fallback error.
  • #59854: other Windows preview engine-selection/cache problems, with different primary diagnostics.

Posted with the affected user's authorization. No original documents, names, student identifiers, local user paths, screenshots, session transcripts, credentials, or raw application logs are included.

主要言語
Rust
スター
136k
フォーク
21.5k
平均マージ
1分
マージ済み PR(30日)
998

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

openai/codex のほかの issue

openai/codex の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。