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

[Bug] dfs_v2打开pagecache,运行elf后会存在memleak #9900

Open
wycwyhwyq opened this issue Jan 9, 2025 · 4 comments
Open

[Bug] dfs_v2打开pagecache,运行elf后会存在memleak #9900

wycwyhwyq opened this issue Jan 9, 2025 · 4 comments
Labels
BSP: K230 BSP related with K230

Comments

@wycwyhwyq
Copy link
Contributor

RT-Thread Version

53bd56c

Hardware Type/Architectures

risc-v/K230

Develop Toolchain

GCC

Describe the bug

  1. dfs_v2打开pagecache,运行任意elf后,通过free对比运行前后发现存在memleak

Other additional context

定位到具体位置有两处:

  1. 加载elf文件时对应的struct dfs_file *file结构未释放,原因为elf map时会增加file->ref_count,导致执行close->fd_release->fdt_fd_releasefile->ref_count不等于1,未能正常释放
  2. 用户程序退出时会执行lwp_exit->_clear_child_tid->sys_futex,此处是个share futex,不会被删除

对于share futex,还有一个疑问,对于没有进程使用的futex似乎没有删除操作?

@polarvid
Copy link
Contributor

share futex 设计时有 lazy 任务定期清理。不过由于 libc 的设计算法,整个系统生命周期中它的 footpirnt 基本上和 tick 形成 O(1) 增长关系。所以这个研发任务定为”必要不紧急“。因为重要任务很多,所以搁置了。如果题主有兴趣可以 PR 补充。

@BernardXiong
Copy link
Member

share futex 设计时有 lazy 任务定期清理。不过由于 libc 的设计算法,整个系统生命周期中它的 footpirnt 基本上和 tick 形成 O(1) 增长关系。所以这个研发任务定为”必要不紧急“。因为重要任务很多,所以搁置了。如果题主有兴趣可以 PR 补充。

是否可以简单展开说明下?

@heyuanjie87
Copy link
Contributor

确实存在内存泄漏

  1. 打印执行文件时创建的file指针
    image

  2. 打印rt_free的指针
    image

  3. 在程序退出时输出的日志中查找file指针,只有一条
    image

@Rbb666
Copy link
Member

Rbb666 commented Jan 17, 2025

关联:#9917

@Rbb666 Rbb666 added the BSP: K230 BSP related with K230 label Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BSP: K230 BSP related with K230
Projects
None yet
Development

No branches or pull requests

5 participants