Citando Timo Sirainen <tss@iki.fi>:
> I guess it works around some other bug then. If it's a memory-related
> bug you could also see if valgrind complains something:
> 
> protocol imap {
>   ..
>   mail_executable = /usr/bin/valgrind /usr/local/libexec/dovecot/imap
> }

Here is the output (I cloned the http://hg.dovecot.org/dovecot-1.2 and made no changes to this test):

ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 123 from 2)
malloc/free: in use at exit: 94,040 bytes in 1,032 blocks.
malloc/free: 1,704 allocs, 672 frees, 1,042,476 bytes allocated.
For counts of detected errors, rerun with: -v
searching for pointers to 1,032 not-freed blocks.
checked 111,072 bytes.

88,161 (328 direct, 87,833 indirect) bytes in 1 blocks are definitely lost in loss record 30 of 45
   at 0x4C24384: calloc (vg_replace_malloc.c:397)
   by 0x4AF165: pool_system_malloc (mempool-system.c:77)
   by 0x63E0DA2: ???
   by 0x63DF91D: ???
   by 0x5DBAF27: ???
   by 0x5DBBE50: ???
   by 0x46BBFF: mailbox_transaction_begin (mail-storage.c:794)
   by 0x42976F: imap_search_start (imap-search.c:540)
   by 0x4206D7: cmd_search (cmd-search.c:50)
   by 0x4232CB: client_command_input (client.c:608)
   by 0x423389: client_command_input (client.c:657)
   by 0x4239F4: client_handle_input (client.c:698)

LEAK SUMMARY:
   definitely lost: 328 bytes in 1 blocks.
   indirectly lost: 87,833 bytes in 1,016 blocks.
     possibly lost: 0 bytes in 0 blocks.
   still reachable: 5,879 bytes in 15 blocks.
        suppressed: 0 bytes in 0 blocks.
Reachable blocks (those to which a pointer was found) are not shown.
To see them, rerun with: --leak-check=full --show-reachable=yes
