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

Segfault running aarch64-unknown-linux-gnu binaries on Fedora #36994

Closed
cuviper opened this issue Oct 6, 2016 · 2 comments
Closed

Segfault running aarch64-unknown-linux-gnu binaries on Fedora #36994

cuviper opened this issue Oct 6, 2016 · 2 comments
Labels
O-Arm Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state

Comments

@cuviper
Copy link
Member

cuviper commented Oct 6, 2016

I've been trying to bootstrap Fedora aarch64, and I was getting strange segfaults. It was even stranger when I found that it would work in a Fedora chroot on my tablet (Android kernel), but failed under a full Fedora system. I finally realized that Fedora's kernel is using 64k pages, and Rust's jemalloc is built for 4k.

I filed jemalloc/jemalloc#467 for compiled-in page sizes. The result is that most madvise(MADV_DONTNEED) calls are failing due to alignment, which wouldn't be a big deal, but a few happen to align correctly. However, the kernel rounds up the requested length to a full 64k page, so it actually clears a lot more memory than intended. It doesn't take long for a nulled pointer to get dereferenced and crash.

So on the Rust side, this might be more fuel for switching the default allocator, cc #36963. Or perhaps Rust's jemalloc tree can be patched the same as Firefox's mozjemalloc to read the page size at runtime.

In the meantime, those madvise calls can be disabled by the environment:
export MALLOC_CONF=lg_dirty_mult:-1
So far, that works for me, and I'll try a full build soon.

@sanxiyn sanxiyn added the O-Arm Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state label Oct 6, 2016
@cuviper
Copy link
Member Author

cuviper commented Oct 6, 2016

FWIW, here's what a failed build looks like. You have to scroll up the log a bit to see where the crash was (thanks to parallel make), but the very first rustc invocation for libcore hits the segfault.

Here's a successful build just having added that MALLOC_CONF. It even aced the testsuite!

@alexcrichton
Copy link
Member

I've opened a PR to disable jemalloc on aarch64: #37392

alexcrichton added a commit to alexcrichton/rust that referenced this issue Oct 27, 2016
Sounds like jemalloc is broken on systems which differ in page size than the
host it was compiled on (unless an option was passed). This unfortunately
reduces the portability of binaries created and can often make Rust segfault by
default. For now let's patch over this by disabling jemalloc until we can figure
out a better solution.

Closes rust-lang#36994
Closes rust-lang#37320
cc jemalloc/jemalloc#467
bors added a commit that referenced this issue Oct 29, 2016
Disable jemalloc on aarch64/powerpc

Sounds like jemalloc is broken on systems which differ in page size than the
host it was compiled on (unless an option was passed). This unfortunately
reduces the portability of binaries created and can often make Rust segfault by
default. For now let's patch over this by disabling jemalloc until we can figure
out a better solution.

Closes #36994
Closes #37320
cc jemalloc/jemalloc#467
bors added a commit that referenced this issue Oct 30, 2016
Disable jemalloc on aarch64/powerpc

Sounds like jemalloc is broken on systems which differ in page size than the
host it was compiled on (unless an option was passed). This unfortunately
reduces the portability of binaries created and can often make Rust segfault by
default. For now let's patch over this by disabling jemalloc until we can figure
out a better solution.

Closes #36994
Closes #37320
cc jemalloc/jemalloc#467
kennytm added a commit to kennytm/rust that referenced this issue Oct 25, 2017
Disable jemalloc for sparcv9-sun-solaris

Similar to rust-lang#36994, rust programs segfault on SPARC64 Solaris machines.
bors added a commit that referenced this issue Oct 31, 2017
[beta] Disable jemalloc for sparcv9-sun-solaris

Backport from #45508. Similar to #36994, rust programs segfault on SPARC64 Solaris machines.
bors added a commit that referenced this issue Nov 2, 2017
[beta] Disable jemalloc for sparcv9-sun-solaris

Backport from #45508. Similar to #36994, rust programs segfault on SPARC64 Solaris machines.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-Arm Target: 32-bit Arm processors (armv6, armv7, thumb...), including 64-bit Arm in AArch32 state
Projects
None yet
Development

No branches or pull requests

3 participants