-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
macos: rustc built without jemalloc sporadically fails with realloc failure #92173
Comments
More information about this is over at #92185 (comment). These are likely the same issue, but I am not certain. |
I also ran into this a while ago, reported it against rayon initially: rayon-rs/rayon#901. There was a non-Rust issue we found that reported similar issues: ibmdb/python-ibmdb#648 (comment). Analysis we've done so far: it seems that something is broken with the macOS 12-provided /usr/lib/libstdc++.6.dylib. Swapping to the homebrew-provided libstdc++ seems to fix the crash, and using link-cplusplus to swap to libc++ also seems to fix the crash. Switching to jemalloc or mimalloc seemed to fix this. Does anyone have the ear of folks at Apple? |
Yes, I've reached out to a friend. |
@saethlin Has a radar been filed for this, and if so, what’s the radar number? |
Hey folks, I'm the person who'd be closest to being in charge of the old The right fix would be to always use libc++, since that is (and has been for a while) the one supported C++ Standard Library on Apple platforms. Sorry if that sounds like a silly suggestion -- I don't have much context on this issue from your side. Is there a reason why you folks are using the older |
I don't think it is linked to libstdc++.dylib
#92173 (comment) might have been discussing a different project? |
I agree, this issue showed up in Rust built via Nix (NixOS/nixpkgs#144704) and the build setup there uses |
Is this issue related to the crashes folks are observing in clippy on macOS in the new 1.59.0 release? |
This issue here is about when rustc is built without jemalloc, whereas that issue is occurring with binaries downloaded via rustup and which presumably are using jemalloc. |
@ehuss should this be tagged as a stable-to-stable regression and up the priority? or is there another place I should be following along? |
I'd leave it up to the clippy team to set the priority for fixing clippy specifically. |
Thanks for the context and the links @ehuss! |
Some more details:
|
I just want to report that issue is currently blocking me in development. If there are any work around for the macos darwin tool chain and clippy errors... would love to hear about it. |
I've been tracking this issue. My fix was to downgrade to my project's MSRV, 1.57. But after the latest "Command Line Tools for Xcode" update (13.3), I found that I could run clippy again on both |
I am running into the issue myself. What seems to be a workaround for everybody? |
The definitive fix is to update to Xcode 13.3, you may need to use the App Store or Settings App (I've had it come differently on two different machines) I believe one of the malloc implementations shipped with the 'shared library' feature of Xcode was broken. From my testing, I believe it's completely unrelated to the rust alloc code. |
I got XCode 13.3 and removed my rustup and reinstalled my version (1.51). Do I need to do anything else special because it seems to not have done anything? |
so I am unsure if it is the same issue but things were fine on big sir and then I upgrade. My particular project has an enormous amount of dependencies (>800). Occasionally when doing a cargo clean, cargo update some libraries fail for apparently no reason (SIGABORT). If I rerun multiple times things seem to eventually build.
|
You can run it with Our issue was actually logging the malloc issue (Source of this ticket and clippy issue):
The above issue appears fixed as of Xcode 13.3. |
Should I create a new ticket? |
If possible, debug cargo/rustc and print the callstack, if it's different, then definitely! |
|
Sorry forgot |
|
You would have to debug rustc directly I believe. It's kinda hard to explain over github. Are you in the discord/zulip? |
https://discord.com/invite/rust-lang
Then you can run lldb on that |
rustc(69444,0x700006d18000) malloc: *** error for object 0x600002ff1b00: pointer being realloc'd was not allocated |
I am able to build |
So it is the same error as described but I am able to reproduce it in a separate fashion, which I am unsure if that makes it the same issue, |
Upon further investigation I took the 1.51-dev I build and installed myself (with cargo) and tried rebuilding my project using that and it worked. When I install rust with rustup does it not also compile it in some fashion? Why does that not work? |
Now that I’ve built my own rust is there some doc how I can package and distribute a tool chain myself? |
I am seeing a crash inside Exporting MallocStackLogging=1 before the |
I'm also seeing this bug, I think?
I'm on v14 of CLI tools (on macOS), though, given how much time has passed.
This is on,
Was there some fix, here? Are later nightlies still affected? (For … historical reasons … my company is on nightly. We try to track the nightly right before the branch to a stable, though, so this is my best guess for 1.60. But this blocks us getting to 1.60, currently. Should I just attempt to skip 1.60? (Would this be fixed in the nightly-before 1.61?)) |
I can reliably create this using libruby as well, which uses #[global_allocator]
static ALLOCATOR: System = System; |
Looks like Miri might also be affected. So this issue means every single user of rustc_driver will waste a few hours/days debugging strange macOS crashes. Would be good to do something that makes this discoverable. Is there a reason that librustc_driver doesn't just set jemalloc itself, to avoid having every single tool repeat this procedure? EDIT: looks like that does not work for terrible sad reasons. |
For anyone seeing this in their GitHub CI: In Kani, we have chosen to upgrade to macos-13 runners (currently in beta): model-checking/kani#2987. This appears to solve the problem for us. |
For the record, we also ran into "pointer being freed was not allocated" running clippy-driver on macos12, and also chose to upgrade the OS. |
I can confirm this for 1.82.0 on a M2 with macOS 15.0.1 Sequoia: On heavily threaded code (rayon) this happens sporadically after running it for a couple of hours. Switching to jemalloc (or removing rayon) seems to fix it for me (although with sporadic errors like this you can never really be sure). |
Building rustc on macos without jemalloc (the default in config.toml) will trigger frequent SIGABRT. The error is:
The backtrace is:
Backtrace
This happens almost 100% of the the time for me, though it can be sporadic.
Doing something like
./x.py build --stage=2 src/tools/cargo
is enough to reproduce. It almost always fails while buildingcore
for stage2.I've spent some time trying to debug it, but have not figured anything out.
Using jemalloc makes the error go away.
Currently using master (8ad3c1d), though this has been going on for a while. If I get a chance, I'll try to bisect to see when it started. But for me, I think it started after I updated to Monterey (macOS 12.0).
I have XCode 13.1.
Other users have reported this at rust-lang/cargo#10022.
The text was updated successfully, but these errors were encountered: