Arctic-Fox icon indicating copy to clipboard operation
Arctic-Fox copied to clipboard

Arctic Fox 46.2 Hangs in NS_InitXPCOM2 on PAGE_SIZE_4KB kernels on ppc64

Open zephyyy opened this issue 5 months ago • 2 comments

Hello, I have recently tried building Arctic Fox 46.2 on a G5 Quad running Gentoo Linux (glibc profile), it builds fine but trying to run it with a 4KB PAGE_SIZE kernel results in a hang in NS_InitXPCOM2 since there's a hardcoded assumption in jemalloc.c that the page size is 64KB on powerpc64

memory/mozjemalloc/jemalloc.c:

#elif defined(__powerpc64__)
#define pagesize_2pow			((size_t) 16)
Thread 2.1 (Thread 0x3ffff7f9a020 (LWP 48683) "arcticfox"):
#0  0x00003ffff798f088 in ??? () at /usr/lib64/libc.so.6
#1  0x00003ffff79988dc in pthread_mutex_lock () at /usr/lib64/libc.so.6
#2  0x0000000100024d9c in malloc_mutex_lock (mutex=0x3ffff7700088) at /var/tmp/portage/www-client/arcticfox-46.2/work/arcticfox-46.2/memory/mozjemalloc/jemalloc.c:1618
#3  arena_malloc_small (arena=0x3ffff7700080, size=32, zero=false) at /var/tmp/portage/www-client/arcticfox-46.2/work/arcticfox-46.2/memory/mozjemalloc/jemalloc.c:4018
        ret = <optimized out>
        bin = 0x3ffff7700258
        run = <optimized out>
        ret = <optimized out>
        bin = <optimized out>
        run = <optimized out>
#4  arena_malloc (arena=0x3ffff7700080, size=<optimized out>, zero=<optimized out>) at /var/tmp/portage/www-client/arcticfox-46.2/work/arcticfox-46.2/memory/mozjemalloc/jemalloc.c:4091
#5  0x00000001000250dc in malloc (size=20) at /var/tmp/portage/www-client/arcticfox-46.2/work/arcticfox-46.2/memory/mozjemalloc/jemalloc.c:5914
        ret = <optimized out>
#6  0x00003ffff792a508 in ??? () at /usr/lib64/libc.so.6
#7  0x00003ffff7929310 in .__dcgettext () at /usr/lib64/libc.so.6
#8  0x00003ffff79afe04 in .__strerror_r () at /usr/lib64/libc.so.6
#9  0x000000010002177c in pages_unmap (addr=<optimized out>, size=<optimized out>) at /var/tmp/portage/www-client/arcticfox-46.2/work/arcticfox-46.2/memory/mozjemalloc/jemalloc.c:2371
        buf = '\000' <repeats 49 times>, "\241\341w5\025\3504\000\000?\377\367j\230 "
#10 pages_unmap (addr=<optimized out>, size=<optimized out>) at /var/tmp/portage/www-client/arcticfox-46.2/work/arcticfox-46.2/memory/mozjemalloc/jemalloc.c:2365
        buf = {<optimized out> <repeats 64 times>}
#11 0x0000000100023dc0 in pages_trim (addr=<optimized out>, alloc_size=<optimized out>, leadsize=<optimized out>, size=<optimized out>) at /var/tmp/portage/www-client/arcticfox-46.2/work/arcticfox-46.2/memory/mozjemalloc/jemalloc.c:2575
        trailsize = 18446744073709490176
        ret = 0x3fffea200000
        ret = <optimized out>
        trailsize = <optimized out>
#12 chunk_alloc_mmap_slow (size=1048576, alignment=1048576) at /var/tmp/portage/www-client/arcticfox-46.2/work/arcticfox-46.2/memory/mozjemalloc/jemalloc.c:2597
        ret = <optimized out>
        pages = <optimized out>
        alloc_size = 2031616
        leadsize = <optimized out>
        ret = <optimized out>
        pages = <optimized out>
        alloc_size = <optimized out>
        leadsize = <optimized out>
