Skip to content

[fix] Avoid PyArrow 25 thread initialization crash - #15947

Merged
sfc-gh-lwilby-1 merged 5 commits into
developfrom
lukasmasuch/debug-playwright-log-regression
Jul 13, 2026
Merged

sfc-gh-lwilby-1 merged 5 commits into
developfrom
lukasmasuch/debug-playwright-log-regression

Conversation

@lukasmasuch

@lukasmasuch lukasmasuch commented Jul 12, 2026 •

Copy link
Copy Markdown
Collaborator

Describe your changes

PyArrow 25.0.0 bundles mimalloc 3.3.1, which can segfault when the library is
first loaded on a short-lived worker thread and a later thread performs an Arrow
allocation. Streamlit's ScriptRunner lifecycle triggers this pattern. The app
server exits with signal 11, and Playwright subsequently reports connection
refusals across otherwise unrelated tests and browsers.

This change:

  • Caps PyArrow at <25 until the upstream allocator issue is fixed.
  • Reports the final Python environment after make protobuf, since its uv run
    can update dependencies after the previous environment log.
  • Prints the installed Chromium, Firefox, and WebKit revisions.
  • Reports the exit code and signal when an E2E subprocess dies before teardown.

Upstream issue: apache/arrow#50471

GitHub Issue Link (if applicable)

N/A

Testing Plan

  • Reproduced the crash locally with PyArrow 25.0.0 on Python 3.14: exit code 139.
  • Verified the same reproduction passes with PyArrow 24.0.0.
  • Verified PyArrow 25.0.0 passes with ARROW_DEFAULT_MEMORY_POOL=system.
  • Changed-files Playwright workflow: 334 passed, 8 skipped.
  • Full Playwright workflow with only pyarrow<25: 5809 passed, 233 skipped.
  • Custom-components Playwright workflow passed with only pyarrow<25.
  • make python-lint
  • make python-types
  • Pre-commit hooks

@lukasmasuch lukasmasuch added impact:internal PR changes only affect internal code change:chore PR contains maintenance or housekeeping change labels Jul 12, 2026
@snyk-io

snyk-io Bot commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@github-actions

github-actions Bot commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR preview is ready!

Name Link
📦 Wheel file https://core-previews.s3-us-west-2.amazonaws.com/pr-15947/streamlit-1.58.0-py3-none-any.whl
📦 @streamlit/component-v2-lib Download from artifacts
🕹️ Preview app pr-15947.streamlit.app (☁️ Deploy here if not accessible)

@lukasmasuch
lukasmasuch force-pushed the lukasmasuch/debug-playwright-log-regression branch from 9d754b8 to a1534f5 Compare July 12, 2026 11:41
@lukasmasuch lukasmasuch changed the title [chore] Pin E2E dependency versions [fix] Avoid PyArrow 25 thread initialization crash Jul 12, 2026
@lukasmasuch lukasmasuch added change:bugfix PR contains bug fix implementation impact:users PR changes affect end users and removed impact:internal PR changes only affect internal code change:chore PR contains maintenance or housekeeping change labels Jul 12, 2026
@lukasmasuch
lukasmasuch marked this pull request as ready for review July 12, 2026 13:25
@lukasmasuch
lukasmasuch requested a review from a team as a code owner July 12, 2026 13:25
Copilot AI review requested due to automatic review settings July 12, 2026 13:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@lukasmasuch lukasmasuch added the ai-review If applied to PR or issue will run AI review workflow label Jul 12, 2026
@greptile-apps

greptile-apps Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR works around the PyArrow 25 crash and adds more CI diagnostics. The main changes are:

  • Caps pyarrow below version 25.
  • Moves final Python environment logging after protobuf generation.
  • Prints PyArrow runtime and Playwright browser information in CI.
  • Logs subprocess exit code and signal during E2E teardown.

Confidence Score: 5/5

This looks safe to merge after making the Playwright diagnostic non-fatal.

  • No blocking issues found in the changed code.
  • The only follow-up is a diagnostic command that can fail the setup step even though its output is informational.

.github/actions/playwright_install/action.yml

Important Files Changed

Filename Overview
.github/actions/make_init/action.yml Runs protobuf generation before final environment logging and adds PyArrow runtime diagnostics.
.github/actions/playwright_install/action.yml Adds Playwright dry-run output after browser installation; the diagnostic command should not be allowed to fail setup.
e2e_playwright/conftest.py Adds teardown logging when an E2E subprocess exits before cleanup.
lib/pyproject.toml Adds the pyarrow<25 cap with an upstream crash note.

Reviews (1): Last reviewed commit: "chore: improve e2e environment diagnosti..." | Re-trigger Greptile

python -m playwright install
fi
echo "Installed Playwright browser versions:"
python -m playwright install --dry-run

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Diagnostic Command Can Fail Setup

This dry-run command is only used for logging, but it now runs under the same failing shell step as the browser install. If the pinned Playwright CLI ever returns a nonzero status for install --dry-run in a cache or dependency-check edge case, the action fails after the browsers were already installed successfully.

Suggested change
python -m playwright install --dry-run
python -m playwright install --dry-run || true

@github-actions github-actions Bot removed the ai-review If applied to PR or issue will run AI review workflow label Jul 12, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

