Infinite loop and stack overflow when IMAP server repeatedly responds with BAD to CAPABILITY command
Sorry, I should have made that confidential from the start. This obsoletes issue #47 (closed).
Just got the following trace:
...
C: 12227 CAPABILITY\r\n
S: 12227 BAD unknown command.\r\n
C: 12228 CAPABILITY\r\n
S: 12228 BAD unknown command.\r\n
C: 12229 CAPABILITY\r\n
S: 12229 BAD unknown command.\r\n
...
Balsa then crashes with a stack overflow Stack overflow in thread #1: can't grow stack to 0x1ffe801000
.
==1962== Memcheck, a memory error detector
==1962== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==1962== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==1962== Command: /home/demo/.nix-profile/bin/balsa
==1962==
==1962== Memcheck, a memory error detector
==1962== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==1962== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==1962== Command: /nix/store/6qqi8zmkv8kc333f8ma74s0czalwz25y-balsa-2.5.9/bin/.balsa-wrapped
==1962==
==1967== Warning: invalid file descriptor 1036 in syscall close()
==1967== Warning: invalid file descriptor 1037 in syscall close()
==1967== Warning: invalid file descriptor 1038 in syscall close()
==1967== Warning: invalid file descriptor 1039 in syscall close()
==1967== Use --log-fd=<number> to select an alternative log fd.
==1967== Warning: invalid file descriptor 1040 in syscall close()
==1967== Warning: invalid file descriptor 1041 in syscall close()
==1967== Warning: invalid file descriptor 1042 in syscall close()
==1966==
==1966== HEAP SUMMARY:
==1966== in use at exit: 1,722,866 bytes in 16,001 blocks
==1966== total heap usage: 217,638 allocs, 201,637 frees, 12,666,773 bytes allocated
==1966==
==1966== LEAK SUMMARY:
==1966== definitely lost: 2,168 bytes in 4 blocks
==1966== indirectly lost: 121 bytes in 2 blocks
==1966== possibly lost: 2,664 bytes in 27 blocks
==1966== still reachable: 1,648,513 bytes in 15,399 blocks
==1966== of which reachable via heuristic:
==1966== length64 : 3,248 bytes in 59 blocks
==1966== newarray : 2,064 bytes in 49 blocks
==1966== suppressed: 0 bytes in 0 blocks
==1966== Rerun with --leak-check=full to see details of leaked memory
==1966==
==1966== For lists of detected and suppressed errors, rerun with: -s
==1966== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
==1969== Warning: invalid file descriptor 1036 in syscall close()
==1969== Warning: invalid file descriptor 1037 in syscall close()
==1969== Warning: invalid file descriptor 1038 in syscall close()
==1969== Warning: invalid file descriptor 1039 in syscall close()
==1969== Use --log-fd=<number> to select an alternative log fd.
==1969== Warning: invalid file descriptor 1040 in syscall close()
==1969== Warning: invalid file descriptor 1041 in syscall close()
==1969== Warning: invalid file descriptor 1042 in syscall close()
==1968==
==1968== HEAP SUMMARY:
==1968== in use at exit: 1,723,416 bytes in 16,012 blocks
==1968== total heap usage: 217,649 allocs, 201,637 frees, 12,667,323 bytes allocated
==1968==
==1968== LEAK SUMMARY:
==1968== definitely lost: 2,168 bytes in 4 blocks
==1968== indirectly lost: 121 bytes in 2 blocks
==1968== possibly lost: 2,664 bytes in 27 blocks
==1968== still reachable: 1,649,063 bytes in 15,410 blocks
==1968== of which reachable via heuristic:
==1968== length64 : 3,248 bytes in 59 blocks
==1968== newarray : 2,064 bytes in 49 blocks
==1968== suppressed: 0 bytes in 0 blocks
==1968== Rerun with --leak-check=full to see details of leaked memory
==1968==
==1968== For lists of detected and suppressed errors, rerun with: -s
==1968== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
==1971== Warning: invalid file descriptor 1036 in syscall close()
==1971== Warning: invalid file descriptor 1037 in syscall close()
==1971== Warning: invalid file descriptor 1038 in syscall close()
==1971== Warning: invalid file descriptor 1039 in syscall close()
==1971== Use --log-fd=<number> to select an alternative log fd.
==1971== Warning: invalid file descriptor 1040 in syscall close()
==1971== Warning: invalid file descriptor 1041 in syscall close()
==1971== Warning: invalid file descriptor 1042 in syscall close()
==1970==
==1970== HEAP SUMMARY:
==1970== in use at exit: 1,723,548 bytes in 16,014 blocks
==1970== total heap usage: 217,651 allocs, 201,637 frees, 12,667,455 bytes allocated
==1970==
==1970== LEAK SUMMARY:
==1970== definitely lost: 2,168 bytes in 4 blocks
==1970== indirectly lost: 121 bytes in 2 blocks
==1970== possibly lost: 2,664 bytes in 27 blocks
==1970== still reachable: 1,649,195 bytes in 15,412 blocks
==1970== of which reachable via heuristic:
==1970== length64 : 3,248 bytes in 59 blocks
==1970== newarray : 2,064 bytes in 49 blocks
==1970== suppressed: 0 bytes in 0 blocks
==1970== Rerun with --leak-check=full to see details of leaked memory
==1970==
==1970== For lists of detected and suppressed errors, rerun with: -s
==1970== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
==1973== Warning: invalid file descriptor 1036 in syscall close()
==1973== Warning: invalid file descriptor 1037 in syscall close()
==1973== Warning: invalid file descriptor 1038 in syscall close()
==1973== Warning: invalid file descriptor 1039 in syscall close()
==1973== Use --log-fd=<number> to select an alternative log fd.
==1973== Warning: invalid file descriptor 1040 in syscall close()
==1973== Warning: invalid file descriptor 1041 in syscall close()
==1973== Warning: invalid file descriptor 1042 in syscall close()
==1972==
==1972== HEAP SUMMARY:
==1972== in use at exit: 1,723,668 bytes in 16,017 blocks
==1972== total heap usage: 217,654 allocs, 201,637 frees, 12,667,575 bytes allocated
==1972==
==1972== LEAK SUMMARY:
==1972== definitely lost: 2,168 bytes in 4 blocks
==1972== indirectly lost: 121 bytes in 2 blocks
==1972== possibly lost: 2,664 bytes in 27 blocks
==1972== still reachable: 1,649,315 bytes in 15,415 blocks
==1972== of which reachable via heuristic:
==1972== length64 : 3,248 bytes in 59 blocks
==1972== newarray : 2,064 bytes in 49 blocks
==1972== suppressed: 0 bytes in 0 blocks
==1972== Rerun with --leak-check=full to see details of leaked memory
==1972==
==1972== For lists of detected and suppressed errors, rerun with: -s
==1972== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
==1975== Warning: invalid file descriptor 1036 in syscall close()
==1975== Warning: invalid file descriptor 1037 in syscall close()
==1975== Warning: invalid file descriptor 1038 in syscall close()
==1975== Warning: invalid file descriptor 1039 in syscall close()
==1975== Use --log-fd=<number> to select an alternative log fd.
==1975== Warning: invalid file descriptor 1040 in syscall close()
==1975== Warning: invalid file descriptor 1041 in syscall close()
==1975== Warning: invalid file descriptor 1042 in syscall close()
==1974==
==1974== HEAP SUMMARY:
==1974== in use at exit: 1,723,790 bytes in 16,020 blocks
==1974== total heap usage: 217,657 allocs, 201,637 frees, 12,667,697 bytes allocated
==1974==
==1974== LEAK SUMMARY:
==1974== definitely lost: 2,168 bytes in 4 blocks
==1974== indirectly lost: 121 bytes in 2 blocks
==1974== possibly lost: 2,664 bytes in 27 blocks
==1974== still reachable: 1,649,437 bytes in 15,418 blocks
==1974== of which reachable via heuristic:
==1974== length64 : 3,248 bytes in 59 blocks
==1974== newarray : 2,064 bytes in 49 blocks
==1974== suppressed: 0 bytes in 0 blocks
==1974== Rerun with --leak-check=full to see details of leaked memory
==1974==
==1974== For lists of detected and suppressed errors, rerun with: -s
==1974== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Network is available (Fri 27 Nov 2020 04:11:15 PM UTC)
==1962== Stack overflow in thread #1: can't grow stack to 0x1ffe801000
==1962==
==1962== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==1962== Access not within mapped region at address 0x1FFE801FE8
==1962== Stack overflow in thread #1: can't grow stack to 0x1ffe801000
==1962== at 0xA4284C4: __vfprintf_internal (in /nix/store/6m2k8kx8h216jlx9dg3lp4m90bz05yck-glibc-2.30/lib/libc-2.30.so)
==1962== If you believe this happened as a result of a stack
==1962== overflow in your program's main thread (unlikely but
==1962== possible), you can try to increase the size of the
==1962== main thread stack using the --main-stacksize= flag.
==1962== The main thread stack size used in this run was 8388608.
==1962== Stack overflow in thread #1: can't grow stack to 0x1ffe801000
==1962==
==1962== Process terminating with default action of signal 11 (SIGSEGV)
==1962== Access not within mapped region at address 0x1FFE801FE0
==1962== Stack overflow in thread #1: can't grow stack to 0x1ffe801000
==1962== at 0x482E105: _vgnU_freeres (in /nix/store/v1mqcsqgrgnq9j32zvjidmk310mgjmh1-valgrind-3.15.0/lib/valgrind/vgpreload_core-amd64-linux.so)
==1962== If you believe this happened as a result of a stack
==1962== overflow in your program's main thread (unlikely but
==1962== possible), you can try to increase the size of the
==1962== main thread stack using the --main-stacksize= flag.
==1962== The main thread stack size used in this run was 8388608.
==1962==
==1962== HEAP SUMMARY:
==1962== in use at exit: 140,502,669 bytes in 2,832,050 blocks
==1962== total heap usage: 29,129,992 allocs, 26,297,892 frees, 1,010,117,262 bytes allocated
==1962==
==1962== LEAK SUMMARY:
==1962== definitely lost: 20,624 bytes in 11 blocks
==1962== indirectly lost: 18,589 bytes in 769 blocks
==1962== possibly lost: 41,972 bytes in 1,169 blocks
==1962== still reachable: 139,580,460 bytes in 2,824,078 blocks
==1962== of which reachable via heuristic:
==1962== length64 : 12,992 bytes in 182 blocks
==1962== newarray : 2,368 bytes in 68 blocks
==1962== suppressed: 0 bytes in 0 blocks
==1962== Rerun with --leak-check=full to see details of leaked memory
==1962==
==1962== For lists of detected and suppressed errors, rerun with: -s
==1962== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Segmentation fault (core dumped)
I have not the time to look more closely into it. Please make the issue public whenever you like.