ddvk / remarkable2-framebuffer

remarkable2 framebuffer reversing
MIT License
283 stars 22 forks source link

v0.0.3 crashes koreader on startup #52

Closed snelg closed 3 years ago

snelg commented 3 years ago

Only crashes if it's a fresh koreader installation, or more particularly if koreader/cache/fontinfo.dat does not yet exist. See https://github.com/toltec-dev/toolchain/issues/8

raisjn commented 3 years ago

thank you, didn't see that issue before - that is a nice investigation!

snelg commented 3 years ago

didn't see that issue before

Yeah, guess I should have cross-posted in the first place :)

raisjn commented 3 years ago

this might block stable merge of rm2fb until we figure it out or use old toolchain

matteodelabre commented 3 years ago

Thanks for reporting @snelg! This does not seem to be linked to the toolchain or to recent changes in rm2fb though, since I managed to reproduce the crash using rm2fb 1.0.0-7 from Toltec stable.

Logs with existing /opt/koreader/cache/fontinfo.dat file ``` --------------------------------------------- launching... _ _____ ____ _ | |/ / _ \| _ \ ___ __ _ __| | ___ _ __ | ' / | | | |_) / _ \/ _` |/ _` |/ _ \ '__| | . \ |_| | _ < __/ (_| | (_| | __/ | |_|\_\___/|_| \_\___|\__,_|\__,_|\___|_| It's a scroll... It's a codex... It's KOReader! [*] Current time: 03/03/21-13:13:29 [*] Version: v2020.12 ffi.load: blitbuffer ffi.load (assisted searchpath): ./libs/libblitbuffer.so ffi.load: SDL2 ffi.load (warning): libSDL2.so: cannot open shared object file: No such file or directory ffi.load: libSDL2-2.0.so ffi.load (warning): libSDL2-2.0.so: cannot open shared object file: No such file or directory ffi.load: libSDL2-2.0.so.0 ffi.load (warning): libSDL2-2.0.so.0: cannot open shared object file: No such file or directory SDL2 not loaded: ./setupkoenv.lua:27: Not able to load dynamic library: libSDL2-2.0.so.0 03/03/21-13:13:29 INFO deviceType: reMarkable 2.0 [ko-input] Forked off fake event generator(pid:466). 03/03/21-13:13:29 INFO initializing for device reMarkable 2 03/03/21-13:13:29 INFO framebuffer resolution: { ["w"] = 1404, ["h"] = 1872, } ffi.load: libs/libmupdf.so ffi.load: libs/libwrap-mupdf.so ffi.load: libs/libfreetype.so.6 ffi.load: libs/libharfbuzz.so.0 03/03/21-13:13:30 INFO opening file /opt/koreader/help/quickstart-en-v2020.12.html 03/03/21-13:13:30 INFO Loading plugins from directory: plugins ffi.load: sqlite3 ffi.load (assisted searchpath): ./libs/libsqlite3.so 03/03/21-13:13:30 INFO Plugin plugins/autofrontlight.koplugin/main.lua has been disabled. 03/03/21-13:13:30 INFO Plugin plugins/keepalive.koplugin/main.lua has been disabled. 03/03/21-13:13:30 INFO Plugin plugins/SSH.koplugin/main.lua has been disabled. 03/03/21-13:13:30 INFO Plugin plugins/timesync.koplugin/main.lua has been disabled. ffi.load: z ffi.load (assisted searchpath): ./libs/libz.so.1 03/03/21-13:13:30 INFO Plugin plugins/autostandby.koplugin/main.lua has been disabled. 03/03/21-13:13:30 INFO Plugin plugins/hello.koplugin/main.lua has been disabled. 03/03/21-13:13:30 INFO RD loaded plugin autosuspend at plugins/autosuspend.koplugin 03/03/21-13:13:30 INFO RD loaded plugin autoturn at plugins/autoturn.koplugin 03/03/21-13:13:30 INFO RD loaded plugin backgroundrunner at plugins/backgroundrunner.koplugin 03/03/21-13:13:30 INFO RD loaded plugin batterystat at plugins/batterystat.koplugin 03/03/21-13:13:30 INFO RD loaded plugin calibre at plugins/calibre.koplugin 03/03/21-13:13:30 INFO RD loaded plugin coverbrowser at plugins/coverbrowser.koplugin 03/03/21-13:13:30 INFO RD loaded plugin coverimage at plugins/coverimage.koplugin 03/03/21-13:13:30 INFO RD loaded plugin docsettingtweak at plugins/docsettingtweak.koplugin 03/03/21-13:13:30 INFO RD loaded plugin evernote at plugins/evernote.koplugin 03/03/21-13:13:30 INFO RD loaded plugin gestures at plugins/gestures.koplugin 03/03/21-13:13:30 INFO RD loaded plugin goodreads at plugins/goodreads.koplugin 03/03/21-13:13:30 INFO RD loaded plugin kosync at plugins/kosync.koplugin 03/03/21-13:13:30 INFO RD loaded plugin movetoarchive at plugins/movetoarchive.koplugin 03/03/21-13:13:30 INFO RD loaded plugin newsdownloader at plugins/newsdownloader.koplugin 03/03/21-13:13:30 INFO RD loaded plugin perceptionexpander at plugins/perceptionexpander.koplugin 03/03/21-13:13:30 INFO RD loaded plugin profiles at plugins/profiles.koplugin 03/03/21-13:13:30 INFO RD loaded plugin qrclipboard at plugins/qrclipboard.koplugin 03/03/21-13:13:30 INFO RD loaded plugin readtimer at plugins/readtimer.koplugin 03/03/21-13:13:30 INFO RD loaded plugin send2ebook at plugins/send2ebook.koplugin 03/03/21-13:13:30 INFO RD loaded plugin statistics at plugins/statistics.koplugin 03/03/21-13:13:30 INFO RD loaded plugin systemstat at plugins/systemstat.koplugin 03/03/21-13:13:30 INFO RD loaded plugin terminal at plugins/terminal.koplugin 03/03/21-13:13:30 INFO RD loaded plugin texteditor at plugins/texteditor.koplugin 03/03/21-13:13:30 INFO RD loaded plugin wallabag at plugins/wallabag.koplugin 03/03/21-13:13:30 INFO RD loaded plugin zsync at plugins/zsync.koplugin 03/03/21-13:13:30 INFO ReaderStatistics: Initializing average time per page at 50% of the max value, i.e., 60 ```
Logs with missing /opt/koreader/cache/fontinfo.dat file ``` --------------------------------------------- launching... _ _____ ____ _ | |/ / _ \| _ \ ___ __ _ __| | ___ _ __ | ' / | | | |_) / _ \/ _` |/ _` |/ _ \ '__| | . \ |_| | _ < __/ (_| | (_| | __/ | |_|\_\___/|_| \_\___|\__,_|\__,_|\___|_| It's a scroll... It's a codex... It's KOReader! [*] Current time: 03/03/21-13:12:23 [*] Version: v2020.12 ffi.load: blitbuffer ffi.load (assisted searchpath): ./libs/libblitbuffer.so ffi.load: SDL2 ffi.load (warning): libSDL2.so: cannot open shared object file: No such file or directory ffi.load: libSDL2-2.0.so ffi.load (warning): libSDL2-2.0.so: cannot open shared object file: No such file or directory ffi.load: libSDL2-2.0.so.0 ffi.load (warning): libSDL2-2.0.so.0: cannot open shared object file: No such file or directory SDL2 not loaded: ./setupkoenv.lua:27: Not able to load dynamic library: libSDL2-2.0.so.0 03/03/21-13:12:23 INFO deviceType: reMarkable 2.0 [ko-input] Forked off fake event generator(pid:455). 03/03/21-13:12:23 INFO initializing for device reMarkable 2 03/03/21-13:12:23 INFO framebuffer resolution: { ["w"] = 1404, ["h"] = 1872, } ffi.load: libs/libmupdf.so ffi.load: libs/libwrap-mupdf.so ffi.load: libs/libfreetype.so.6 ffi.load: libs/libharfbuzz.so.0 /opt/bin/rm2fb-client: line 3: 454 Segmentation fault (core dumped) LD_PRELOAD=/opt/lib/librm2fb_client.so.1.0.0 $* ```
raisjn commented 3 years ago

