Open StillerHarpo opened 1 year ago
scrypt("pleaseletmein", "SodiumChloride", 1048576, 8, 1) = FAILED
This test needs 1 GiB of memory, and your system doesn't seem to have that much RAM+swap.
Maybe we need to add printing of strerror(errno)
after the FAILED
.
It has only 1 GiB and no swap. So it wasn't an armv7l. Some information about out of memory would be nice. Otherwise you can close this issue
I just ran into the same thing, but using qemu on a machine with plenty of RAM. I'm guessing rather running out of memory it's running out of address space on 32-bit ARM. Maybe that specific test should be skipped on 32-bit architectures?
I just ran into the same thing, but using qemu on a machine with plenty of RAM.
You didn't say how much RAM you allocated to the QEMU VM. I guess not plenty.
I'm guessing rather running out of memory it's running out of address space on 32-bit ARM. Maybe that specific test should be skipped on 32-bit architectures?
No, 1 GiB can generally be allocated just fine on 32-bit, and that worked in my tests.
We do need to improve the error reporting by this tests, or/and skip it by default, but because of low memory VMs - not because 32-bit systems exist.
For reference, I'm using qemu user mode emulation so there's no VM. I haven't been able to find information about any memory limits that apply to user mode emulation.
The command that shows the issue is: qemu-arm -strace test/alg-yescrypt
which fails with:
...
305468 mmap2(NULL,16780288,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS,-1,0) = 0x3ee4f000
305468 munmap(0x3ee4f000,16780288) = 0
305468 write(1,0x2f2b8,249)scrypt("pleaseletmein", "SodiumChloride", 16384, 8, 1) = 70 23 bd cb 3a fd 73 48 46 1c 06 cd 81 fd 38 eb fd a8 fb ba 90 4f 8e 3e a9 b5 43 f6 54 5d a1 f2 d5 43 29 55 61 3f 0f cf 62 d4 97 05 24 2a 9a f9 e6 1e 85 dc 0d 65 1e 40 df cf 01 7b 45 57 58 87
= 249
305468 mmap2(NULL,1073744896,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS,-1,0) = -1 errno=12 (Cannot allocate memory)
305468 write(1,0x2f2b8,66)scrypt("pleaseletmein", "SodiumChloride", 1048576, 8, 1) = FAILED
= 66
print_scrypt("pleaseletmein", "SodiumChloride", 512 * 1024, 8, 1);
(half as much memory) works fine.
I agree it's odd that it fails. The kernel seems intent to map memory below 0x4000_0000
where there is indeed not enough space. I haven't figured out why it doesn't try to use the space above that. According to /proc/*/maps
there seems to be enough unused space. I'll let you know if I ever figure it out.
Thank you, @Lucus16. OK, yes, this is a reason for us to consider skipping this test.
I found the likely reason: The man page of mmap describes the MAP_32BIT flag as follows:
Put the mapping into the first 2 Gigabytes of the process address space. This flag is only supported on x86-64, for 64-bit programs. It was added to allow thread stacks to be allocated somewhere in the first 2GB of memory, so as to improve context-switch performance on some early 64-bit processors. Modern x86-64 processors no longer have this performance problem, so use of this flag is not required on those systems. The MAP_32BIT flag is ignored when MAP_FIXED is set.
It's likely that qemu uses this flag when emulating 32-bit binaries on 64-bit systems. 2GB is enough in principle for the 1GB allocation, but based on the memory map I'm reading from the process, it appears some stuff was already allocated in the middle, leaving insufficient space at either side for a 1GB allocation.
I've also hit this, in the official NixOS sd card image for armv6 :/
The test for yesscrypt fails on an armv7l rashberry pi 2