Opened on 12/09/2016 at 06:37:43 PM

Last modified on 01/09/2017 at 09:23:14 AM

#4725 new defect

The update function of AdblockPlusEngine leaks a Windows thread instance

Reported by: eric@adblockplus.org 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.

Attachments (0)

Change History (2)

comment:1 Changed on 12/09/2016 at 06:38:09 PM by eric@adblockplus.org

  • 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 on 01/09/2017 at 09:23:14 AM 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).

Add Comment

Modify Ticket

Change Properties
Action
as new .
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from (none).
Next status will be 'reviewing'.
 
Note: See TracTickets for help on using tickets.