Skip to content

fix divide by zero when upsync host resolves to no IPv4 address - #329

Merged
gfrankliu merged 1 commit into
masterfrom
fix-divide-by-zero-ipv6-only
Oct 15, 2026
Merged

gfrankliu merged 1 commit into
masterfrom
fix-divide-by-zero-ipv6-only

Conversation

@gfrankliu

Copy link
Copy Markdown
Collaborator

ngx_http_upsync_init_server() counts only AF_INET results from getaddrinfo() and then picks one with ngx_random() % n. If the upsync host resolves only to IPv6 (AAAA) addresses, n is 0 and the worker crashes with SIGFPE (signal 8) on every sync attempt.

This falls back to the address resolved at config time (goto valid), the same path already used when getaddrinfo() fails. IPv6 support for the upsync connection itself is still out of scope (see #216).

ngx_http_upsync_init_server() counts only AF_INET results from
getaddrinfo() and then picks one with ngx_random() % n. If the
host resolves only to IPv6 (AAAA) addresses, n is 0 and the worker
crashes with SIGFPE on every sync attempt. Fall back to the
configured address instead, as is already done when getaddrinfo()
fails.
@xiaokai-wang

Copy link
Copy Markdown
Member

wow, do you still use the module? @gfrankliu

@gfrankliu

Copy link
Copy Markdown
Collaborator Author

Some old systems are still running

@xiaokai-wang xiaokai-wang self-assigned this Oct 14, 2026
@gfrankliu
gfrankliu merged commit 46264eb into master Oct 15, 2026
2 of 4 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.

2 participants