Skip to content

Fix expandTilde: use getpwnam_r return value instead of errno - #11150

Merged
thewilsonator merged 1 commit into
dlang:masterfrom
dkorpel:fix-expandtilde-errno
Nov 11, 2026
Merged

thewilsonator merged 1 commit into
dlang:masterfrom
dkorpel:fix-expandtilde-errno

Conversation

@dkorpel

@dkorpel dkorpel commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Closes #11151

Blocks dlang/dmd#24274

POSIX reports the error through the return value, superseding the unreliable errno checking (falling through to onOutOfMemoryError() on macOS 15).

This PR was written entirely by an LLM/AI.

POSIX reports the error through the return value. On macOS 15 errno is not
ERANGE when the buffer is too small, which was reported as an
OutOfMemoryError.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@CyberShadow

Copy link
Copy Markdown
Member

Diff LGTM but I don't understand this in the commit message:

POSIX reports the error through the return value

Is getpwnam_r POSIX and getpwnam not?

@0xEAB 0xEAB added Severity:Bug Fix Review:AI Generated Code that is generated by an LLM AI — or suspected to be. labels Nov 11, 2026
@0xEAB

0xEAB commented Nov 11, 2026

Copy link
Copy Markdown
Member

@dkorpel
Mind opening an issue to reference or adding a changelog entry?

@dkorpel

dkorpel commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

Done

@thewilsonator
thewilsonator merged commit 3de9bd8 into dlang:master Nov 11, 2026
7 of 9 checks passed
@dkorpel
dkorpel deleted the fix-expandtilde-errno branch November 11, 2026 12:20
@dkorpel

dkorpel commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

Is getpwnam_r POSIX and getpwnam not?

According to POSIX, getpwnam_r returns the error instead of setting errno, but Phobos checks errno as if it called getpwnam_r. Presumably linux implementations still set errno to the returned value in that variant (or 0, see deleted workaround comment), but that's an unspecified side effect Phobos relied on, which changed in Macos 15.

@CyberShadow

Copy link
Copy Markdown
Member

Yeah, that part is clear. I was just confused by that sentence in that commit message, i.e. why it said "POSIX reports".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review:AI Generated Code that is generated by an LLM AI — or suspected to be. Review:Blocking Other Work Severity:Bug Fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

expandTilde checks errno instead of return value, failing on macos15

4 participants