Closed kevinjwalters closed 4 years ago
I have no need for lengths above 64 btw!
The soft device must only support up to 64 bytes here: https://github.com/adafruit/circuitpython/blob/master/ports/nrf/common-hal/os/__init__.c#L70
We should split it up as needed.
Based on previous mention of the SAMD51 having this hardware feature too I thought I'd try a nearby Feather M4 Express. I put 4.1.2
on that and I've noticed that works ok with numbers larger than 64.
It does blow up with -1
and 30000
. I hunted around the upper magic value and it doesn't look like a fixed value but perhaps one related to memory. It goes into hard fault handler and says The CircuitPython stack was corrupted because the heap was too small.
I doubt many people are going to need large amounts of random data in one go but this could cause confusing crashes for bugs where the wrong number of bytes are sometimes requested from urandom()
.
Perhaps more worringly after a second os.urandom()
crash on that board on my trusty Win8.1 desktop the usb starts misbehaving and the serial port (driver is Adafruit Industries LLC
/ 13/01/2019
/ 10.2.4.0
) and CIRCUITPY
drive no longer work. Any other Adafruit boards then don't work and that together with a ponderous reboot to Win 8.1 suggests there's a driver issue here. I had a quick try on a Win 10 laptop and can't reproduce usb issue there.
Fixed by #2461.
I was playing around in CircuitPython to work out the possible and best ways to detect if
os.urandom
is present. It turns out it's always present so I then started looking at the exceptions that it throws on platforms with no hardware, e.g. SAMD21 (M0) like the CPX. I noticed during that experimentation that even on a CPB where there is hardware support this fails for values above 64. Either that's a bug or it's a confusing use of theNotImplementedError
exception?For comparison of the exception, CPX output: