Skip to content

fix(pflash): support Windows in DflashClient - #126

Merged
davide221 merged 1 commit into
Luce-Org:mainfrom
phazei:fix/pflash-windows-support
May 8, 2026
Merged

davide221 merged 1 commit into
Luce-Org:mainfrom
phazei:fix/pflash-windows-support

Conversation

@phazei

@phazei phazei commented May 8, 2026

Copy link
Copy Markdown
Contributor

The daemon-spawn path was POSIX-only. Three things break on Windows:

  1. LD_LIBRARY_PATH is meaningless; Windows uses PATH for DLL resolution.
  2. subprocess.Popen(pass_fds=...) is unsupported on Windows.
  3. The child receives the parent file descriptor via --stream-fd, which on Windows must be a Win32 HANDLE (an int-castable handle value), not a CRT fd integer.

Fixes:

  • Add a sys.platform == "win32" branch when extending the loader search path. The else branch is unchanged, so Linux behaviour is byte-identical to before.
  • On Windows, mark the pipe write-end inheritable (os.set_inheritable) and pass msvcrt.get_osfhandle(...) as --stream-fd. The daemon already accepts a HANDLE value here on Windows.
  • On Windows, spawn with close_fds=False so the child inherits the marked handle; on POSIX, keep the existing pass_fds=(self.w_pipe,) path.

The pattern matches the in-process port already used in dflash/scripts/server.py.

The daemon-spawn path was POSIX-only.  Three things break on Windows:

1. `LD_LIBRARY_PATH` is meaningless; Windows uses `PATH` for DLL
   resolution.
2. `subprocess.Popen(pass_fds=...)` is unsupported on Windows.
3. The child receives the parent file descriptor via `--stream-fd`,
   which on Windows must be a Win32 HANDLE (an `int`-castable handle
   value), not a CRT fd integer.

Fixes:

- Add a `sys.platform == "win32"` branch when extending the loader
  search path.  The `else` branch is unchanged, so Linux behaviour is
  byte-identical to before.
- On Windows, mark the pipe write-end inheritable
  (`os.set_inheritable`) and pass `msvcrt.get_osfhandle(...)` as
  `--stream-fd`.  The daemon already accepts a HANDLE value here on
  Windows.
- On Windows, spawn with `close_fds=False` so the child inherits the
  marked handle; on POSIX, keep the existing `pass_fds=(self.w_pipe,)`
  path.

The pattern matches the in-process port already used in
`dflash/scripts/server.py`.

@cubic-dev-ai cubic-dev-ai 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.

1 issue found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="pflash/pflash/dflash_client.py">

<violation number="1" location="pflash/pflash/dflash_client.py:68">
P1: Windows HANDLE values are passed through `--stream-fd` but the daemon still parses them into a 32-bit `int`, so the handle can be truncated on 64-bit Windows and break IPC.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread pflash/pflash/dflash_client.py Resolved
@davide221

davide221 commented May 8, 2026 •

Copy link
Copy Markdown
Contributor

@phazei please check Cubic. P0 and P1 need review

@phazei

phazei commented May 8, 2026

Copy link
Copy Markdown
Contributor Author

please check Cubic. P0 and P1 need review

I replied to the comments, I don't believe any changes are necessary.

@davide221
davide221 merged commit 54b6178 into Luce-Org:main May 8, 2026
1 check passed
smpurkis pushed a commit to smpurkis/lucebox-hub that referenced this pull request May 10, 2026
fix(pflash): support Windows in DflashClient
oliveagle pushed a commit to oliveagle/lucebox-hub that referenced this pull request May 22, 2026
fix(pflash): support Windows in DflashClient
oliveagle pushed a commit to oliveagle/lucebox-hub that referenced this pull request May 22, 2026
fix(pflash): support Windows in DflashClient
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