Skip to content

If ashmem is not available, fall back to wrapping vanilla SYSV shared memory#22

Open
robertkirkman wants to merge 1 commit into
termux:masterfrom
robertkirkman:master
Open

If ashmem is not available, fall back to wrapping vanilla SYSV shared memory#22
robertkirkman wants to merge 1 commit into
termux:masterfrom
robertkirkman:master

Conversation

@robertkirkman

@robertkirkman robertkirkman commented Jun 30, 2026

Copy link
Copy Markdown
Member

@robertkirkman

robertkirkman commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

@twaik does this fix #13 in your opinion, or not fix it because of an obvious problem or insufficiency?

… memory

- Fixes termux/termux-docker#87

- Fixes termux#13

- If vanilla SYSV shared memory is allowed to be run on normal Android, the program will crash, but this can be worked around by attempting to always detect whether ashmem is available before doing anything, and only wrapping vanilla SYSV shared memory in the case that ashmem is not available. If ashmem is not available AND SYSV shared memory is still blocked by SELinux, then on that device, logically there is no codepath that `libandroid-shmem` could have used to work, so the program could not have worked, and crashing in that case might be acceptable.

- Is passing all of these tests on all devices of all architectures and all types of Android that have been tested so far:
  - `cd ~/.termux-build/libandroid-shmem/src/test && make`
  - `initdb $PREFIX/var/lib/postgresql`
  - `shmem-share.c`
  - `shmem-test.c`

- Derived from code primarily originating from https://android.googlesource.com/platform/bionic/+/02ce401d1e2b31586c94c8b6999364bbbce27388/libc/bionic/sys_shm.cpp

- Potential alternative to termux#21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

postgresql and some other reverse dependencies of libandroid-shmem do not work Feature request.

1 participant