ntirpc icon indicating copy to clipboard operation
ntirpc copied to clipboard

memory leak using udp

Open riweirui opened this issue 2 years ago • 2 comments

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 https://github.com/nfs-ganesha/nfs-ganesha/issues/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

riweirui avatar Feb 06 '23 11:02 riweirui

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

chengmao2010 avatar Nov 09 '23 03:11 chengmao2010

There is a pull request: #271

ffilz avatar Nov 09 '23 15:11 ffilz