canselcik / libremarkable

The only public framework for developing applications with native refresh support for Remarkable Tablet
MIT License
607 stars 57 forks source link

Built-in rm2fb client corrupts the server state #88

Closed LoganDark closed 2 years ago

LoganDark commented 2 years ago

Somehow libremarkable's rm2fb client implementation is causing the server to stop working after executing the application once. The server no longer understands messages from either libremarkable apps OR the official rm2fb client - it is completely defunct. These log messages occur when the server becomes corrupteed:

reMarkable env[18332]: Error, unknown message type
reMarkable env[18332]: Error recv msgbuf: Invalid argument
reMarkable env[18332]: Error, unknown message type
reMarkable env[18332]: Error recv msgbuf: Invalid argument
reMarkable env[18332]: Error, unknown message type
reMarkable env[18332]: Error recv msgbuf: Invalid argument
reMarkable env[18332]: Error, unknown message type
reMarkable env[18332]: Error recv msgbuf: Invalid argument
reMarkable env[18332]: Error, unknown message type
reMarkable env[18332]: Error recv msgbuf: Invalid argument

Restarting rm2fb allows it to work again.

Forcing libremarkable to use /dev/fb0 and running it under LD_PRELOAD=/opt/rm2fb/librm2fb_client.so.1.0.1 does not exhibit the issue. The application can be run any number of times without affecting the server. The issue only occurs when libremarkable is allowed to use its built-in client.

Codex version 2.11.0.442 reMarkable 2 model RM110 rm2fb server invocation: /usr/bin/env LD_PRELOAD=/opt/rm2fb/librm2fb_server.so.1.0.1 /usr/bin/xochitl

LoganDark commented 2 years ago

This Rust file exhibits the issue:

use libremarkable::device::CURRENT_DEVICE;
use libremarkable::framebuffer::core::Framebuffer;
use libremarkable::framebuffer::FramebufferBase;

fn main() {
    Framebuffer::from_path(CURRENT_DEVICE.get_framebuffer_path());
}

Binary: corrupt.zip

bkirwi commented 2 years ago

...which is wild, since of course many apps include that code. Perhaps a bug introduced very recently, something triggered by unusual use of the framebuffer, or some environmental thing?

I can try and repro, but maybe not for a couple days depending.

LinusCDE commented 2 years ago

Good catch. Seems to be an issue with the built-in client. Found some weird crashing of the rm2fb stuff (including other apps wanting to use it) when testing the newest plato release with it. I disabled it by default there, but didn't have the time yet, to investigate further. Will do so now i guess.

Full discord message with some rationale why I didn't create this issue 2 days ago. Around that message might also be more context regarding finding / investigating this bug.