SeedSigner / seedsigner

Use an air-gapped Raspberry Pi Zero to sign for Bitcoin transactions! (and do other cool stuff)
MIT License
721 stars 168 forks source link

Creating seed via image entropy w/ another seed loaded raises exception #450

Closed jdlcdl closed 1 year ago

jdlcdl commented 1 year ago

As of commit beaf4ae which we've been testing for 1 week, I've experienced an exception while one seed was already loaded and trying to create a new seed from image entropy. It's a DireWarning like:

System Error ValueError "Image.py 1505 in paste", "cannot determine region size; use 4 item box"

I've just updated my testing head for Nick's recent merges, to commit 8b5c8af5 9451a9d 2244509f and the above error remains.

Image.py is part of PIL, so it's a hint, but not so helpful. A backtrace from a Manual Installation pi2 w/ console output looks like:

ValueError: cannot determine region size; use 4-item box
cannot determine region size; use 4-item box
Traceback (most recent call last):
  File "/home/pi/seedsigner-dev/src/seedsigner/controller.py", line 307, in start
    next_destination = next_destination.run()
  File "/home/pi/seedsigner-dev/src/seedsigner/views/view.py", line 161, in run
    return self._run_view()
  File "/home/pi/seedsigner-dev/src/seedsigner/views/view.py", line 156, in _run_view
    return self.view.run()
  File "/home/pi/seedsigner-dev/src/seedsigner/views/tools_views.py", line 71, in run
    ret = ToolsImageEntropyLivePreviewScreen().display()
  File "/home/pi/seedsigner-dev/src/seedsigner/gui/screens/screen.py", line 59, in display
    raise e
  File "/home/pi/seedsigner-dev/src/seedsigner/gui/screens/screen.py", line 56, in display
    return self._run()
  File "/home/pi/seedsigner-dev/src/seedsigner/gui/screens/tools_screens.py", line 68, in _run
    self.renderer.canvas.paste(frame)
  File "/home/pi/.envs/seedsigner-dev-env/lib/python3.10/site-packages/PIL/Image.py", line 1505, in paste
    raise ValueError("cannot determine region size; use 4-item box")
ValueError: cannot determine region size; use 4-item box

On the pi0 after regenerating a new pre-release test image in a running pre-built-for-pi0 container, like:

docker exec -it seedsigner-os_build-images_1 bash

./build.sh --pi0 --no-clean --app-commit-id="2244509"
...
64c90f00d4f1d340cb0b0ecb0c8704ee1be745927fc1cf1936e808b4c8220a20  /opt/../images/seedsigner_os.2244509.pi0.img

... the same exception is raised in seedsigner-os running on pi0, but the Image.py line number is 1711.

I've tested this a bunch of times now, maybe it has nothing to do with a seed being loaded and more to do with a repetition of create-seed-via-image-entropy. It works the first time, usually not again but sometimes it works without raising this exception.

jdlcdl commented 1 year ago

This morning, Nick suggested changing "gpu_mem" from 64 to 128 in config.txt on the pi0. This worked for me on pi0, I can no longer reproduce this error.

However, on Raspi-OS I have always used only 16mb for gpu_mem. Changing to 128 and even 256 does NOT resolve the error. I still believe that we should track down exactly where this became a problem. I suspect it's recent, but I'm not sure, It's not a regular habit of mine to load more than one seed at a time... but I've certainly done this in the past and never seen this error before.

kdmukai commented 1 year ago

I ran into that maybe a month ago but at the time it was because that paste operation was trying to paste None instead of image data. It was just a bug in my in-progress code at the time that I resolved. No clue yet what might be causing it this time.

jdlcdl commented 1 year ago

Keith asked me "sticky joystick click?", and this seems to answer everything.

I cannot reproduce the error, on pi0-ss-os nor pi2-raspi-os, without a press-and-hold. If Im careful to quick clickly, I cannot reproduce it at all, while a long-press reproduces it every time.