Skip to content

[#691] Fix stack overflow in test_connection_bind_unix_socket - #692

Merged
Pranav-error merged 1 commit into
pgexporter:mainfrom
ahmedmmordi:fix-connection-test
Dec 1, 2026
Merged

Pranav-error merged 1 commit into
pgexporter:mainfrom
ahmedmmordi:fix-connection-test

Conversation

@ahmedmmordi

Copy link
Copy Markdown
Contributor

Allocated test_config on the heap and added free(test_config) in cleanup

Closes #691

@ahmedmmordi

Copy link
Copy Markdown
Contributor Author

@jesperpedersen PTAL

@Pranav-error Pranav-error 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.

Looks good. struct configuration is about 26.7 MB here (sizeof on this PR's headers, macOS arm64), well above the default 8 MB stack, so moving it to the heap is the right fix. These two tests were the only places that put it on the stack; the other copy in tscommon.c is static.

One small thing, not blocking: in test_connection_bind_unix_socket_permissions, if calloc fails we go to cleanup before sock_path is set, so unlink(sock_path) reads an uninitialized buffer. The mkdtemp failure path already had the same problem. Moving the memset(sock_path, ...) to the top of the test fixes both.

@ahmedmmordi

Copy link
Copy Markdown
Contributor Author

One small thing, not blocking: in test_connection_bind_unix_socket_permissions, if calloc fails we go to cleanup before sock_path is set, so unlink(sock_path) reads an uninitialized buffer. The mkdtemp failure path already had the same problem. Moving the memset(sock_path, ...) to the top of the test fixes both.

@Pranav-error Good catch. Moved it to the top. PTAL

@Pranav-error

Copy link
Copy Markdown
Collaborator

Re-checked at 5f01c2f: struct configuration is 26.7 MB here (8 MB stack), and on main -t test_connection_bind_unix_socket segfaults (exit 139); with this PR both tests pass. Looks good to me.

@Pranav-error
Pranav-error merged commit 801d41c into pgexporter:main Dec 1, 2026
8 checks passed
@ahmedmmordi
ahmedmmordi deleted the fix-connection-test branch December 2, 2026 15:05
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.

CI Fail: Stack overflow in test_connection_bind_unix_socket_permissions

2 participants