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

Fatal signal 11 (SIGSEGV) when importing cartopy #1300

Closed
ytremare opened this issue Nov 27, 2024 · 9 comments
Closed

Fatal signal 11 (SIGSEGV) when importing cartopy #1300

ytremare opened this issue Nov 27, 2024 · 9 comments
Labels

Comments

@ytremare
Copy link

ytremare commented Nov 27, 2024

App crash with fatal error in libc.
Fork is available at: https://github.com/ytremare/chaquopy-16.0.0
note that chaquopy-16.0.0 is the chaquopy version of chaquopy (github people told me it wasn't possible to have 2 forks of the same repository ) but packages are up to date and the build version is 14.0.2.

Chaquopy version com.chaquo.python:gradle:14.0.2'

Debug trace below

art_sigsegv_fault:
	pushq  %rbp                     
	pushq  %r14                     
	pushq  %rbx                     
	subq   $0x10, %rsp              
	movq   %fs:0x28, %rax           
	movq   %rax, 0x8(%rsp)          
	movq   0x6f0f9b(%rip), %rax     
	cmpb   $0x0, 0xd(%rax)          
	jne    0x4684dc                   ; <+60>
	movq   %fs:0x28, %rax           
	cmpq   0x8(%rsp), %rax          
	jne    0x468543                   ; <+163>
	addq   $0x10, %rsp              
	popq   %rbx                     
	popq   %r14                     
	popq   %rbp                     
	retq                            
	movl   $0x2, %edi               
	xorl   %esi, %esi               
	callq  0x9484e0                   ; symbol stub for: android::base::ShouldLog(android::base::LogSeverity, char const*)
	testb  %al, %al                 
	je     0x4684c3                   ; <+35>
	callq  0x948540                   ; symbol stub for: __errno
	movq   %rax, %rbx               
	movl   (%rax), %ebp             
	leaq   -0x39a18b(%rip), %rsi    
	movq   %rsp, %r14               
	movq   %r14, %rdi               
	movl   $0x32, %edx              
	movl   $0x2, %ecx               
	xorl   %r8d, %r8d               
	movl   $0xffffffff, %r9d          ; imm = 0xFFFFFFFF
	callq  0x9484f0                   ; symbol stub for: android::base::LogMessage::LogMessage(char const*, unsigned int, android::base::LogSeverity, char const*, int)
	movq   %r14, %rdi               
	callq  0x948500                   ; symbol stub for: android::base::LogMessage::stream()
	leaq   -0x39bf12(%rip), %rsi    
	movl   $0x47, %edx              
	movq   %rax, %rdi               
	callq  0x3beeb0                   ; std::__1::basic_ostream<char, std::__1::char_traits<char>>& std::__1::__put_character_sequence<char, std::__1::char_traits<char>>(std::__1::basic_ostream<char, std::__1::char_traits<char>>&, char const*, unsigned long)
	movq   %r14, %rdi               
	callq  0x948520                   ; symbol stub for: android::base::LogMessage::~LogMessage()
	movl   %ebp, (%rbx)             
	jmp    0x4684c3                   ; <+35>
	callq  0x94ad10                   ; symbol stub for: __stack_chk_fail

Crash occurs on the following instruction:
import cartopy.feature as cf
import cartopy provides also libc crash

App without any change was working on my previous laptop. I've checked a lot of things but didn't succeed to find what is wrongly set or configured on the laptop. I also copied cartopy from old laptop to the new one, result is the same.
Wheels are correctly generated generated .
My guess is there some mistake at laptop side , but I'm unable to find it.

You'll find also attached build.gradle.log file.
build.gradle-log.txt

@mhsmith mhsmith changed the title Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 Fatal signal 11 (SIGSEGV) when importing cartopy Nov 28, 2024
@mhsmith
Copy link
Member

mhsmith commented Nov 28, 2024

The build log includes the following wheels you built yourself, so the error is probably in one of them:

Processing /home/ytrem/miniconda3/chaquopy-eccodes-14.0.2/server/pypi/dist/eccodes/eccodes-2.33.0-0-py3-none-android_21_arm64_v8a.whl
Processing /home/ytrem/miniconda3/chaquopy-eccodes-14.0.2/server/pypi/dist/cfgrib/cfgrib-0.9.10.4-0-cp310-cp310-android_21_arm64_v8a.whl
Processing /home/ytrem/miniconda3/chaquopy-eccodes-14.0.2/server/pypi/dist/cartopy/cartopy-0.22.0-0-cp310-cp310-android_21_arm64_v8a.whl
Processing /home/ytrem/miniconda3/chaquopy-eccodes-14.0.2/server/pypi/dist/libaec/libaec-1.1.2-0-py3-none-android_21_arm64_v8a.whl

This "Debug trace" is simply a disassembly of an Android error reporting function, and doesn't provide any useful information. Please post the full error along with any other relevant logcat messages.

@ytremare
Copy link
Author

ytremare commented Nov 28, 2024

Thanks for your quick response.
The guilty instruction is import cartopy.feature as cf
App calls 2 python scripts, the first one is to initialize python environment for app, the second one is the functional script, it's in charge to load read and decode grib file(grib are weather forecast data).
In the logcat you 'll see that decoding is working fine. Decoding and reading are based on cfgrib associated to eccodes (native lib). When python attempt to project data on map, it imports cartopy. putting import cartopy leads to have crash with "no module name ", but no libc crash.
Please find attached full logcat/
here below full error msg.
Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 21874 (ibdownloaderapp), pid 21874 (ibdownloaderapp)
logcat.txt

@ytremare
Copy link
Author

ytremare commented Dec 4, 2024 via email

@mhsmith
Copy link
Member

mhsmith commented Dec 4, 2024

libc is provided by the device itself. It's involved in reporting the crash, but it's unlikely to be the cause of the problem.

This log still doesn't contain any more information about the crash. There should be a native backtrace that looks something like the ones in #1209 (comment). To find it in the logcat, you may need to display all messages rather than just the ones from your own app.

@ytremare
Copy link
Author

ytremare commented Dec 4, 2024 via email

@ytremare
Copy link
Author

ytremare commented Dec 4, 2024

Adding full logcat
full_logcat.txt

@mhsmith
Copy link
Member

mhsmith commented Dec 4, 2024

Thanks very much. Unfortunately this still doesn't give a clear indication of the cause, except that it involves libc++, which we released a new version of recently.

I don't really understand what you're saying at the top of this issue about Chaquopy 14.0.2 and 16.0.0. But if you built these .whl files using build-wheel from the 14.0.2 tag, then you will have used NDK version 22, with the old libc++ version. The new version is supposed to be backward compatible with the old one, and it works with almost all the existing packages, but we had to rebuild a couple which experienced native crashes (#1171). It's possible one of your packages has a similar issue.

To make sure your app uses the old libc++ version at runtime, you can add this to the pip section of your build.gradle file:

install("chaquopy-libcxx==11000")

However, we've fixed lots of bugs since then, so I recommend you try updating your app to Chaquopy 16.0.0, and rebuilding the .whl files with the current version of build-wheel (i.e. the head of the master branch, not the 16.0.0 tag). This produces .whl files with an API level of 24, so your app's minSdk will need to be 24 or greater.

@ytremare
Copy link
Author

ytremare commented Dec 5, 2024 via email

@ytremare
Copy link
Author

ytremare commented Dec 6, 2024

Fixed chaquopy-libcxx==11000.
Thanks for your efficient suppot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants