-
Notifications
You must be signed in to change notification settings - Fork 44
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
override
feature is unsafe or broken on many platforms and should be labeled as such
#41
Comments
New 1.7.0 mimalloc tries to fix DragonFly and MacOS part. Nevertheless, when I tried with MacOS, it does not seem to work with rustc combined with libmimalloc-sys, at least. Any ideas what could be still missing? |
Yeah, I contributed some of the macOS fixes. The issue isn't mimalloc (necessarially), it's our use of it. The way to use malloc override on macOS is:
Unfortunately, DYLD_FORCE_FLAT_NAMESPACE=1 tends to break things in strange ways. macOS system libraries don't do well with it on. In firefox we had trouble with it and address sanitizer (no custom malloc involved). This could be the issue you're seeing if you were doing the rest to these steps properly. In general, there isn't a good way to override malloc globally and completely on mac for all programs. So. You'll note that absolutely none of this is doable from the way we have the override feature setup, which it why I described it as being used totally incorrectly. The way we use it (to build a static library that is linked in) is broken on macOS, (and not just macOS either). The only way to make this work without setting the environment is probably to detect those vars being missing in |
For rustc on macOS my recommendation would be
I was working on this at one point but its such a hassle. I like a lot of things about macOS's system design but the way userspace memory allocation works is a disaster and feels like its from the 1990s. |
Thanks for the detailed response! Just wondering, jemalloc-sys in rustc claims that they can override malloc on MacOS. Of course, it may not really work? If it does, however, then maybe mimalloc can do it in a similar way. I'll take a look. |
Note that (For example, |
Uhh, thanks. Rustc comments for config.toml are just wrong then. |
Huh, I had assumed they knew they weren't overriding on macOS. I'll bring that up in t-compiler/performance on zulip. |
And BTW, the reason I was looking into this is this test run: rust-lang/rust#81782 |
(sad macOS user noises) But yes, switching rustc to use mimalloc is probably a good idea across the board. |
Also, note that this works iff Since you're presumably adding this dep into the actual |
Sounds to me that it would work on par with |
Oh yes, it's fine for rustc, I just meant I still felt that it was worth renaming the feature to |
@thomcc It seems possible to make override working for macOS with a reasonable effort, please see rust-lang/rust#82423. Maybe this can be improved for |
In theory mimalloc supports it in specific cases, but not in a general/fully safe way, I'll look into what would be needed for rustc's case, but probably won't get to it until next week or so. |
Thanks! I am not familiar with macOS internals, but as a macOS user can perhaps at least test drive. |
Do you have access to a pre-10.12 macOS machine? |
I have the latest Big Sur only, so unfortunately no. |
That's fine, I'll see if I have a machine that's old enough (I think I have one in a box somewhere...). Sadly, a lot of these things changed then, and rustc supports back to 10.7 |
Mimalloc's MI_OVERRIDE feature is being used totally incorrectly for us. We always statically link, meaning it only works on a few unixes (never on windows), and that even then you must arrange for it to be first in the linkers path otherwise you'll end up
I think it should be renamed to
unsafe_override
orexperimental_override
and disabled on platforms known to be incomplete (dragonflybsd) or buggy (macos), perhaps with an environment var you can use to force the issue.The text was updated successfully, but these errors were encountered: