#Should allocators panic on android?

1 messages · Page 1 of 1 (latest)

heady spade
#

When I attempt to use any zig allocator (smp, arena, etc…) in a library built for android, it causes a panic when using the allocator inside the android emulator. If I use the lib c allocator, no panic occurs.

Is this expected behavior for android platforms? Or could there be some information I am missing that might enable the zig allocators to work inside libraries built for android.

Although my library works fine with the c allocator, I get significant performance improvements by using the arena allocator, so it would be nice if there was a way to use the arena allocator on android.

I wonder if doing something like this makes sense, but in light of the fact even the smp allocator panics, I’m hesitant to try:

var arena = std.heap.ArenaAllocator.init(std.heap.c_allocator);
defer arena.deinit();
const allocator = arena.allocator();
bitter mortar
#

No, they shouldn't. This is a bug.

heady spade
#

I wasn’t sure if there was any special initialization or special process zig might need when on android. I’ll update to the latest zig build and re-test.

bitter mortar
#

Unless you already see a bug report that has been fixed, I think it's unlikely that will help. AFAIK Android hasn't been a focus, so likely lots of stuff broken. What's needed is to drill in and find the precise cause of the problem and open a detailed issue with reproducible minimal repro case.

heady spade
#

Thanks, yea, the problem for me is I still feel very very noob at all this android stuff. Last week I didn’t know anything about android studio, android packages, and android linking. It feels like I’m holding everything together with bandaids and sticky tape. I’m not sure there is much debugging I can do that would be meaningful yet.

(I did make an android library with rust for Godot before, but it was significantly easier and less painful)

solid kestrel
#

What panic do you get?

#

wrapping c_allocator with arenas is fine fyi

heady spade
#

This is what appears in android syslog (logcat) when you try and init something with the smp allocator or arena allocator:

Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 24708 (SDLThread), pid 24685 (SDLActivity)

Note that the panic occurs inside the libc process, not in my app itself.

solid kestrel
#

you should get trace too on debug builds

heady spade
#

I am able to work around that by using "nm mylib.so" to list all the addresses of the symbols and manually cross check the numbers. It goes deep deep into std lib code (about 20 std lib calls between my code and libc)