Event handle leak in mailsync.exe on Windows


I use Mailspring for six email accounts, and have noticed that mailsync.exe creates a lot of handles (the handle counter I have enabled in Process Hacker keeps going up; sometimes I reckon about 100k handles for all the mailsync processes in total). These handles will go away on restarting MailSpring (which, in turn, restarts all the mailsync.exe processes).

I have attached to a couple of processes via windbg and found that they use 15k and 25k event handles, respectively. Not sure if this is during normal operation or not, but I believe that the event handles are leaking.

To Reproduce…

Steps to reproduce the behavior:

  1. Have mailsync.exe running for several days
  2. Attach to a mailsync.exe instance via windbg
  3. Enter a command !handle
  4. Note the event handle count

In one case, I had the following metrics:

Type           	Count
None           	10
Event          	26910
Section        	1
File           	28
Directory      	4
Mutant         	3
WindowStation  	2
Semaphore      	31
Key            	17
Thread         	18
Desktop        	1
IoCompletion   	7
TpWorkerFactory	5
ALPC Port      	4
WaitCompletionPacket	14

Expected Behavior

mainsync.exe shouldn’t leak resources even if running for several days.


  • OS and Version: Windows 10 2004
  • Installation Method: via Windows installer
  • Mailspring Version: 1.8.0-8983dca2

Additional Context

I’ve found a GitHub issue mentioning a similar leak, marked as fixed in 2017: Mailsync leaks handles · Issue #388 · Foundry376/Mailspring · GitHub

Though I still observe the leaks (have to restart Mailspring every several days to reset the handle counter).