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

Improve Error Handling to Prevent Exit, Crashes and Memory Leaks #1929

Open
wants to merge 40 commits into
base: main
Choose a base branch
from

Conversation

songlingatpan
Copy link

This PR focuses on improving the robustness and stability of the code by enhancing error handling. The main objectives of this update include:

  • Preventing the program from exiting or crashing in case of errors
  • Preventing memory leaks by checking for NULL pointers after memory allocations and ensuring proper memory cleanup in failure cases.
  • Adding safeguards for potential memory allocation issues, ensuring the program doesn't crash or exit unexpectedly.

Note: This PR does not introduce any new functionality but aims to stabilize the existing code and make it more resilient to errors. Future test cases will be added to simulate scenarios such as out-of-memory conditions and ensure these improvements work as intended.

@songlingatpan
Copy link
Author

This PR depends on #1823. Since the changes from #1823 have not been merged yet, I have cherry-picked those commits into this PR. Once #1823 is merged, I will rebase this PR on top of the main branch to ensure a clean merge.

@baentsch
Copy link
Member

@songlingatpan Thanks for the various enhancements. I now triggered a more complete CI run. Do you expect to do further commits or is this now indeed Ready for Review from your perspective?

return NULL;
}
uint8_t *ptr = (uint8_t *)(((uintptr_t)(buffer) + offset) & ~(alignment - 1));
ptrdiff_t diff = ptr - buffer;
Copy link
Member

Choose a reason for hiding this comment

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

Looks like quite a few compilers don't "appreciate" this type. See CI results...

@songlingatpan
Copy link
Author

@songlingatpan Thanks for the various enhancements. I now triggered a more complete CI run. Do you expect to do further commits or is this now indeed Ready for Review from your perspective?

I will post more commits. Thanks

@songlingatpan
Copy link
Author

@dstebila @baentsch Could you please trigger the complete CI run again? Thanks

@songlingatpan
Copy link
Author

@baentsch CI run again? Thanks

@baentsch
Copy link
Member

I will post more commits.

Then please move this PR status to "Draft".

CI run again?

Done. Other failures. Could you please try to get CI to pass locally first so that I'm not required to manually trigger re-runs any more @songlingatpan ? If all seems to be OK, please revert to Ready for Review stage. Thanks.

Signed-off-by: Songling Han <[email protected]>
Signed-off-by: Songling Han <[email protected]>
Signed-off-by: Songling Han <[email protected]>
Signed-off-by: Songling Han <[email protected]>
Signed-off-by: Songling Han <[email protected]>
Signed-off-by: Songling Han <[email protected]>
@songlingatpan songlingatpan force-pushed the pr_shan_error_handling branch 2 times, most recently from 09cb543 to d248429 Compare September 23, 2024 00:03
@songlingatpan
Copy link
Author

@dstebila @baentsch
This PR is ready for review and merge. Thanks

Signed-off-by: Songling Han <[email protected]>
Signed-off-by: Songling Han <[email protected]>
@dstebila dstebila added this to the 0.12.0 milestone Sep 23, 2024
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.

5 participants