#13 chunk_alloc_mmap (size=1048576, alignment=1048576) at /var/tmp/portage/www-client/arcticfox-46.2/work/arcticfox-46.2/memory/mozjemalloc/jemalloc.c:2632
        ret = <optimized out>
        offset = <optimized out>
        ret = <optimized out>
        offset = <optimized out>
#14 chunk_alloc (size=size@entry=1048576, alignment=alignment@entry=1048576, base=base@entry=false, zero=<optimized out>, zero@entry=true) at /var/tmp/portage/www-client/arcticfox-46.2/work/arcticfox-46.2/memory/mozjemalloc/jemalloc.c:2812
        ret = <optimized out>
        RETURN = <optimized out>
#15 0x0000000100024c80 in arena_run_alloc (arena=arena@entry=0x3ffff7700080, size=size@entry=65536, large=large@entry=true, zero=zero@entry=false, bin=0x0) at /var/tmp/portage/www-client/arcticfox-46.2/work/arcticfox-46.2/memory/mozjemalloc/jemalloc.c:3542
        chunk = <optimized out>
        run = <optimized out>
        mapelm = 0x0
        key = {link = {rbn_left = 0x100025050 <imalloc+44>, rbn_right_red = 0x3fffffffa750}, bits = 65552}
#16 0x0000000100024fe8 in arena_malloc_large (arena=0x3ffff7700080, size=65536, zero=false) at /var/tmp/portage/www-client/arcticfox-46.2/work/arcticfox-46.2/memory/mozjemalloc/jemalloc.c:4058
        ret = <optimized out>
        ret = <optimized out>
#17 arena_malloc (arena=0x3ffff7700080, size=<optimized out>, zero=<optimized out>) at /var/tmp/portage/www-client/arcticfox-46.2/work/arcticfox-46.2/memory/mozjemalloc/jemalloc.c:4093
#18 0x00000001000250dc in malloc (size=65536) at /var/tmp/portage/www-client/arcticfox-46.2/work/arcticfox-46.2/memory/mozjemalloc/jemalloc.c:5914
        ret = <optimized out>

full backtrace

Since I'm running a 4KB kernel, I tried patching jemalloc.c like this:

--- a/memory/mozjemalloc/jemalloc.c
+++ b/memory/mozjemalloc/jemalloc.c
@@ -1051,7 +1051,8 @@
     (defined(__sparc) || defined(__sparcv9) || defined(__ia64))
 #define pagesize_2pow			((size_t) 13)
 #elif defined(__powerpc64__)
-#define pagesize_2pow			((size_t) 16)
+/* gets stuck on a 4kb kernel; trying to match it here to avoid allocator miscalcs */
+#define pagesize_2pow			((size_t) 12)
 #else
 #define pagesize_2pow			((size_t) 12)
 #endif

And it seemed to help as the browser no longer hangs, instead it displays a window and is overall working fine (except for some graphical issues in #262).

I have also noticed that ArchPOWER just disables malloc static sizes on both powerpc and powerpc64: powerpc-disable-malloc-static-sizes.patch And T2 SDE patches the static size too: hotfix-jemalloc-pagesize.patch

I think it might be better to either define the size at build time during configure or just disable static sizes like ArchPOWER does.

zephyyy avatar Sep 28 '25 01:09 zephyyy

I'm a little bit weary touching jemalloc for a little used configuration. Such patch is not needed on Debian PPC 32bit nor PPC 64bit to my knowledge.

rmottola avatar Oct 06 '25 12:10 rmottola

Yeah, I can understand the reasoning not to touch jemalloc here.

I don't have a PPC64 Debian installed at the moment so I can't speak for sure, but what I can see right now is that Debian packages both the 4KB and 64KB kernel for PPC64, and the latter should not be affected by this bug:

linux-image-6.16.9+deb14-powerpc64 linux-image-6.16.9+deb14-powerpc64-64k

I'll take a look at it later, though if I didn't mess up my system somehow, I'm pretty sure I will encounter the same bug with a 4KB kernel on Debian.

zephyyy avatar Oct 06 '25 22:10 zephyyy