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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

App crashes after changing chapter on study #1725

Closed
rodrigoq opened this issue Jun 15, 2021 · 6 comments 路 Fixed by #1832
Closed

App crashes after changing chapter on study #1725

rodrigoq opened this issue Jun 15, 2021 · 6 comments 路 Fixed by #1832
Assignees

Comments

@rodrigoq
Copy link

Describe the bug
App crashes after changing chapter on specific study.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'Study' on the main menu
  2. Select '馃嚞馃嚙馃嚞馃嚙 Learn The London System: A Repertoire for Beginners to Master 馃嚞馃嚙馃嚞馃嚙: Introduction on the London System'
  3. Click the bottom right menu
  4. Select chapter 2 'Typical Position after the Opening'
  5. Wait for it (a few seconds)
  6. App crashes

It's consistent all the time on my phone.
On the webpage the url of the study is:
https://lichess.org/study/iDglcwYy

Expected behavior
To master the London system like a pro. Also, not a crash.

Smartphone (please complete the following information):

  • Device: Xiaomi MI 9T Pro
  • OS: MIUI 12.0.5 (Android 10 QKQ1.190825.002, security patch level 2021-04-01)

Additional context
I couldn't find any other studies that crashes, only that one.

Crash dump:

Build fingerprint: 'Xiaomi/raphael_eea/raphael:10/QKQ1.190825.002/V12.0.5.0.QFKEUXM:user/release-keys'
Revision: '0'
ABI: 'arm64'
Timestamp: 2021-06-15 08:04:13-0300
pid: 8684, tid: 8759, name: CapacitorPlugin >>> org.lichess.mobileapp <<<
uid: 10354
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0xd3d3d71e
x0 00000077edff6680 x1 00000077751ee000 x2 0000000000000005 x3 0000000000000000
x4 000000000000001f x5 0000000000000015 x6 000000000000003e x7 50322f3242315033
x8 000000001a5a5ab4 x9 000000777f789000 x10 0000000000000800 x11 000000000101017e
x12 0000000000000000 x13 0000000001010102 x14 0000000000000001 x15 ffffffffffffffff
x16 ffffffffffffffff x17 00000000283ceb41 x18 000000779cb3e000 x19 00000077edff6680
x20 00000077751ee000 x21 00000077751ee008 x22 0000000000000004 x23 0000000000000020
x24 0000000000000000 x25 0000000000000003 x26 000000779cc649d0 x27 ffffffffffffffff
x28 000000779cc649f8 x29 000000779cc64990
sp 000000779cc64970 lr 000000777f773b0c pc 000000777f77423c

