[Git][ghc/ghc][wip/io-manager-deadlock-detection] DEBUG: attempts to debug wasm poll failures
Duncan Coutts pushed to branch wip/io-manager-deadlock-detection at Glasgow Haskell Compiler / GHC Commits: 7b991089 by Duncan Coutts at 2026-08-30T13:18:58+01:00 DEBUG: attempts to debug wasm poll failures - - - - - 1 changed file: - rts/posix/Poll.c Changes: ===================================== rts/posix/Poll.c ===================================== @@ -38,6 +38,10 @@ #include <signal.h> #include <poll.h> #endif +#if defined(HAVE_UNISTD_H) +#include <unistd.h> +#endif + #include "IOManagerInternals.h" #include "Timeout.h" @@ -424,13 +428,13 @@ void pollCompletedTimeoutsOrIOPoll(CapIOManager *iomgr) int res = ppoll(poll_table, nfds, &tv, NULL); debugTrace(DEBUG_iomanager, - "ppoll(nfds = %d, timeout.sec = 0, timeout.nsec = 0) = %d", + "ppoll(nfds = %lu, timeout.sec = 0, timeout.nsec = 0) = %d", nfds, res); #else int res = poll(poll_table, nfds, 0); debugTrace(DEBUG_iomanager, - "poll(nfds = %d, timeout_ms = 0) = %d", + "poll(nfds = %lu, timeout_ms = 0) = %d", nfds, res); #endif if (res == 0) { @@ -510,15 +514,30 @@ bool awaitCompletedTimeoutsOrIOPoll(CapIOManager *iomgr) int res = ppoll(poll_table, nfds, timeout_ns, NULL); debugTrace(DEBUG_iomanager, - "ppoll(nfds = %d, timeout.sec = %d, timeout.nsec = %d) = %d", + "ppoll(nfds = %lu, timeout.sec = %d, timeout.nsec = %d) = %d", nfds, timeout_ns == NULL ? -1 : timeout_ns->tv_sec, timeout_ns == NULL ? 0 : timeout_ns->tv_nsec, res); +#elif defined(wasm32_HOST_ARCH) + /* Debug hack: on wasm CI we observe failures like + * T5866: poll res = -1: Not supported + * We want to get more detail. + */ + int res = poll(poll_table, nfds, timeout_ms); + if (res < 0) { + if (errno == ENOTSUP && nfds == 0 && timeout_ms == -1) { + pause(); + } else { + sysErrorBelch("poll res = %d, errno = %d (ENOTSUP == %d), nfds = %lu, timeout_ms = %d", + res, errno, ENOTSUP, nfds, timeout_ms); + stg_exit(EXIT_FAILURE); + } + } #else int res = poll(poll_table, nfds, timeout_ms); debugTrace(DEBUG_iomanager, - "poll(nfds = %d, timeout_ms = %d) = %d", + "poll(nfds = %lu, timeout_ms = %d) = %d", nfds, timeout_ms, res); #endif @@ -579,7 +598,8 @@ static void reportPollError(int res, nfds_t nfds) // as soon as we get thread submitting an operation that would exceed // the limit. } else { - sysErrorBelch("poll res = %d", res); + sysErrorBelch("poll res = %d, errno = %d, nfds = %lu ", + res, errno, (unsigned long) nfds); stg_exit(EXIT_FAILURE); } } View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7b99108940a6eba52960363634ddb489... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/7b99108940a6eba52960363634ddb489... You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
participants (1)
-
Duncan Coutts (@dcoutts)