pe_run_package: report a package image that is not a PE as an error line #1608

Merged
tedin7 merged 1 commit from upstream-pr/1615 into main 2026-11-24 16:04:03 +00:00
tedin7 commented 2026-11-24 15:03:05 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T15:03:05Z.


pe_run_package.py exits with a traceback when a package image is not a valid PE. pe_package_preflight.py reports the same input as one error line.

Reproduce on origin/main: put a file named app.exe containing the bytes "MZ not a portable executable" in an empty directory and run
python tools/pe_run_package.py MAPPER PACKAGE_DIR app.exe --preflight-only
It prints a Traceback ending in pefile.PEFormatError. main() caught only ValueError and OSError. It now also catches pefile.PEFormatError, the same set the preflight tool uses. The exit code stays 1.

New test: tests/pe_run_package_invalid_check.py (registered as pe_run_package_invalid_pe). It verifies clean exit code 1 with a stderr error line, empty stdout, and no traceback for:

  • a non-PE entry image (app.exe),
  • a non-PE bundled DLL (helper.dll) alongside a valid entry image, and
  • an entry outside/missing from the package.
    The mapper placeholder is kept outside the package directory so package scanning inspects only the intended package images. The test needs no Windows host, because the error occurs before the mapper is loaded.

Commands executed locally:

  • python -B tests/pe_run_package_invalid_check.py (passes, 3 tests)
  • python -B tests/pe_package_ordinal_plan_check.py (passes, 3 tests)
  • python -B tests/pe_package_preflight_check.py (passes, 14 tests)
  • python -B tests/docs_links_check.py (passes)
  • python -B tests/bidi_controls_check.py (passes)
  • git diff --check

Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit 047a3f19e0299310bc9a932f06a7164d1177291a:

  • Debug (--preset dev): ctest --preset dev -R '^pe_run_package_invalid_pe$' --parallel 4 --no-tests=error --output-on-failure — 1/1 passed (0.51s)
  • Release /O2 (--preset release): ctest --preset release -R '^pe_run_package_invalid_pe$' --parallel 4 --no-tests=error --output-on-failure — 1/1 passed (0.52s)
  • Windows Python checks: tests/intake/import_forms_check.py ok (0.1s)

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6584787829 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1615). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T15:03:05Z. --- pe_run_package.py exits with a traceback when a package image is not a valid PE. pe_package_preflight.py reports the same input as one error line. Reproduce on origin/main: put a file named app.exe containing the bytes "MZ not a portable executable" in an empty directory and run python tools/pe_run_package.py MAPPER PACKAGE_DIR app.exe --preflight-only It prints a Traceback ending in pefile.PEFormatError. main() caught only ValueError and OSError. It now also catches pefile.PEFormatError, the same set the preflight tool uses. The exit code stays 1. New test: tests/pe_run_package_invalid_check.py (registered as pe_run_package_invalid_pe). It verifies clean exit code 1 with a stderr error line, empty stdout, and no traceback for: - a non-PE entry image (app.exe), - a non-PE bundled DLL (helper.dll) alongside a valid entry image, and - an entry outside/missing from the package. The mapper placeholder is kept outside the package directory so package scanning inspects only the intended package images. The test needs no Windows host, because the error occurs before the mapper is loaded. Commands executed locally: - python -B tests/pe_run_package_invalid_check.py (passes, 3 tests) - python -B tests/pe_package_ordinal_plan_check.py (passes, 3 tests) - python -B tests/pe_package_preflight_check.py (passes, 14 tests) - python -B tests/docs_links_check.py (passes) - python -B tests/bidi_controls_check.py (passes) - git diff --check Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit `047a3f19e0299310bc9a932f06a7164d1177291a`: - Debug (`--preset dev`): `ctest --preset dev -R '^pe_run_package_invalid_pe$' --parallel 4 --no-tests=error --output-on-failure` — 1/1 passed (0.51s) - Release `/O2` (`--preset release`): `ctest --preset release -R '^pe_run_package_invalid_pe$' --parallel 4 --no-tests=error --output-on-failure` — 1/1 passed (0.52s) - Windows Python checks: `tests/intake/import_forms_check.py` ok (0.1s) AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-24 16:03:33 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T15:15:59Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T15:17:50.211374Z 047a3f1 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7135735323 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1615#issuecomment-7135735323). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T15:15:59Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"047a3f19e0299310bc9a932f06a7164d1177291a","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-24T15:17:50.211374Z">2026-11-24T15:17:50.211374Z</relative-time> | `047a3f1` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
upstream-sync closed this pull request 2026-11-24 17:01:42 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!1608
No description provided.