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

Đang mở Phù hợp với người mới
#62,533 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
latex, python
Lĩnh vực
desktop, devtools

Hướng nghiên cứu

Bắt đầu với tectonic/compiler/compile_desktop.py và kiểm tra texlive_environment(), nơi home và USERPROFILE tạm thời được cấu hình. Chuẩn bị các thư mục hồ sơ còn thiếu trước khi khởi chạy TeX Live, sau đó bổ sung kiểm thử hồi quy cho một tài liệu chỉ có văn bản và một tài liệu có chứa PDF hiện có trong hồ sơ Windows mới. Hoàn thành khi cả hai biên dịch thành công bằng môi trường xem trước được cô lập.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Rust
Star
136k
Fork
21.5k
Merge trung bình
1 phút
Pull request đã merge (30 ngày)
998

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của openai/codex

Tất cả issue của openai/codex

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.