Bug #17511
closedSegmentation fault when compiled with -O2 or higher on ARM Android
Description
To reproduce a segmentation fault, compile Ruby with CFLAGS=-Oz
using Android NDK r22 (Clang 11.0.5), and input the following:
require 'rubygems'
pp
A segmentation fault also occurs with CFLAGS=-O2
when Up or Down key is pressed in IRB.
A workaround is to disable using __builtin_setjmp
:
./configure --with-setjmp-type=setjmp
I have no idea if there are similar issues or not in non-Android Linux systems on 32-bit ARM.
Bug #14480 seems to suggest that there was a similar case on AArch64 Linux with GCC.
Files
Updated by mame (Yusuke Endoh) almost 4 years ago
- Related to Bug #14480: miniruby crashing when compiled with -O2 or -O1 on aarch64 added
Updated by mame (Yusuke Endoh) almost 4 years ago
- Status changed from Open to Closed
Applied in changeset git|b9c1b3f8d82b6f2517786b2f9e06683909af34c3.
configure.ac: disable using __builtin_setjmp on ARM Android
A patch from Tee KOBAYASHI xtkoba+ruby@gmail.com. [Bug #17511]
Updated by mame (Yusuke Endoh) almost 4 years ago
Thank you, I've imported your patch.
BTW, I'm curious for what purpose you are attempting to build Ruby for Android.
As I said, we currently have no CI or development environment for Arm Android.
So it is difficult for us to test the code for the environment.
I thought your patch for this ticket was very trivial, so I've imported it.
But if it was more complicated, such as fixing a test, it would be difficult for me to commit it.
If there is a practical use case for Android Ruby, I'm willing to try preparing a CI for the environment.
Updated by xtkoba (Tee KOBAYASHI) almost 4 years ago
Thanks for the merge!
My running Ruby on ARM Android is JUST FOR FUN :-)
I think it would be more productive to prepare a CI for AArch64 Android if you could, rather than for nearly out-of-date 32-bit ARM Android.
Updated by xtkoba (Tee KOBAYASHI) over 3 years ago
- File ruby-ec-volatile.patch ruby-ec-volatile.patch added
I revisited this issue, and probably found another workaround: to add volatile
qualifier to the ec
argument of the functions rb_ec_tag_jump
and vm_exec
, as in the attached patch. I have no idea exactly what it means, and I don't expect it to be merged. After all, there is no problem unless __builtin_{set,long}jmp
are in use.
Updated by xtkoba (Tee KOBAYASHI) over 3 years ago
Just for the record, there turns out to be a Clang/LLVM bug in its __builtin_longjmp
implementation for ARM Linux (more specifically for non-Darwin and non-Windows) for which there seems to be no reliable workaround on user's side.