-
Notifications
You must be signed in to change notification settings - Fork 217
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
Troubles with parity-util-mem #364
Comments
For 2, the issue is that parity-util-mem need to be aware of the allocator in use, so that is why it should be this crate that define the allocator.
So clearly the definition of the allocator by feature in parity-util-mem should be done only at the top level (binary) to avoid having to manage this kind of thing, but for test it can be quite an annoyance. Thinking about 1, the part of parity-util-mem that define allocator could also be extracted in another crate to make it more 'stable' and reduce the need for crate update (and have only a smaller crate that requires a single version, but having two different version of util-mem is probably rather difficult to do (you need very distinct data structure)). TLDR; my first thought are other crate need to use |
My understanding that if two crates define global allocators, it won't compile.
So the problem only happens if parity-util-mem doesn't define a global allocator, but it's defined somewhere in the code (e.g. see link above in p.2). |
Parity util mem need to know which allocator is in use (except if runing with estimate-heapsize), so I would think using parity-util-mem in the link with feature dlmalloc is required, then there is two way to proceed:
Also if we want to get an error in such case, maybe we also want parity-util-mem to always define allocator (std::system::Allocator), but I am really not sure how things will behave. |
I think for this dlmalloc specific case it's fine because it's used in a no-std environment where
This actually could work, good idea, let me try it. |
Actually it doesn't seem to work as in it doesn't generate a link-time error. |
parity-util-mem
currently has several issues:parity-util-mem
with different global allocator features set will lead to Undefined Behaviour, see #Ban multiple versions of parity-util-mem polkadot#922 (this is addressed in Ban duplicates of parity-uil-mem from being linked into the same program #363).parity-util-mem
features may lead to UB (e.g. https://github.com/paritytech/polkadot/pull/918/files#diff-0d754f08395fefc53a33b67bd7e02a22R31).I don't know how to address p. 2.
cc @cheme
The text was updated successfully, but these errors were encountered: