Opened 2 years ago

Last modified 2 years ago

#4725 new defect

The update function of AdblockPlusEngine leaks a Windows thread instance

Reported by: eric@… Assignee:
Priority: Unknown Milestone:
Module: Adblock-Plus-for-Internet-Explorer Keywords:
Cc: oleksandr Blocked By:
Blocking: Platform: Internet Explorer
Ready: no Confidential: no
Tester: Unknown Verified working: no
Review URL(s):

Description

Defective behavior

The function Updater::Update in AdblockPlusEngine creates a detached thread to run the download for an update. It system-calls CreateThread, which returns a thread handle, but discards the return value. This leaks the thread.

From MSDN:

The number of threads a process can create is limited by the available virtual memory. By default, every thread has one megabyte of stack space.
[...]
The thread object remains in the system until the thread has terminated and all handles to it have been closed through a call to CloseHandle.

How to reproduce

The defect triggers every time an update download occurs.

How to cure

Using C++11 <thread> library is sufficient. The thread object can be created and detached, after which the runtime library will handle system clean-up when the thread terminates.

Change History (2)

comment:1 Changed 2 years ago by eric@…

  • Summary changed from The update function of AdblockPlusEngine leaks a Windows thread handle to The update function of AdblockPlusEngine leaks a Windows thread instance

comment:2 Changed 2 years ago by sergz

I think that instead of creating of yet one thread as it is now we should rather change the code to use currently available message loop (ABPAtlModule::RunMessageLoop).

Note: See TracTickets for help on using tickets.