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

Standard library allocators should support valgrind client requests #1837

Open
daurnimator opened this issue Dec 17, 2018 · 3 comments
Open
Labels
proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. standard library This issue involves writing Zig code for the standard library.
Milestone

Comments

@daurnimator
Copy link
Contributor

To find memory leaks in zig programs, the standard library allocators should inform valgrind about allocations/frees.

This has a dependency on making valgrind client requests possible from zig code. valgrind/valgrind.h is a gnarly piece of code!

Valgrind docs: http://valgrind.org/docs/manual/mc-manual.html#mc-manual.clientreqs

Related to

@andrewrk andrewrk added the standard library This issue involves writing Zig code for the standard library. label Dec 17, 2018
@andrewrk andrewrk added this to the 0.5.0 milestone Dec 17, 2018
@andrewrk
Copy link
Member

This is a good idea. At least the general purpose allocator that we eventually have should support this, in debug mode. We'll need to balance it with the use case of comptime allocation (see #1291). (Maybe that can be solved with "use this special allocator" for comptime allocation).

Also related #896

@andrewrk
Copy link
Member

andrewrk commented Dec 17, 2018

And #480

@andrewrk
Copy link
Member

andrewrk commented Mar 11, 2019

@daurnimator your pull request was a great start to tackling this issue. It was the basis for solving #460 which is now integrated directly into the codegen of the compiler. I merged the std.valgrind module but I removed the integration with std.mem.Allocator for now. I want to work towards solving #1291 and this issue at the same time. For future reference, the integration with std.mem.Allocator code can be found here: d633dcd

This issue is still open, and I'm not sure yet how exactly the integration will work, whether it goes into the Allocator interface, or implementations, or something special. Whatever happens, thanks to @daurnimator's work, it's now possible for zig users' custom allocators to add valgrind integration, and example integration can be found in the above linked commit.

@andrewrk andrewrk modified the milestones: 0.5.0, 0.6.0 Sep 20, 2019
@andrewrk andrewrk modified the milestones: 0.6.0, 0.7.0 Oct 17, 2019
@andrewrk andrewrk added the proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. label Oct 30, 2020
@andrewrk andrewrk modified the milestones: 0.7.0, 0.8.0 Oct 30, 2020
@andrewrk andrewrk modified the milestones: 0.8.0, 0.10.0 May 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal This issue suggests modifications. If it also has the "accepted" label then it is planned. standard library This issue involves writing Zig code for the standard library.
Projects
None yet
Development

No branches or pull requests

2 participants