backtrace:
#00 pc 000000000004f23c /data/app/org.lichess.mobileapp-ssR6Z9ww3QpgcsFlgWktHA==/lib/arm64/libstockfish.so (Position::set_check_info(StateInfo*) const+612) (BuildId: 57e2b844da89cb3637b4a5431e6b3204dae01eb0)
#1 pc 000000000004eb08 /data/app/org.lichess.mobileapp-ssR6Z9ww3QpgcsFlgWktHA==/lib/arm64/libstockfish.so (Position::set_state(StateInfo*) const+344) (BuildId: 57e2b844da89cb3637b4a5431e6b3204dae01eb0)
#2 pc 000000000004da14 /data/app/org.lichess.mobileapp-ssR6Z9ww3QpgcsFlgWktHA==/lib/arm64/libstockfish.so (Position::set(std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator> const&, bool, StateInfo*, Thread*)+1688) (BuildId: 57e2b844da89cb3637b4a5431e6b3204dae01eb0)
#3 pc 0000000000053fc0 /data/app/org.lichess.mobileapp-ssR6Z9ww3QpgcsFlgWktHA==/lib/arm64/libstockfish.so (BuildId: 57e2b844da89cb3637b4a5431e6b3204dae01eb0)
#4 pc 0000000000052cac /data/app/org.lichess.mobileapp-ssR6Z9ww3QpgcsFlgWktHA==/lib/arm64/libstockfish.so (UCI::command(std::__ndk1::basic_string<char, std::__ndk1::char_traits, std::__ndk1::allocator>)+2688) (BuildId: 57e2b844da89cb3637b4a5431e6b3204dae01eb0)
#5 pc 0000000000014c18 /data/app/org.lichess.mobileapp-ssR6Z9ww3QpgcsFlgWktHA==/lib/arm64/libstockfish.so (Java_org_lichess_mobileapp_stockfish_Stockfish_jniCmd+184) (BuildId: 57e2b844da89cb3637b4a5431e6b3204dae01eb0)
#6 pc 00000000000460a8 /data/app/org.lichess.mobileapp-ssR6Z9ww3QpgcsFlgWktHA==/oat/arm64/base.odex (art_jni_trampoline+152)
#7 pc 000000000004753c /data/app/org.lichess.mobileapp-ssR6Z9ww3QpgcsFlgWktHA==/oat/arm64/base.odex (org.lichess.mobileapp.stockfish.Stockfish.cmd+364)
#8 pc 0000000000137334 /apex/com.android.runtime/lib64/libart.so (art_quick_invoke_stub+548) (BuildId: d8ff78fda9077f8e6f85a96944cba214)
#9 pc 0000000000145fec /apex/com.android.runtime/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+244) (BuildId: d8ff78fda9077f8e6f85a96944cba214)
#10 pc 00000000004b16b4 /apex/com.android.runtime/lib64/libart.so (art::(anonymous namespace)::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, art::(anonymous namespace)::ArgArray*, art::JValue*, char const*)+104) (BuildId: d8ff78fda9077f8e6f85a96944cba214)
#11 pc 00000000004b3258 /apex/com.android.runtime/lib64/libart.so (art::InvokeMethod(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jobject*, _jobject*, unsigned long)+1480) (BuildId: d8ff78fda9077f8e6f85a96944cba214)
#12 pc 000000000043e4f0 /apex/com.android.runtime/lib64/libart.so (art::Method_invoke(_JNIEnv*, _jobject*, _jobject*, _jobjectArray*)+52) (BuildId: d8ff78fda9077f8e6f85a96944cba214)
#13 pc 00000000006d4ea4 /system/framework/arm64/boot.oat (art_jni_trampoline+180) (BuildId: 7ef21945ee0a003569d945d33aa0ea0064a95c1f)
#14 pc 000000000006b7c4 /data/app/org.lichess.mobileapp-ssR6Z9ww3QpgcsFlgWktHA==/oat/arm64/base.odex (com.getcapacitor.PluginHandle.invoke+340)
#15 pc 000000000005ba78 /data/app/org.lichess.mobileapp-ssR6Z9ww3QpgcsFlgWktHA==/oat/arm64/base.odex (com.getcapacitor.Bridge$1.run+104)
#16 pc 000000000167520c /system/framework/arm64/boot-framework.oat (android.os.Handler.dispatchMessage+76) (BuildId: 2954b28034c0608040a302a38819685a429d9a49)
#17 pc 000000000167e844 /system/framework/arm64/boot-framework.oat (android.os.Looper.loop+1540) (BuildId: 2954b28034c0608040a302a38819685a429d9a49)
#18 pc 0000000001677c20 /system/framework/arm64/boot-framework.oat (android.os.HandlerThread.run+400) (BuildId: 2954b28034c0608040a302a38819685a429d9a49)
#19 pc 0000000000137334 /apex/com.android.runtime/lib64/libart.so (art_quick_invoke_stub+548) (BuildId: d8ff78fda9077f8e6f85a96944cba214)
#20 pc 0000000000145fec /apex/com.android.runtime/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+244) (BuildId: d8ff78fda9077f8e6f85a96944cba214)
#21 pc 00000000004b16b4 /apex/com.android.runtime/lib64/libart.so (art::(anonymous namespace)::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, art::(anonymous namespace)::ArgArray*, art::JValue*, char const*)+104) (BuildId: d8ff78fda9077f8e6f85a96944cba214)
#22 pc 00000000004b27c8 /apex/com.android.runtime/lib64/libart.so (art::InvokeVirtualOrInterfaceWithJValues(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, jvalue const*)+416) (BuildId: d8ff78fda9077f8e6f85a96944cba214)
#23 pc 00000000004f3184 /apex/com.android.runtime/lib64/libart.so (art::Thread::CreateCallback(void*)+1176) (BuildId: d8ff78fda9077f8e6f85a96944cba214)
#24 pc 00000000000d6cb0 /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+36) (BuildId: 084c8a81b8c78e19cd9a1ff6208e77cf)
#25 pc 0000000000074eac /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: 084c8a81b8c78e19cd9a1ff6208e77cf)

