[nginx] Fix valgrind errors in mail tests
Maxim Dounin
mdounin at mdounin.ru
Wed May 15 06:06:06 UTC 2024
Hello!
On Mon, May 13, 2024 at 03:43:58PM +1000, Robert Mueller wrote:
> # HG changeset patch
> # User Rob Mueller <robm at fastmailteam.com>
> Fix valgrind errors in mail tests
>
> Applying this fix allows nginx to be run under valgrind and all
> mail_* tests to pass with no valgrand issues detected
> ---
> src/event/modules/ngx_epoll_module.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/src/event/modules/ngx_epoll_module.c b/src/event/modules/ngx_epoll_module.c
> index 98e3ce7c8..c89a56d95 100644
> --- a/src/event/modules/ngx_epoll_module.c
> +++ b/src/event/modules/ngx_epoll_module.c
> @@ -474,6 +474,7 @@ ngx_epoll_test_rdhup(ngx_cycle_t *cycle)
> }
>
> ee.events = EPOLLET|EPOLLIN|EPOLLRDHUP;
> + ee.data.u64 = 0;
>
> if (epoll_ctl(ep, EPOLL_CTL_ADD, s[0], &ee) == -1) {
> ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
There were reports about similar complaints from Valgrind on
32-bit platforms a while ago, but for normal epoll_ctl() calls,
where only data.ptr is set:
https://mailman.nginx.org/pipermail/nginx-devel/2013-July/003892.html
Given this is a hot path, and there are multiple such calls,
suggested approach was to do additional unneeded initialization
only if NGX_VALGRIND is defined (which is already used to ignore
sigaction() results under Valgrind, see 5244:593d344999f5). This
was never implemented though.
Still, I cannot reproduce it with recent Valgrind versions. It
looks like it is fixed in the Valgrind itself, and now it only
checks ee.events, but not ee.data and padding:
https://bugs.kde.org/show_bug.cgi?id=422623
The fix is available starting with Valgrind 4.17.0, which is not
exactly new. In particular, the only supported Ubuntu version
without the fix is 20.04 LTS, while Ubuntu 22.04 LTS packages
contain Valgrind 3.18.0, with the fix.
OTOH, I'm not really seeing this on Ubuntu 20.04 LTS / amd64 with
Valgrind 3.15.0 either, not sure why, probably due to some code
generation nuances. But on Ubuntu 20.04 LTS I'm seeing another
Valgrind bug ("Source and destination overlap in memcpy_chk()" for
memmove(), https://bugs.kde.org/show_bug.cgi?id=402833).
I was only able to reproduce this on Ubuntu 18.04 / i386 (with
Valgrind 3.13.0, along with complaints about normal epoll_ctl()
calls.
Overall, this patch is probably no longer needed, as the proper
fix is already in Valgrind, and there are other bugs in old
Valgrind versions anyway.
--
Maxim Dounin
http://mdounin.ru/
More information about the nginx-devel
mailing list