Copilot commented on code in PR #3599:
URL: https://github.com/apache/brpc/pull/3599#discussion_r4248019440


##########
test/run_tests.sh:
##########
@@ -46,6 +46,17 @@ if [ $test_num -eq 0 ]; then
 fi
 
 print_bt () {
+    case "${2-}" in
+        ''|*[!0-9]*) return ;;
+    esac
+    # Assertion failures exit normally. A passing death test may have left a
+    # core in this binary, so only consider statuses that can represent a 
signal.
+    if [ "$2" -le 128 ] || [ "$2" -gt 255 ]; then
+        return
+    fi
+    if ! kill -l "$2" >/dev/null 2>&1; then

Review Comment:
   `"$2"` here is an *exit status* (typically `128 + signum` for signal 
termination), but `kill -l <n>` expects a *signal number* (e.g., `11` for 
SIGSEGV). As written, `kill -l 139` will usually fail, causing `print_bt` to 
return early and suppress backtraces even on real signal crashes. Convert the 
exit status to a signal number before validating/printing (e.g., compute 
`signum = rc - 128`, validate that, then proceed).



##########
test/endpoint_unittest.cpp:
##########
@@ -16,19 +16,27 @@
 // under the License.
 
 #include <gtest/gtest.h>
+#include <atomic>
+#include <pthread.h>
+#include <signal.h>
 #include <butil/fd_guard.h>
 #include <butil/fd_utility.h>
 #include "butil/errno.h"
 #include "butil/endpoint.h"
 #include "butil/logging.h"
+#include "butil/memory/scope_guard.h"
 #include "butil/containers/flat_map.h"
 #include "butil/details/extended_endpoint.hpp"
 #include <netinet/tcp.h>
-#if defined(OS_MACOSX)
+#if defined(OS_LINUX)
+#include <sys/epoll.h>
+#elif defined(OS_MACOSX)
+#include <sys/event.h>
 #include <netinet/tcp_fsm.h>
 #endif
 
 namespace butil {
+int pthread_fd_wait(int fd, unsigned events, const timespec* abstime);

Review Comment:
   This introduces a local forward declaration of `butil::pthread_fd_wait`. If 
the real function signature differs across platforms/versions (e.g., `events` 
type), this can lead to link errors or subtle mismatches. Prefer including the 
header that declares `pthread_fd_wait` (or exposing a stable declaration) 
rather than re-declaring it in the test.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to