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

Enable malloc debug features #401

Closed
wants to merge 1 commit into from
Closed

Enable malloc debug features #401

wants to merge 1 commit into from

Conversation

krader1961
Copy link
Contributor

This enables malloc debugging features provided by various
implementations. This is only really useful when issue #396 is resolved
so that ksh no longer uses the AST Vmalloc subsystem. I'm recommending
merging this now to to make it obvious that any bugs involving the use
of the native malloc subsystem are caught sooner rather than later.

This enables malloc debugging features provided by various
implementations. This is only really useful when issue #396 is resolved
so that `ksh` no longer uses the AST Vmalloc subsystem. I'm recommending
merging this now to to make it obvious that any bugs involving the use
of the native malloc subsystem are caught sooner rather than later.
@krader1961
Copy link
Contributor Author

krader1961 commented Feb 8, 2018

P.S., I tested this on several distros such as FreeBSD11. This change makes meson test sh_match fail consistently whereas without it the test seldom fails.

@krader1961
Copy link
Contributor Author

P.P.S., This results in FreeBSD 11 test failures going from 65 to 74. So apparently there are a lot more "use after free" or "malloc buffers should be initialized to zero", or similar, bugs in the code.

#
malloc_debug_env = environment()
# These env vars are recognized by GNU malloc.
malloc_debug_env.set('MALLOC_CHECK_', '3')
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should also set MALLOC_PERTURB_ environment variable here. This would set all the free'd bytes to value specified by this variable, so it's easier to detect use after free cases.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Set to 165 (0xA5) to mimic the macOS behavior.

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.

2 participants