to understand: does it crash on the second run? is this something that is automatically handled since koreader.sh has a loop in it?

matteodelabre commented 3 years ago

To produce the logs above I ran rm2fb-client ./reader.lua directly from the /opt/koreader directory. The first log file corresponds to a successful KOReader run, the second file corresponds to a crash. The koreader.sh wrapper seems to generate the /opt/koreader/cache/fontinfo.dat file when it’s missing (not sure how yet), so the app does not crash.

matteodelabre commented 3 years ago

Setting LD_LIBRARY_PATH to ./libs: (as done by the koreader.sh wrapper) seems to fix it. So the following command does not crash, even if the fontinfo.dat file is missing:

$ LD_LIBRARY_PATH=./libs: rm2fb-client ./reader.lua

Comparing strace logs shows that, without the flag, both the system /usr/lib/libharfbuzz.so.0 library and then the local /opt/koreader/libs/libharfbuzz.so.0 library get loaded. With the flag, only the local one gets loaded.

matteodelabre commented 3 years ago

It looks like I hit a bug that shadowed another one here. Running LD_LIBRARY_PATH=./libs: LD_PRELOAD="/path/to/librm2fb_client.so.1.0.0" ./reader.lua with the latest rm2fb release (v0.0.3 downloaded from this repo’s releases) does result in a crash, whereas it did not crash using the earlier rm2fb release. So there does seem to be a regression introduced in rm2fb. I’ll investigate the segfault.

matteodelabre commented 3 years ago

Here’s my hypothesis: a change introduced in the toolchain cancels the effect of the LD_LIBRARY_PATH environment variable. Evidence:

Eeems commented 3 years ago

@NiLuJe pinging you, as you might have some insight.

NiLuJe commented 3 years ago

c.f., my answers in https://github.com/toltec-dev/toolchain/issues/8, which follow the same train of thought as @matteodelabre ;)