Fix crash with large objects (#7919)

See comments for details.