erickutcher / httpdownloader

HTTP(S) download manager that uses input/output completion ports (IOCP).
https://erickutcher.github.io/#HTTP_Downloader
558 stars 62 forks source link

Random crash when adding url #169

Closed char101 closed 2 years ago

char101 commented 3 years ago

Hi,

Sometimes the application crashes when adding url after clearing the completed items (thus the list is empty). Today I managed to get a crash dump.

CONTEXT:  (.ecxr)
eax=00000001 ebx=00000000 ecx=dfdff508 edx=00000000 esi=76b65f90 edi=0056006c
eip=001e9828 esp=0150f8f0 ebp=0150f958 iopl=0         nv up ei pl nz na pe nc
cs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00010206
HTTP_Downloader!UpdateMenus+0x8d8:
001e9828 f687e402000004  test    byte ptr [edi+2E4h],4      ds:002b:00560350=??
Resetting default scope

FAULTING_IP: 
HTTP_Downloader!UpdateMenus+8d8 [D:\compile\code\httpdownloader\HTTP_Downloader\menus.cpp @ 406]
001e9828 f687e402000004  test    byte ptr [edi+2E4h],4

EXCEPTION_RECORD:  (.exr -1)
ExceptionAddress: 001e9828 (HTTP_Downloader!UpdateMenus+0x000008d8)
   ExceptionCode: c0000005 (Access violation)
  ExceptionFlags: 00000000
NumberParameters: 2
   Parameter[0]: 00000000
   Parameter[1]: 00560350
Attempt to read from address 00560350

DEFAULT_BUCKET_ID:  INVALID_POINTER_READ

PROCESS_NAME:  HTTP_Downloader.exe

FOLLOWUP_IP: 
HTTP_Downloader!UpdateMenus+8d8 [D:\compile\code\httpdownloader\HTTP_Downloader\menus.cpp @ 406]
001e9828 f687e402000004  test    byte ptr [edi+2E4h],4

FAULTING_SOURCE_CODE:  
   402:         _EnableMenuItem( g_hMenuSub_edit, MENU_SELECT_ALL, ( sel_count != item_count ? MF_ENABLED : MF_GRAYED ) );
   403: 
   404:         wchar_t *item_text, *item_text2;
   405:         UINT item_text_length, item_text_length2;
>  406:         if ( di != NULL && IS_STATUS( di->status, STATUS_PAUSED ) && sel_count > 0 )
   407:         {
   408:             item_text = ST_V_Resume;
   409:             item_text_length = ST_L_Resume;
   410: 
   411:             item_text2 = ST_V_Resu_me;

It looks that in this case, di is not a valid DOWNLOAD_INFO struct.

char101 commented 3 years ago

Local variables

0:009> dv
           enable = <value unavailable>
              tbb = struct TBBUTTONINFOW
              mii = struct tagMENUITEMINFOW
item_text_length2 = <value unavailable>
       item_count = 0n1
         is_group = <value unavailable>
 item_text_length = <value unavailable>
               di = 0x0056006c
        sel_count = 0n0
        item_text = <value unavailable>
              tln = <value unavailable>
       item_text2 = <value unavailable>
char101 commented 3 years ago

Dump of di

0:009> dt di
Local var @ edi Type DOWNLOAD_INFO*
   +0x000 file_path        : [260]  "--- memory read error at address 0x0056006c ---"
   +0x208 di_cs            : _RTL_CRITICAL_SECTION
   +0x220 download_node    : DoublyLinkedList
   +0x22c queue_node       : DoublyLinkedList
   +0x238 shared_info_node : DoublyLinkedList
   +0x248 add_time         : _ULARGE_INTEGER
   +0x250 start_time       : _ULARGE_INTEGER
   +0x258 last_modified    : _ULARGE_INTEGER
   +0x260 auth_info        : AUTH_CREDENTIALS
   +0x268 file_size        : ??
   +0x270 last_downloaded  : ??
   +0x278 downloaded       : ??
   +0x280 speed            : ??
   +0x288 time_remaining   : ??
   +0x290 time_elapsed     : ??
   +0x298 download_speed_limit : ??
   +0x2a0 shared_info      : ???? 
   +0x2a4 proxy_info       : ???? 
   +0x2a8 url              : ???? 
   +0x2ac host_list        : ???? 
   +0x2b0 range_list       : ???? 
   +0x2b4 print_range_list : ???? 
   +0x2b8 range_list_end   : ???? 
   +0x2bc range_queue      : ???? 
   +0x2c0 parts_list       : ???? 
   +0x2c4 w_add_time       : ???? 
   +0x2c8 cookies          : ???? 
   +0x2cc headers          : ???? 
   +0x2d0 data             : ???? 
   +0x2d4 icon             : ???? 
   +0x2d8 hFile            : ???? 
   +0x2dc filename_offset  : ??
   +0x2e0 file_extension_offset : ??
   +0x2e4 status           : ??
   +0x2e8 parts            : ??
   +0x2ea active_parts     : ??
   +0x2ec parts_limit      : ??
   +0x2ed retries          : ??
   +0x2ee method           : ??
   +0x2ef ssl_version      : ??
   +0x2f0 processed_header : ??
   +0x2f1 download_operations : ??
   +0x2f2 moving_state     : ??
   +0x2f3 hosts            : ??
   +0x2f4 active_hosts     : ??
Memory read error 00560360
erickutcher commented 3 years ago

Nice. I was able to consistently get this to crash. The focused treelistview node isn't being cleared when using "Remove Completed" if it happens to be a completed download.

erickutcher commented 3 years ago

A new version is up that fixes this.