bits0rcerer / wellenbrecher

🌊 A capable pixelflut server written in Rust 🦀
GNU General Public License v3.0
11 stars 0 forks source link

Segfault after restart with increased canvas size #2

Closed GKnirps closed 10 months ago

GKnirps commented 10 months ago

Hi, I tried out wellenbrecher, and I get a segfault under certain circumstances.

Steps to reproduce:

  1. Start wellenbrecher with default parameters
  2. stop wellenbrecher
  3. start wellenbrecher with a larger screen size (e.g. 1920×1080)
  4. let a client write all over the canvas

Expected result: The pixels get printed in the expected area. Actual result: wellenbrecher gets terminated because of a segmentation fault.

Additionally: The canvas is persisted between restarts. I tried to figure out where and how to reset it, but I was unsuccessful. Maybe that can go into the README.md as well?

GKnirps commented 10 months ago

I fiddled around with the code a bit. In wellenbrecher-canvas/srs/lib.rs, in Canvas::open, the variable size is larger than the actual size of shared_memory after the initialization of the shared memory. Later, the shared memory is accessed as if it had the size of size, which leads to memory corruption.

bits0rcerer commented 10 months ago

Hi, thanks for giving wellenbrecher a try :)


Yep, you are right.

Any component (wellenbrecher, seebruecke, …) will create a shared memory if there is no present ( :thinking: maybe only wellenbrecher should be able to do that?).

There are mechanics in wellenbrecher to remove that shared memory on exit but they did not receive much attention yet.

wellenbrecher --help
# …
# -l, --canvas-file-link <CANVAS_FILE_LINK>
#          Canvas shared memory file link [default: /tmp/wellenbrecher-canvas]
#     --keep-canvas-file-link
#          Keep canvas shared memory file link
# …

/tmp/wellenbrecher-canvas contains the shared memory that you can find under /dev/shm/.

cat /tmp/wellenbrecher-canvas
# /shmem_<some id>

Remove the canvas manually:

sudo rm "/dev/shm$(cat /tmp/wellenbrecher-canvas)" /tmp/wellenbrecher-canvas

The canvas is persisted between restarts

Yes that is actually a feature :D

bits0rcerer commented 10 months ago

TODOs: