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

Unexpected error from C library during 'malloc': Cannot allocate memory in Linux aarch64 #24836

Closed
ayr-ton opened this issue Jul 28, 2022 · 2 comments
Labels

Comments

@ayr-ton
Copy link

ayr-ton commented Jul 28, 2022

Steps to reproduce

  1. Ensure you're using a Linux-based kernel compiled for aarch64 with pages of 16K (Mine was 5.19.0-rc7-asahi-2-1-ARCH)
  2. Install telegram-desktop via any method (apt, pacman, flatpak) or static binary
  3. Run telegram-desktop via terminal

Expected behaviour

To open the app as expected

Actual behaviour

The app won't open with Segfault error because the binary wasn't compiled with 16K pages support

Operating system

Linux 5.19.0-rc7-asahi-2-1-ARCH PREEMPT_DYNAMIC aarch64

Version of Telegram Desktop

4.0.2

Installation source

Static binary from official website

Logs

telegram-desktop                                                                                                                             
<jemalloc>: Unsupported system page size
<jemalloc>: Unsupported system page size
GLib (gthread-posix.c): Unexpected error from C library during 'malloc': Cannot allocate memory.  Aborting.
zsh: IOT instruction (core dumped)  telegram-desktop
@ayr-ton ayr-ton added the bug label Jul 28, 2022
@ilya-fedin
Copy link
Contributor

Static binary from official website

How can you use static binary if it doesn't exist for aarch64?

For other official builds (snap, flatpak) see discussion at #24564. Basically, we don't want to tamper with jemalloc arguments and this should be reported to jemalloc, so they change defaults to the appropriate ones.

@treeshateorcs
Copy link

All you need to do to make it work is rebuild jemalloc. You don't even need to change any build options, just copy this

# Maintainer:  Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
# Contributor: Massimiliano Torromeo <massimiliano.torromeo@gmail.com>
# Contributor: Kovivchak Evgen <oneonfire@gmail.com>

# ALARM: Hayden Seay <me@diatr.us>
#  - build with 16 KiB page sizes on arm.

pkgname=jemalloc
epoch=1
pkgver=5.3.0
pkgrel=1.1
pkgdesc='General-purpose scalable concurrent malloc implementation'
arch=('aarch64')
license=('BSD')
url='http://www.canonware.com/jemalloc/'
depends=('glibc')
makedepends=('clang')
options=('!lto')
provides=('libjemalloc.so')
optdepends=('perl: for jeprof')
source=("https://github.com/jemalloc/jemalloc/releases/download/${pkgver}/${pkgname}-${pkgver}.tar.bz2")
sha256sums=('2db82d1e7119df3e71b7640219b6dfe84789bc0537983c3b7ac4f7189aecfeaa')

build() {
  cd $pkgname-$pkgver

  # FS#71745: GCC-built jemalloc causes telegram-desktop to crash a lot. The reason is still not clear.
  export CC=clang
  export CXX=clang++

  [[ $CARCH == "aarch64" ]] && CONFIG="--with-lg-page=14"
  ./configure \
    --enable-autogen \
    --prefix=/usr $CONFIG
  make
}

package() {
  cd $pkgname-$pkgver

  make DESTDIR="$pkgdir" install

  install -Dm644 COPYING "$pkgdir/usr/share/licenses/$pkgname/COPYING"
  chmod 644 "$pkgdir/usr/lib/libjemalloc_pic.a"
}

into a file called PKGBUILD, and run makepkg -si

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants