Skip to content

bug: shared/happy-eyeballs: a failed name lookup reports errno instead of the getaddrinfo error (error code 0 on Linux) #903

Closed

Description

@zackees

Found while characterizing shared/happy-eyeballs for #880.

Location

shared/happy-eyeballs/happy-eyeballs.c, build_addr_list:

int err = getaddrinfo(hostname, port_str.array, &hints, &context->addresses);
...
if (err) {
	context->error = GetSockError();
	context->error_message = strerror(GetSockError());
	return STATUS_FAILURE;
}

getaddrinfo reports failure through its return value (EAI_*), not errno. GetSockError() is errno on POSIX and WSAGetLastError() on Windows.

Class

Logic error: wrong error source.

How it is reached

happy_eyeballs_connect(ctx, "obs-rust-test.invalid", 80) on Linux returns STATUS_FAILURE, but happy_eyeballs_get_error_code(ctx) is 0 and the message is strerror(0) ("Success"). obs-outputs then logs a connect failure whose reason says success. Reproduced in the Tier 2 Linux container.

Proposed fix and failing test

Store err and use gai_strerror(err) (gai_strerrorA on Windows) for the message. Failing test: after an unresolvable lookup, happy_eyeballs_get_error_code is non-zero and the message is not "Success". test_happy_eyeballs (#880) deliberately leaves this unpinned until the fix.

Activity

  1. added
    bug
    on Oct 15, 2026
  2. zackees commented on Oct 15, 2026

    @zackees
    MemberAuthor

    Claiming: fix in one PR, RED (a new cmocka test: after an unresolvable lookup the error code is non-zero and the message is not "Success") then GREEN (store getaddrinfo's result; message from gai_strerror). Lands before the #880 move so the moved code carries the fix.

  3. added
    claimed
    on Oct 15, 2026
  4. added a commit that references this issue on Oct 15, 2026
    477e572
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugclaimed

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions