Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable OpenSSL QtNetwork backend to avoid Windows crash #723

Merged

Conversation

jonathanperret
Copy link
Contributor

@jonathanperret jonathanperret commented Oct 31, 2024

Problem

Fixes #720.

Proposed solution

With the help of @Adrienne200 I tracked the crash down to an incorrect OpenSSL DLL being loaded in the AYAB process: instead of the libssl-3-x64.dll library bundled with AYAB, the library (on one crashing computer) was being loaded from C:\Program Files\HP\HP One Agent\libssl-3-x64.dll!

The reason for the bundled library not being loaded is a PyInstaller bug that I reported: pyinstaller/pyinstaller#8857

We won't need to wait for the fix to PyInstaller though, because in this PR I opted to entirely remove the affected Qt plugin (the OpenSSL-backed QtNetwork backend), as suggested in the Qt documentation when OpenSSL-specific features are not needed: https://doc.qt.io/qt-6/ssl.html#considerations-while-packaging-your-application

Testing

I created a test release from this PR's head commit: https://github.com/jonathanperret/ayab-desktop/releases/tag/0.99.2-wincrash4

Summary by CodeRabbit

  • New Features

    • Added support for creating AppImages for Linux, including steps for dependency installation and metadata configuration.
    • Enhanced version checking with improved logging and error handling.
  • Bug Fixes

    • Refined handling of OpenSSL dependencies on Windows to prevent packaging issues.
  • Chores

    • Optimized build process by retaining caching mechanisms for various files across jobs.

Copy link
Contributor

coderabbitai bot commented Oct 31, 2024

Walkthrough

The pull request introduces modifications to the GitHub Actions workflow and the VersionChecker class. In the workflow, a new step is added to remove the OpenSSL QtNetwork backend for Windows builds, and the build-appimage job is enhanced to create AppImages for Linux. The VersionChecker class now features improved logging, better error handling, and automatic deletion of network replies. These changes aim to refine the build process and enhance version checking functionality.

Changes

File Change Summary
.github/workflows/build-multi-os.yml Added step to remove OpenSSL QtNetwork backend in build-windows. Updated build-appimage for AppImage creation.
src/main/python/main/ayab/version_checker.py Enhanced logging in VersionChecker, improved network request handling, and modified error handling.

Assessment against linked issues

Objective Addressed Explanation
Fix crash on launch for Windows Beta2 build (#720) The changes do not directly address the crash issue reported.

Possibly related PRs

Suggested reviewers

  • dl1com

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@jonathanperret jonathanperret requested a review from dl1com October 31, 2024 11:20
The Qt docs warn against deleting a QNetworkReply while the
`finished` handler is running (https://doc.qt.io/qt-6/qnetworkreply.html).

We're not explicitly deleting it here, just setting the Python reference
to `None`, but that might be enough to cause the object to be
destroyed, explaining the crash we're seeing on Windows.

Instead we set the option on QNetworkAccessManager to auto-delete
replies.
This is to work around a bug in PyInstaller that
can cause the wrong DLLs to be loaded, leading
to a crash.
@jonathanperret jonathanperret force-pushed the fix-windows-start-crash branch from 91cfdca to 6ea9698 Compare October 31, 2024 11:21
Copy link

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
src/main/python/main/ayab/version_checker.py (1)

Line range hint 1-99: Consider adding fallback mechanisms for version checking

Given that this PR disables the OpenSSL backend, which could potentially affect network functionality, consider:

  1. Implementing a retry mechanism with exponential backoff for failed requests
  2. Adding an alternative version check method (e.g., local cache, different API endpoint) as fallback
  3. Making the version check more resilient to network backend changes

This would improve the robustness of the version checking system across different configurations.

.github/workflows/build-multi-os.yml (1)

271-286: LGTM! Well-documented solution to the OpenSSL backend issue.

The implementation follows Qt's recommended approach for handling OpenSSL dependencies. The detailed comments explain the rationale and link to relevant documentation, making future maintenance easier.

Consider adding a comment with the PyInstaller issue link (pyinstaller/pyinstaller#8857) to help track when this workaround can be removed once PyInstaller fixes the underlying issue.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b9483a7 and 6ea9698.

📒 Files selected for processing (2)
  • .github/workflows/build-multi-os.yml (1 hunks)
  • src/main/python/main/ayab/version_checker.py (4 hunks)
🔇 Additional comments (5)
src/main/python/main/ayab/version_checker.py (4)

54-62: LGTM! Enhanced error diagnostics

The additional logging of HTTP status and response length will help diagnose network-related issues, particularly useful for tracking down connectivity problems.


76-84: LGTM! Improved code clarity

The restructured conditionals and additional logging enhance code readability and debugging capabilities.


99-99: LGTM! Proper resource cleanup

The cleanup logging is helpful, and the removal of explicit reply cleanup is correct since setAutoDeleteReplies(True) handles this automatically.


22-30: Verify compatibility with disabled OpenSSL backend

While the changes improve logging and memory management, we need to ensure this network code works when the OpenSSL QtNetwork backend is disabled.

.github/workflows/build-multi-os.yml (1)

271-286: Verify SSL functionality with native Windows backend.

While the solution elegantly resolves the crash by using Windows' native SSL implementation, it's important to verify that all SSL-related functionality works correctly with the native backend.

Run this script to identify SSL-dependent code that might be affected:

✅ Verification successful

Based on the search results, I can now generate a final response as we have sufficient information about the SSL usage in the codebase.

SSL functionality change appears safe with Windows native backend

The codebase's only SSL-dependent network functionality is in version_checker.py, which performs HTTPS requests to check for updates. The Windows native SSL backend (schannel) is a mature and well-tested component that fully supports modern HTTPS, making this change safe.

  • The only Qt network classes used are QNetworkAccessManager and QNetworkRequest in version_checker.py
  • No direct SSL socket manipulation or custom SSL configurations are present
  • All HTTPS URLs found are for standard web requests that are fully supported by Windows' native SSL stack
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for SSL/HTTPS related network calls
echo "Searching for SSL/HTTPS related code..."
rg -l 'https://' || true
rg -l 'QSslSocket|QSslConfiguration' || true

# Search for Qt network functionality that might use SSL
echo "Searching for Qt network functionality..."
ast-grep --pattern 'QNetworkAccessManager' || true
ast-grep --pattern 'QNetworkRequest' || true

Length of output: 2934

@dl1com dl1com merged commit 0583fe4 into AllYarnsAreBeautiful:main Oct 31, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] On Windows, the Beta2 release build crashes on launch.
2 participants