Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memory leak using udp #270

Open
riweirui opened this issue Feb 6, 2023 · 2 comments
Open

memory leak using udp #270

riweirui opened this issue Feb 6, 2023 · 2 comments

Comments

@riweirui
Copy link

riweirui commented Feb 6, 2023

When using udp protocol to read and write data, nfs-ganesha received KILL signal
View dmsge, the memory usage is too high and KILL

version V3.5

kernel
3.10.0-957.el7.x86_64

The following information can be found through the valgrind
16,568,600 (142,080 direct, 16,426,520 indirect) bytes in 1,110 blocks are definitely lost in loss record 2,128 of 2,129
==12775== at 0x4C2C089: calloc (vg_replace_malloc.c:762)
==12775== by 0x4F7A602: nfs3_readdirplus (nfs3_readdirplus.c:354)
==12775== by 0x4E902F5: nfs_rpc_process_request (nfs_worker_thread.c:1509)
==12775== by 0x4E9064F: nfs_rpc_valid_NFS (nfs_worker_thread.c:1636)
==12775== by 0x4FD6F2D: svc_dg_decode (svc_dg.c:362)
==12775== by 0x4FDAFC9: svc_request (svc_rqst.c:1202)
==12775== by 0x4FD6DED: svc_dg_recv (svc_dg.c:329)
==12775== by 0x4E91218: nfs_rpc_dispatch_udp_NFS (nfs_rpc_dispatcher_thread.c:279)
==12775== by 0x4FD6DC5: svc_dg_rendezvous (svc_dg.c:318)
==12775== by 0x4FDAF4A: svc_rqst_xprt_task_recv (svc_rqst.c:1183)
==12775== by 0x4FDBADE: svc_rqst_epoll_loop (svc_rqst.c:1564)
==12775== by 0x4FE5875: work_pool_thread (work_pool.c:183)

This problem appears to be caused by an update udp readdir bug
nfs-ganesha/nfs-ganesha#718

I think I found the issue,
The issue is at xdr_mem.c
The code
if (!(--uio->uio_references)) {
if (uio->uio_release) {
uio->uio_release(uio, UIO_FLAG_NONE);
} else {
__warnx(TIRPC_DEBUG_FLAG_ERROR,
"%s() memory leak, unexpected or no release flags (%u)\n",
func, uio->uio_flags);
abort();
}
}

my modification suggestion

if (uio->uio_references == 0) {
uio->uio_references = 1;
}
//fixbug memory leak
//if (!(--uio->uio_references)) {
if (uio->uio_release) {
uio->uio_release(uio, UIO_FLAG_NONE);
} else {
__warnx(TIRPC_DEBUG_FLAG_ERROR,
"%s() memory leak, unexpected or no release flags (%u)\n",
func, uio->uio_flags);
abort();
}
//}

After the modification, the bug of memory leak was solved, and no new problems were found in the test for a week

@chengmao2010
Copy link

I have the same problem on V3.5,any suggestions is welcome

@ffilz
Copy link
Member

ffilz commented Nov 9, 2023

There is a pull request: #271

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

No branches or pull requests

3 participants