Skip to content

fix(linux): Harden directory iteration to prevent Wine/Proton crashes#1246

Open
500Byte wants to merge 3 commits into
UE4SS-RE:mainfrom
500Byte:fix-linux-support
Open

fix(linux): Harden directory iteration to prevent Wine/Proton crashes#1246
500Byte wants to merge 3 commits into
UE4SS-RE:mainfrom
500Byte:fix-linux-support

Conversation

@500Byte

@500Byte 500Byte commented May 8, 2026

Copy link
Copy Markdown

What does this PR do?

Introduces stability improvements for users running RE-UE4SS under Linux via Wine/Proton, specifically fixing an infinite recursion crash during directory iteration.

The Problem

When running under Wine/Proton, the Z: drive mapping (which maps the entire Linux root filesystem) can cause std::filesystem::directory_iterator to fall into infinite recursion loops (by aggressively following symlinks or diving infinitely deep into restricted system directories), leading to a hard crash on startup.

The Solution

  • Hardened the iterate_directory lambda in LuaMod.cpp by explicitly skipping symbolic links (item.is_symlink()).
  • Added a recursion depth limit (depth > 7) to completely prevent infinite iteration loops.
  • Simplified and improved the LogicMods path resolution to avoid manually constructing directory paths that often fail under Linux filesystems.
  • Updated README.md to accurately reflect the improved Linux/Proton stability status.

Note: This fix targets users running UE4/5 games under Wine/Proton on Linux, where Wine's Z: drive mapping causes filesystem iteration issues. It is independent of ongoing native Linux build support (#1231).

500Byte added 3 commits May 7, 2026 16:06
Added depth limit and explicit filtering of Wine virtual directories (dosdevices, drive_c, etc) to IterateGameDirectories to prevent BPModLoaderMod from hanging or crashing on Linux environments.

@UE4SS UE4SS left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't like the idea of moving parts of BPModLoaderMod into core UE4SS.
This part of the PR should be removed.

I'm not happy with disallowing symlinks for paths.
It seems more like a workaround than an actual solution.
A better solution might be to check if the canonical path was already iterated.
That would allow the removal of the arbitrary depth limit of 7, and it would also avoid any hard-coded banned paths, while still allowing symlinks.

Comment thread README.md
Comment on lines +76 to +83
## Linux Stability Improvements

RE-UE4SS includes specific hardening for Linux/Proton environments to ensure a smooth experience:

- **Robust Directory Iteration:** Filesystem iterators now skip symbolic links and handle permission errors gracefully, preventing infinite recursion crashes (common with Wine's `Z:` drive mapping).
- **CPU Efficiency:** The async event loop and main update loop use thread-safe atomic flags and proper sleep intervals when paused, eliminating the 100% CPU busy-wait bug.
- **Thread-Safe Hooks:** Hook management uses a synchronized mutex system and safe data capture to prevent data races and Use-After-Free crashes during mod hot-reloading.
- **Improved UTF-8 Support:** Robust path conversion ensures that games installed in directories with non-ASCII characters (accents, CJK, etc.) load correctly.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This doesn't belong in the readme.

@UE4SS

UE4SS commented May 8, 2026

Copy link
Copy Markdown
Collaborator

I don't have any other way of contacting you, so this will have to do.

I know all three of your PRs have been created with AI, and that is provable by the existence of AI files in your repo, though you seem to have force pushed those files away.

As with any work done by AI, my confidence is low, in both the code but also you as a contributor.
How do we know that you're competent ? Can you fix potential problems in your PRs to a satisfactory degree, or are we going to have to play phone with whatever AI provider you use ?

Overall, the ideas for these PRs are mostly good, however, the implementations are not.
I'm also not happy that you didn't mention that your changes were made using AI.
I'm very appreciative of the fact that these PRs are relatively small, it makes life easier for us.

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.

2 participants