There's a crashing bug in this code somewhere. To duplicate the error, add a few attachments, then select the first one and delete them one by one by repeating pressing the delete key.