This PR fixes a segfault caused by PyArrow 25.0.0's bundled mimalloc 3.3.1 when first imported from a short-lived worker thread (triggered by Streamlit's ScriptRunner). The fix caps PyArrow at <25 in lib/pyproject.toml until the upstream issue (apache/arrow#50471) is resolved.

Additionally, CI diagnostics are improved:

  • The "Show environment info" step is moved after make protobuf so reported dependency versions reflect the final environment state.
  • PyArrow version and memory pool backend are logged.
  • Installed Playwright browser revisions are printed via --dry-run.
  • e2e_playwright/conftest.py now logs process exit code and signal when an app server dies before teardown, aiding future crash diagnosis.

Reviewer consensus: Both reviewers (claude-4.6-opus-high-thinking, gpt-5.3-codex-high) approved unanimously with no blocking issues identified.

Code Quality

All changes are well-structured, minimal, and follow existing patterns:

  • CI workflow changes in composite actions are clear and consistent with the existing action structure.
  • The conftest.py change is surgically placed at the top of terminate() before _stop_process() is called, preserving existing control flow and only adding observability.
  • The pyproject.toml change is well-commented with a reference to the upstream issue.

No structural or maintainability concerns were raised by either reviewer.

Test Coverage

No new unit or E2E tests are added, which both reviewers agree is appropriate for this scope:

  • Dependency version constraints are validated by the pip resolver at install time.
  • CI diagnostics are validated by CI runs themselves.
  • The conftest.py diagnostic print is test infrastructure, not application logic.

The PR description includes successful Playwright workflow runs (5809 passed, 233 skipped) validating the dependency cap change in practice.

Backwards Compatibility

The pyarrow<25 cap is the only user-facing change. It narrows the allowed version range from >=7.0 (unbounded above) to >=7.0,<25.

  • Users on PyArrow 24.x are unaffected.
  • Users who explicitly installed PyArrow 25 will be downgraded by pip when installing/upgrading Streamlit. This is intentional — PyArrow 25 causes crashes.
  • The restriction is temporary and will be relaxed once the upstream fix lands.

No API or behavioral breaking changes.

Security & Risk

No security concerns identified by either reviewer:

  • No new endpoints, auth changes, or network behavior.
  • No new dependencies added.
  • Diagnostic prints only output process metadata (PID, return code, command args) to CI logs — not user secrets or sensitive data.
  • The version pin is a conservative restriction (removing a problematic version), not an expansion of attack surface.

External test recommendation

  • Recommend external_test: No
  • Triggered categories: None
  • Evidence:
    • .github/actions/make_init/action.yml: CI step reordering and additional logging — no runtime behavior changes.
    • .github/actions/playwright_install/action.yml: Adds dry-run info output — no runtime behavior changes.
    • e2e_playwright/conftest.py: Diagnostic print in test infrastructure — no runtime behavior changes.
    • lib/pyproject.toml: Dependency version cap — no routing, auth, embedding, websocket, or asset serving changes.
  • Suggested external_test focus areas: N/A
  • Confidence: High
  • Assumptions and gaps: None. All changes are to CI infrastructure or dependency constraints with no impact on Streamlit's runtime behavior in external/embedded contexts.

Accessibility

No frontend changes. Not applicable.

Recommendations

  1. (Optional) Consider adding a TODO comment in pyproject.toml to explicitly signal when to revisit the <25 cap (e.g., "TODO: Remove once apache/arrow#50471 is fixed in PyArrow 25.0.1+ or 26.0.0"). The current comment references the issue but doesn't signal when to revisit. Both reviewers independently suggested this.

Verdict

APPROVED: Clean, well-scoped fix for a real segfault regression with appropriate CI diagnostics improvements. Both reviewers approved unanimously with no blocking issues.


Consolidated review by claude-4.6-opus-high-thinking from 2 model reviews: claude-4.6-opus-high-thinking, gpt-5.3-codex-high. All expected models completed their reviews successfully.

@sfc-gh-lwilby-1
sfc-gh-lwilby-1 merged commit 5338dab into develop Jul 13, 2026
96 checks passed
@sfc-gh-lwilby-1
sfc-gh-lwilby-1 deleted the lukasmasuch/debug-playwright-log-regression branch July 13, 2026 07:43
github-actions Bot pushed a commit that referenced this pull request Jul 13, 2026
## Describe your changes

PyArrow 25.0.0 bundles mimalloc 3.3.1, which can segfault when the
library is
first loaded on a short-lived worker thread and a later thread performs
an Arrow
allocation. Streamlit's ScriptRunner lifecycle triggers this pattern.
The app
server exits with signal 11, and Playwright subsequently reports
connection
refusals across otherwise unrelated tests and browsers.

This change:

- Caps PyArrow at `<25` until the upstream allocator issue is fixed.
- Reports the final Python environment after `make protobuf`, since its
`uv run`
  can update dependencies after the previous environment log.
- Prints the installed Chromium, Firefox, and WebKit revisions.
- Reports the exit code and signal when an E2E subprocess dies before
teardown.

Upstream issue: apache/arrow#50471

## GitHub Issue Link (if applicable)

N/A

## Testing Plan

- Reproduced the crash locally with PyArrow 25.0.0 on Python 3.14: exit
code 139.
- Verified the same reproduction passes with PyArrow 24.0.0.
- Verified PyArrow 25.0.0 passes with
`ARROW_DEFAULT_MEMORY_POOL=system`.
- Changed-files Playwright workflow: 334 passed, 8 skipped.
- Full Playwright workflow with only `pyarrow<25`: 5809 passed, 233
skipped.
- Custom-components Playwright workflow passed with only `pyarrow<25`.
- `make python-lint`
- `make python-types`
- Pre-commit hooks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:bugfix PR contains bug fix implementation impact:users PR changes affect end users

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants