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

dummyfs: memory-related fixes #44

Merged
merged 2 commits into from
Aug 19, 2021
Merged

Conversation

nalajcie
Copy link
Member

@nalajcie nalajcie commented Aug 19, 2021

Description

  • dummyfs: fix memory leaks
    • deleted dirents for dummyfs root dir were never freed
    • fixed memory leaks in error paths
    • fixed ERRNO value
  • dummyfs: fix realloc() usage
    Also: remove unneeded chunk properly.

Motivation and Context

Fixes phoenix-rtos/phoenix-rtos-project#169

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

How Has This Been Tested?

  • Already covered by automatic testing.
  • New test added: (add PR link here).
  • Tested by hand on: imx6ull.

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing linter checks and tests passed.
  • My changes generate no new compilation warnings for any of the targets.

Special treatment

  • This PR needs additional PRs to work (list the PRs, preferably in merge-order).
  • I will merge this PR by myself when appropriate.

Also: remove unneeded chunk properly.

Fixes phoenix-rtos/phoenix-rtos-project#169
- deleted dirents for dummyfs root dir were never freed
 - fixed memory leaks in error paths
 - fixed ERRNO value

Related to phoenix-rtos/phoenix-rtos-project#169
@@ -35,6 +35,8 @@ int dir_find(dummyfs_object_t *dir, const char *name, oid_t *res)
if (e == NULL)
return -ENOENT;

dirname = strdup(name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still no check for ENOMEM

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think dummyfs needs some careful review. I believe the current approach (always trying to realloc chunks) may result in performance slowdowns (hidden memcpy in realloc implementation).

Also - we need at least some basic functionality checks for file systems (this error was triggered every time a file was truncated to 0 - so for example deleted). Unfortunately we can't test dummyfs on ia32-generic due to phoenix-rtos/phoenix-rtos-project#114)

Copy link
Member

@agkaminski agkaminski Aug 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I think that dummyfs makes writes at NULL pointer on NOMMU targers - we found traces of it only when dummyfs has been started...

@nalajcie nalajcie merged commit cb29b1e into master Aug 19, 2021
@nalajcie nalajcie deleted the nalajcie/dummyfs_fix_realloc branch August 19, 2021 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dummyfs exception when truncating file to 0
2 participants