Skip to content

Fix tcpflood crash detection during RELP TLS tests#149

Open
rgerhards wants to merge 1 commit intomainfrom
codex/analyze-tcpflood-test-failure
Open

Fix tcpflood crash detection during RELP TLS tests#149
rgerhards wants to merge 1 commit intomainfrom
codex/analyze-tcpflood-test-failure

Conversation

@rgerhards
Copy link
Owner

Summary

  • treat tcpflood signal exits as fatal even in --check-only mode so tests fail when the generator crashes without leaving a core file
  • ensure tcpflood aborts cleanly after RELP connection setup failures by cleaning up the client handle and propagating the error across worker threads

Testing

  • make -C tests tcpflood
  • ./tests/imrelp-tls-cfgcmd.sh (fails: imrelp/imdiag plugins not built in this configuration)

https://chatgpt.com/codex/tasks/task_e_6905f1c160608332b12889717631addb

* treat tcpflood signal exits as fatal so the harness fails tests even when no core file is written.\n* ensure tcpflood stops sending after RELP connection setup errors by cleaning up the client handle and propagating the failure across worker threads.\n\nAI-Agent: Codex
@gemini-code-assist
Copy link

Summary of Changes

Hello @rgerhards, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the robustness of tcpflood tests, particularly in RELP TLS scenarios. It ensures that tcpflood crashes are reliably detected and cause test failures, rather than being silently ignored. Additionally, it improves resource management by ensuring RELP client handles are properly cleaned up upon connection failures and propagates connection errors across worker threads to the main test process, leading to more accurate and reliable test outcomes.

Highlights

  • Improved Crash Detection: The tcpflood test utility now treats signal-induced exits as fatal errors, even when running in --check-only mode. This ensures that tests fail appropriately if tcpflood crashes without leaving a core file, providing more robust test results.
  • Clean RELP Client Handle Cleanup: When a RELP connection setup fails, the tcpflood utility now properly cleans up the RELP client handle by calling relpEngineCltDestruct. This prevents resource leaks and ensures a cleaner shutdown process.
  • Enhanced Error Propagation: A new mechanism has been implemented to propagate connection opening failures from worker threads back to the main openConnections function. This ensures that if any worker thread encounters a connection error, the overall openConnections function correctly reports failure, preventing silent errors in multi-threaded scenarios.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces two important fixes. First, it correctly detects tcpflood crashes from signals during tests, making the test suite more robust. Second, it fixes a resource leak in tcpflood's RELP connection handling and ensures that connection failures in worker threads are properly propagated, preventing tests from silently succeeding when they should fail. The changes in tcpflood.c are solid. In diag.sh, the error handling logic is correct, but could be refactored to reduce code duplication, which I've suggested.

Comment on lines +1997 to +2013
if [ "$res" -ge 128 ]; then
sig=$(( res - 128 ))
echo "tcpflood terminated by signal ${sig} on port ${TCPFLOOD_PORT}!"
if [ -f "${RSYSLOG_OUT_LOG}" ]; then
cp "${RSYSLOG_OUT_LOG}" "${RSYSLOG_OUT_LOG}.save"
fi
error_exit 1 stacktrace
fi
if [ "$check_only" == "yes" ]; then
echo "error during tcpflood on port ${TCPFLOOD_PORT}! But test continues..."
return 0
fi
echo "error during tcpflood on port ${TCPFLOOD_PORT}! see ${RSYSLOG_OUT_LOG}.save for what was written"
if [ -f "${RSYSLOG_OUT_LOG}" ]; then
cp "${RSYSLOG_OUT_LOG}" "${RSYSLOG_OUT_LOG}.save"
fi
error_exit 1 stacktrace

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The error handling logic here is correct, but there's some code duplication in how errors are reported and handled. The cp command and error_exit call are repeated. This can be refactored to make the code cleaner and easier to maintain.

Suggested change
if [ "$res" -ge 128 ]; then
sig=$(( res - 128 ))
echo "tcpflood terminated by signal ${sig} on port ${TCPFLOOD_PORT}!"
if [ -f "${RSYSLOG_OUT_LOG}" ]; then
cp "${RSYSLOG_OUT_LOG}" "${RSYSLOG_OUT_LOG}.save"
fi
error_exit 1 stacktrace
fi
if [ "$check_only" == "yes" ]; then
echo "error during tcpflood on port ${TCPFLOOD_PORT}! But test continues..."
return 0
fi
echo "error during tcpflood on port ${TCPFLOOD_PORT}! see ${RSYSLOG_OUT_LOG}.save for what was written"
if [ -f "${RSYSLOG_OUT_LOG}" ]; then
cp "${RSYSLOG_OUT_LOG}" "${RSYSLOG_OUT_LOG}.save"
fi
error_exit 1 stacktrace
if [ "$check_only" == "yes" ] && [ "$res" -lt 128 ]; then
echo "error during tcpflood on port ${TCPFLOOD_PORT}! But test continues..."
return 0
fi
if [ "$res" -ge 128 ]; then
sig=$(( res - 128 ))
echo "tcpflood terminated by signal ${sig} on port ${TCPFLOOD_PORT}!"
else
echo "error during tcpflood on port ${TCPFLOOD_PORT}! see ${RSYSLOG_OUT_LOG}.save for what was written"
fi
if [ -f "${RSYSLOG_OUT_LOG}" ]; then
cp "${RSYSLOG_OUT_LOG}" "${RSYSLOG_OUT_LOG}.save"
fi
error_exit 1 stacktrace

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant