Does string literal have a maximum size?

On both ARM64 and x86_64, it's impossible to actually overflow that number with real allocation sizes, because the CPU actually only supports a 48-bit address space. The whole upper two bytes, including the sign bit, are always zero.

On 32-bit general purpose platforms, it's a bit more complicated. In a lot of operating systems, the upper half of the address space is reserved by the OS, which also happens to be the "negative numbers" in an isize representation. So, it's still impossible to overflow that number before running out of address space.

So you have to be running on 32-bit, bare metal, and you might have to use page table trickery to avoid slamming into the PCI hole, in order to allocate a string that takes up half of your address space.