@jas14
Copy link
Collaborator

jas14 commented Jun 16, 2021

Can reproduce when local Stockfish evaluation is turned on.

@rodrigoq, until this bug is fixed, you can work around it by turning off analysis on your phone before accessing that chapter - click the gear in the bottom left to access those settings.

@NoseKnowsAll
Copy link

I'm here to report this is happening with other studies as well. An android user was viewing my study (https://lichess.org/study/kI8ikTU4) and reported the exact same issue to me. I told them about this workaround, but is there any update on identifying/fixing the underlying issue?

@jas14
Copy link
Collaborator

jas14 commented Aug 31, 2021

Stockfish WASM (on the website) has the same issue when trying to analyze a board missing a king:

Uncaught RuntimeError: memory access out of bounds
    at <anonymous>:wasm-function[328]:0x3a9c1
    at <anonymous>:wasm-function[117]:0x11d65
    at <anonymous>:wasm-function[509]:0x6d053
    at <anonymous>:wasm-function[814]:0x9e86f
    at <anonymous>:wasm-function[813]:0x9e543
    at <anonymous>:wasm-function[535]:0x7df28
    at Xc.b.<computed> (stockfish.js:126)
    at A.dynCall_ii (stockfish.js:144)
    at Object.A.invokeEntryPoint (stockfish.js:36)
    at self.onmessage (stockfish.worker.js:1)

From the board editor, we simply don't allow analysis of a position without kings. I think we should:

  • disable engine analysis of study positions that are missing a king
  • probably catch exceptions at the Stockfish Capacitor plugin level? not sure how you'd handle SEGV in JNI or if you even should (but definitely don't think a segfault can be handled at the app level)

@NoseKnowsAll
Copy link

Nicely done figuring out the issue. From a purely user perspective, I think the expected behavior if there is a position with no king(s) on the board would be to result in a "-" evaluation, similar to what happens when you turn on the engine in a position that is already checkmate or stalemate. As a study creator myself, it's very convenient to be able to "study" positions without kings, so I don't think your first suggestion is optimal (although may be necessary temporarily if we think this is a pervasive issue).

Perhaps this means that the underlying issue is slightly broader than "app crashes after changing chapter on study" now though.

Secondary question: is this more of a Stockfish issue than a lichess issue? If SF can evaluate stalemated/checkmated positions with -, why not positions without kings?

@jas14
Copy link
Collaborator

jas14 commented Sep 1, 2021

I wouldn't call this a Stockfish issue - the ultimate goal in traditional or 960 chess is always to deliver checkmate. If the position is already terminated, I'd expect the engine to recognize the position as terminated. But if the position is totally nonsensical in the given variant - not just that a pawn starts on the back rank or something minor, but that there is no king to checkmate - I'm not surprised that it blows up. We just shouldn't be feeding the engine a position like that.

EDIT: To be clear, the first option doesn't mean you can't view studies on mobile where the position has no king - it would just mean you couldn't turn on engine analysis for that position/chapter.

@NoseKnowsAll
Copy link

I misunderstood your original plan, but the edit cleared it up. Yeah your fix seems like a reasonable solution to me too.

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 a pull request may close this issue.

3 participants