开发者

Random Access Violations in my code

开发者 https://www.devze.com 2023-02-21 01:37 出处:网络
I have been modifying, debugging, modifying, debugging (you know the drill) and I just can\'t figure out what is causing these Access Violations!

I have been modifying, debugging, modifying, debugging (you know the drill) and I just can't figure out what is causing these Access Violations!

The most typical one is with "Read of adress 80000000" in the Skype4COM.dll, however I don't suspect it is the code in there that is causing it.

My first suspicion was that I was sending too many commands to the Skype API (through Skype4COM), but after adding some pausing logic, to make sure that Skype and the COM-object could keep up, I realized that was not it - it's still occuring!

I am using Threads to perform this, and even without using Threads, it still provokes an AV. (I only use one thread at a time)

Here is my Thread Execute method:

procedure TMyThread.Execute;
Var
  I             : Integer;
  User          : PUser;
  ReceiverName  : String;
  FullMessage   : String;
  PauseEvent    : TEvent;
  TimesToPause  : Integer;
  iPause        : Integer;
  J             : Integer;
  FExit         : Boolean;
begin
  inherited;
  if Terminated then
  Exit;

  FreeOnTerminate := True;

  CoInitialize(Nil);

  FExit         := True;
  UserList      := TList.Create;
  SkypeThr      := TSkype.Create(Nil);
  PauseEvent    := TEvent.Create(True);
  Try
  try
      SkypeThr.Attach(10,False);

      Synchronize(SyncBegin);

      iMax := UserList.Count;
      Synchronize(SyncSetMax);
      LogID := 'N/A';


      TimesToPause := Round(UserList.Count / 300);

      // For Loop
      for I := 0 to UserList.Count - 1 do
        begin

          FullMessage := sMessage;

          if (Trim(sFooter) <> '') and (bFooter) then
          FullMessage := FullMessage+sLineBreak+sFooter;

          User := PUser(UserList.Items[I]);

          ReceiverName    := User.DisplayName;
          if Trim(ReceiverName) = '' then
          ReceiverName    := User.SkypeID;

          FullMessage := ParseMessage(FullMessage,ReceiverName);
          LogId           := User.SkypeID;
          try
          SkypeThr.CreateChatWith(User.SkypeID).SendMessage(FullMessage);

          PauseEvent.WaitFor(10);
          if TimesToPause >= 1 then
          Begin
          for iPause := 1 to TimesToPause do
          begin

          J := iPause*300;
             if J = I then
             begin

              Synchronize(SyncPauseBegin);

              PauseEvent.WaitFor(3000);

              Synchronize(SyncPauseEnd);

             end;

          end;

          end;
          Except on E:Exception do
            begin
             ExErr := E.Message;
             ExLog := 'Sending message to user "'+User.SkypeID+'" failed: ';
             ExMsg := 'Error: Sending message to user "'+User.SkypeID+'" failed: ';
             Synchronize(Procedure
             Begin
              Log(ExMsg+ExErr+sLineBreak+' - Last logged Handle: '+LogID);
              if not AnsiContainsText(ExErr,'contact is disabled') then
              Begin
              ErrMsg(ExMsg+ExErr);
              FExit     := True;
              End else FExit := False;

             End
             );


             if FExit then
             Exit;

          end;
          End;



          iProgress := I+1;
          Synchronize(SyncProgress);

        end;

      // End my for loop
  // Except
  Except on E:Exception do
  begin
   ExErr := E.Message;
   ExLog := 'Error while broadcasting: ';
   ExMsg := 'An error has occured while broadcasting: ';
   Synchronize(
   Procedure
   Begin
    Log(ExMsg+ExErr);
    ErrMsg(ExMsg+ExErr);
   End
   );
   Exit;
  end;
  end;
  // Fínally
  Finally
  PauseEvent.Free;
  FreeList;
  SkypeThr.Free;
  Synchronize(SyncFinalize);
  CoUninitialize;
  End;


end;

The access violation occurs in the middle of the whole process - I know because if it was in the end, the progressbar that shows the progress would be full, and it's not, it's usually around 10-80%.

The ErrMsg(); is basically just a MessageDlg routine, so I would not have to do all the mbOk and stuff.

The Log(); adds the error to my Log memo.

If you need more information, do not hesitate to ask!

EDIT: I forgot to mention that debugging is kinda hard, because the AV is occuring on my clients PC, not mine. I will try to log every suspicious action however, by placing Log(); before/after each suspicious line.

EDIT2: I just tested it on another buddy's PC, and his works flawlessly. I have a few testers, and it's like 50% of them that reports the AV's..

Here's one of the madExcept logs:

date/time         : 2011-03-29, 02:01:51, 590ms
computer name     : MTPOCKETS-PC
user name         : mtpockets
registered owner  : mtpockets
operating system  : Windows 7 Starter build 7600
system language   : English
system up time    : 1 day 3 hours
program up time   : 3 hours 12 minutes
processors        : 2x Intel(R) Atom(TM) CPU N270 @ 1.60GHz
physical memory   : 105/1014 MB (free/total)
free disk space   : (C:) 100.42 GB
display mode      : 1024x600, 32 bit
process id        : $1ac8
allocated memory  : 111.87 MB
executable        : xSky.exe
exec. date/time   : 2011-03-27 20:15
version           : 0.9.2.448
compiled with     : Delphi 2010
madExcept version : 3.0l
contact name      : david gilyeat
contact email     : admin@matriscruiser.com
Reproducable      : no
callstack crc     : $280a264a, $5b090a2b, $5b090a2b
exception number  : 2
exception class   : EAccessViolation
exception message : Access violation at address 280A264A in module 'Skype4COM.dll'. Read of address 00B5E000.

main thread ($f8c):
280a264a +000 Skype4COM.dll
76cc8e97 +00a USER32.dll                 DispatchMessageW
75643e73 +0a4 oleaut32.dll               DispCallFunc
76cc8e97 +00a USER32.dll                 DispatchMessageW
00550079 +11d xSky.exe      Forms        TApplication.ProcessMessage
005500be +00a xSky.exe      Forms        TApplication.HandleMessage
005503e9 +0c9 xSky.exe      Forms        TApplication.Run
007b3771 +085 xSky.exe      xSky  49 +10 initialization
75e61192 +010 kernel32.dll               BaseThreadInitThunk

thread $a54:
76ea5caa +0a ntdll.dll     NtWaitForMultipleObjects
75e61192 +10 kernel32.dll  BaseThreadInitThunk

thread $1824:
76ea5cca +000a ntdll.dll                          NtWaitForSingleObject
75031796 +0066 KERNELBASE.dll                     WaitForSingleObjectEx
75e5effe +003e kernel32.dll                       WaitForSingleObjectEx
75e5efad +000d kernel32.dll                       WaitForSingleObject
0057a8f2 +16c6 xSky.exe       VirtualTrees        .TBaseVirtualTree
004a1526 +0042 xSky.exe       Classes             ThreadProc
00406cf0 +0028 xSky.exe       System       152 +0 ThreadWrapper
75e61192 +0010 kernel32.dll                       BaseThreadInitThunk

thread $12f4:
76cc8fbd +26 USER32.dll    GetMessageW
75e61192 +10 kernel32.dll  BaseThreadInitThunk

thread $10c8: <suspended>
76ea588a +00a ntdll.dll                    NtSetEvent
76e8fb6e +020 ntdll.dll                    RtlpUnWaitCriticalSection
76e8fb3f +000 ntdll.dll                    RtlLeaveCriticalSection
004a1d06 +11e xSky.exe     Classes         TThread.Synchronize
004a1dd5 +029 xSky.exe     Classes         TThread.Synchronize
005f2e42 +03a xSky.exe     pngimage        TChunkIDAT.CopyNonInterlacedRGBAlpha16
004a1526 +042 xSky.exe     Classes         ThreadProc
00406cf0 +028 xSky.exe     System   152 +0 ThreadWrapper
75e61192 +010 kernel32.dll                 BaseThreadInitThunk

thread $12bc:
76ea5caa +00a ntdll.dll                      NtWaitForMultipleObjects
7503686c +000 KERNELBASE.dll                 WaitForMultipleObjectsEx
75e5f145 +089 kernel32.dll                   WaitForMultipleObjectsEx
004a4cd6 +056 xSky.exe       SyncObjs        THandleObject.WaitFor
0052f368 +468 xSky.exe       Controls        TCustomHintShowHideThread.Execute
004a1526 +042 xSky.exe       Classes         ThreadProc
00406cf0 +028 xSky.exe       System   152 +0 ThreadWrapper
75e61192 +010 kernel32.dll                   BaseThreadInitThunk

thread $1da0:
76cc8fbd +26 USER32.dll             GetMessageW
00466549 +0d xSky.exe     madExcept CallThreadProcSafe
004665b3 +37 xSky.exe     madExcept ThreadExceptFrame
75e61192 +10 kernel32.dll           BaseThreadInitThunk
>> >> created by thread $e24 at:
75da480b +00 SHLWAPI.dll

thread $604: <suspended>
76ea5cca +00a ntdll.dll                      NtWaitForSingleObject
75031796 +066 KERNELBASE.dll                 WaitForSingleObjectEx
75e5effe +03e kernel32.dll                   WaitForSingleObjectEx
75e5efad +00d kernel32.dll                   WaitForSingleObject
004a1d22 +13a xSky.exe       Classes         TThread.Synchronize
004a1dd5 +029 xSky.exe       Classes         TThread.Synchronize
005f2e42 +03a xSky.exe       pngimage        TChunkIDAT.CopyNonInterlacedRGBAlpha16
004a1526 +042 xSky.exe       Classes         ThreadProc
00406cf0 +028 xSky.exe       System   152 +0 ThreadWrapper
75e61192 +010 kernel32.dll                   BaseThreadInitThunk

thread $1ee4:
76ea5cda +0a ntdll.dll     NtWaitForWorkViaWorkerFactory
75e61192 +10 kernel32.dll  BaseThreadInitThunk

thread $ff4: <priority:-1>
76cc8e97 +0a USER32.dll                  DispatchMessageW
004a1526 +42 xSky.exe     Classes        ThreadProc
00406cf0 +28 xSky.exe     System  152 +0 ThreadWrapper
75e61192 +10 kernel32.dll                BaseThreadInitThunk

thread $8ec:
76cc8fbd +26 USER32.dll    GetMessageW
75e61192 +10 kernel32.dll  BaseThreadInitThunk

modules:
00400000 xSky.exe              0.9.2.448          C:\Program Files\xSky Software LLC\xSky
28000000 Skype4COM.dll         1.0.36.0           C:\Program Files\xSky Software LLC\xSky
66980000 mso.dll               12.0.6545.5004     C:\Program Files\Common Files\Microsoft Shared\office12
67a00000 olmapi32.dll          12.0.6550.5001     C:\Program Files\Microsoft Office\Office12
69660000 SearchFolder.dll      6.1.7600.16385     C:\Windows\system32
69c40000 NetworkExplorer.dll   6.1.7600.16385     C:\Windows\system32
6a190000 StructuredQuery.dll   7.0.7600.16587     C:\Windows\System32
6a3c0000 davclnt.dll           6.1.7600.16723     C:\Windows\System32
6a7f0000 ntlanman.dll          6.1.7600.16385     C:\Windows\System32
6abb0000 EhStorAPI.dll         6.1.7600.16385     C:\Windows\system32
6bbc0000 mlang.dll             6.1.7600.16385     C:\Windows\system32
6bf20000 ieproxy.dll           8.0.7600.16722     C:\Program Files\Internet Explorer
6d890000 ieframe.DLL           8.0.7600.16723     C:\Windows\system32
6eba0000 msls31.dll            3.10.349.0         C:\Windows\system32
6ef40000 SHDOCVW.dll           6.1.7600.16385     C:\Windows\system32
6ef70000 actxprxy.dll          6.1.7600.16385     C:\Windows\system32
6f050000 LINKINFO.dll          6.1.7600.16385     C:\Windows\system32
6f220000 MSMAPI32.DLL          12.0.6413.1000     C:\Program Files\Common Files\SYSTEM\MSMAPI\1033
6f320000 pnrpnsp.dll           6.1.7600.16385     C:\Windows\system32
6f340000 napinsp.dll           6.1.7600.16385     C:\Windows\system32
6f350000 winrnr.dll            6.1.7600.16385     C:\Windows\System32
6f3b0000 sfc_os.DLL            6.1.7600.16385     C:\Windows\system32
6f3c0000 SFC.DLL               6.1.7600.16385     C:\Windows\system32
6f4b0000 PortableDeviceApi.dll 6.1.7600.16385     C:\Windows\system32
6f840000 DAVHLPR.dll           6.1.7600.16385     C:\Windows\System32
6f8f0000 ntshrui.dll           6.1.7600.16385     C:\Windows\system32
6f9c0000 CSCDLL.dll            6.1.7600.16385     C:\Windows\System32
6f9f0000 cscui.dll             6.1.7600.16385     C:\Windows\System32
6fa60000 EhStorShell.dll       6.1.7600.16385     C:\Windows\system32
6ffa0000 msi.dll               5.0.7600.16385     C:\Windows\system32
70300000 winspool.drv          6.1.7600.16385     C:\Windows\system32
70760000 MPR.dll               6.1.7600.16385     C:\Windows\system32
70dc0000 rasadhlp.dll          6.1.7600.16385     C:\Windows\system32
70dd0000 cscapi.dll            6.1.7600.16385     C:\Windows\system32
70ee0000 drprov.dll            6.1.7600.16385     C:\Windows\System32
70ef0000 mapi32.dll            1.0.2536.0         C:\Windows\system32
70fa0000 winmm.DLL             6.1.7600.16385     C:\Windows\system32
71080000 olepro32.dll          6.1.7600.16385     C:\Windows\system32
71140000 msimg32.dll           6.1.7600.16385     C:\Windows\system32
711b0000 MSVCR80.dll           8.0.50727.4927     C:\Windows\WinSxS\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.4927_none_d08a205e442db5b5
71990000 wsock32.dll           6.1.7600.16385     C:\Windows\system32
719a0000 oleacc.dll            7.0.0.0            C:\Windows\system32
73120000 dhcpcsvc6.DLL         6.1.7600.16385     C:\Windows\system32
73130000 dhcpcsvc.DLL          6.1.7600.16385     C:\Windows\system32
731a0000 Fwpuclnt.dll          6.1.7600.16385     C:\Windows\system32
73340000 WINNSI.DLL            6.1.7600.16385     C:\Windows\system32
73350000 IPHLPAPI.DLL          6.1.7600.16385     C:\Windows\system32
734a0000 slc.dll               6.1.7600.16385     C:\Windows\system32
73570000 mssprxy.dll           7.0.7600.16385     C:\Windows\system32
73690000 NLAapi.dll            6.1.7600.16385     C:\Windows\system32
736c0000 ntmarta.dll           6.1.7600.16385     C:\Windows\system32
73720000 samcli.dll            6.1.7600.16385     C:\Windows\system32
73730000 wkscli.dll            6.1.7600.16385     C:\Windows\system32
73740000 netutils.dll          6.1.7600.16385     C:\Windows\system32
738d0000 WindowsCodecs.dll     6.1.7600.16385     C:\Windows\system32
73a30000 xmllite.dll           1.3.1000.0         C:\Windows\system32
73a60000 dwmapi.dll            6.1.7600.16385     C:\Windows\system32
73b40000 DUser.dll             6.1.7600.16385     C:\Windows\system32
73b70000 DUI70.dll             6.1.7600.16385     C:\Windows\system32
73c30000 gdiplus.dll           6.1.7600.16385     C:\Windows\WinSxS\x86_microsoft.windows.gdiplus_6595b64144ccf1df_1.1.7600.16385_none_72fc7cbf861225ca
73dc0000 uxtheme.dll           6.1.7600.16385     C:\Windows\system32
73e00000 propsys.dll           7.0.7600.16385     C:\Windows\system32
74010000 SAMLIB.dll            6.1.7600.16385     C:\Windows\system32
74050000 comctl32.dll          6.10.7600.16661    C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7600.16661_none_420fe3fa2b8113bd
744b0000 version.dll           6.1.7600.16385     C:\Windows\system32
74540000 wshtcpip.dll          6.1.7600.16385     C:\Windows\System32
747d0000 rsaenh.dll            6.1.7600.16385     C:\Windows\system32
748b0000 DNSAPI.dll            6.1.7600.16385     C:\Windows\system32
749e0000 wship6.dll            6.1.7600.16385     C:\Windows\System32
749f0000 mswsock.dll           6.1.7600.16385     C:\Windows\system32
74a30000 CRYPTSP.dll           6.1.7600.16385     C:\Windows\system32
74be0000 srvcli.dll            6.1.7600.16385     C:\Windows\system32
74d60000 Secur32.dll           6.1.7600.16385     C:\Windows\System32
74e90000 SspiCli.dll           6.1.7600.16385     C:\Windows\system32
74eb0000 WINSTA.dll            6.1.7600.16385     C:\Windows\System32
74ee0000 apphelp.dll           6.1.7600.16481     C:\Windows\system32
74f30000 CRYPTBASE.dll         6.1.7600.16385     C:\Windows\system32
74f40000 sxs.dll               6.1.7600.16385     C:\Windows\system32
74fd0000 RpcRtRemote.dll       6.1.7600.16385     C:\Windows\system32
74fe0000 profapi.dll           6.1.7600.16385     C:\Windows\system32
75020000 MSASN1.dll            6.1.7600.16415     C:\Windows\system32
75030000 KERNELBASE.dll        6.1.7600.16385     C:\Windows\system32
75110000 CFGMGR32.dll          6.1.7600.16385     C:\Windows\system32
75140000 DEVOBJ.dll            6.1.7600.16385     C:\Windows\system32
75160000 CRYPT32.dll           6.1.7600.16385     C:\Windows\system32
75280000 WINTRUST.dll          6.1.7600.16493     C:\Windows\system32
752b0000 urlmon.dll            8.0.7600.16723     C:\Windows\system32
753f0000 SETUPAPI.dll          6.1.7600.16385     C:\Windows\system32
75590000 USP10.dll             1.626.7600.16385   C:\Windows\system32
75630000 oleaut32.dll          6.1.7600.16567     C:\Windows\system32
756c0000 WLDAP32.dll           6.1.7600.16385     C:\Windows\system32
75710000 psapi.dll             6.1.7600.16385     C:\Windows\system32
75730000 WS2_32.dll            6.1.7600.16385     C:\Windows\system32
75770000 CLBCatQ.DLL           2001.12.8530.16385 C:\Windows\system32
75800000 msvcrt.dll            7.0.7600.16385     C:\Windows\system32
758b0000 GDI32.dll             6.1.7600.16385     C:\Windows\system32
75900000 LPK.dll               6.1.7600.16385     C:\Windows\system32
75910000 iertutil.dll          8.0.7600.16722     C:\Windows\system32
75b10000 RPCRT4.dll            6.1.7600.16385     C:\Windows\system32
75bf0000 ADVAPI32.DLL          6.1.7600.16385     C:\Windows\system32
75c90000 WININET.dll           8.0.7600.16723     C:\Windows\system32
75d90000 SHLWAPI.dll           6.1.7600.16385     C:\Windows\system32
75df0000 sechost.dll           6.1.7600.16385     C:\Windows\SYSTEM32
75e10000 kernel32.dll          6.1.7600.16481     C:\Windows\system32
75ef0000 NSI.dll               6.1.7600.16385     C:\Windows\system32
75f00000 ole32.dll             6.1.7600.16624     C:\Windows\system32
76060000 shell32.dll           6.1.7600.16644     C:\Windows\system32
76cb0000 USER32.dll            6.1.7600.16385     C:\Windows\system32
76d80000 comdlg32.dll          6.1.7600.16385     C:\Windows\system32
76e60000 ntdll.dll             6.1.7600.16695     C:\Windows\SYSTEM32
76fa0000 IMM32.DLL             6.1.7600.16385     C:\Windows\system32
76fc0000 MSCTF.dll             6.1.7600.16385     C:\Windows\system32

processes:
0000 Idle                     0 0   0
0004 System                   0 0   0
0100 smss.exe                 0 0   0
01a4 csrss.exe                0 0   0
01d8 wininit.exe              0 0   0
01e0 csrss.exe                1 0   0
0210 services.exe             0 0   0
0230 winlogon.exe             1 0   0
023c lsass.exe                0 0   0
0244 lsm.exe                  0 0   0
02b0 svchost.exe              0 0   0
02fc svchost.exe              0 0   0
0360 svchost.exe              0 0   0
039c svchost.exe              0 0   0
03bc svchost.exe              0 0   0
0408 audiodg.exe              0 0   0
0438 svchost.exe              0 0   0
0498 svchost.exe              0 0   0
0540 spoolsv.exe              0 0   0
055c svchost.exe              0 0   0
05c0 svchost.exe              0 0   0
0620 sqlservr.exe             0 0   0
06cc taskhost.exe             1 34  26  normal C:\Windows\system32
06e4 sqlbrowser.exe           0 0   0
075c sqlwriter.exe            0 0   0
07b8 Dwm.exe                  1 25  9   normal C:\Windows\system32
0074 Explorer.EXE             1 414 263 normal C:\Windows
0b68 SearchIndexer.exe        0 0   0
0c40 wmpnetwk.exe             0 0   0
0a00 svchost.exe              0 0   0
16c8 taskhost.exe             1 0   0
1f34 taskmgr.exe              1 130 104 high   C:\Windows\system32
0968 FlashUtil10l_ActiveX.exe 1 9   5   normal C:\Windows\system32\Macromed\Flash
1be8 Skype.exe                1 582 249 normal C:\Program Files\Skype\Phone
1f0c iexplore.exe             1 993 405 normal C:\Program Files\Internet Explorer
1b08 iexplore.exe             1 501 376 normal C:\Program Files\Internet Explorer
1480 skypePM.exe              1 463 694 normal C:\Program Files\Skype\Plugin Manager
0810 iexplore.exe             1 502 236 normal C:\Program Files\Internet Explorer
0e3c iexplore.exe             1 994 378 normal C:\Program Files\Internet Explorer
1bf0 iexplore.exe             1 496 203 normal C:\Program Files\Internet Explorer
1ac8 xSky.exe                 1 407 181 normal C:\Program Files\xSky Software LLC\xSky
16b4 OUTLOOK.EXE              1 502 255 normal C:\Program Files\Microsoft Office\Office12
1b88 WINWORD.EXE              1 272 80  normal C:\Program Files\Microsoft Office\Office12
0218 iexplore.exe             1 405 190 normal C:\Program Files\Internet Explorer

hardware:
+ Batteries
  - Microsoft AC Adapter
  - Microsoft ACPI-Compliant Control Method Battery
  - Microsoft Composite Battery
+ Computer
  - ACPI x86-based PC
+ Disk drives
  - ST9160412ASG ATA Device
+ Display adapters
  - Mobile Intel(R) 945 Express Chipset Family (driver 8.15.10.1930)
  - Mobile Intel(R) 945 Express Chipset Family (driver 8.15.10.1930)
+ IDE ATA/ATAPI controllers
  - ATA Channel 0
  - ATA Channel 1
  - Intel(R) ICH7-M Family Serial ATA Storage Controller - 27C4 (driver 9.1.1.1016)
+ Imaging devices
  - PC Camera
+ Keyboards
  - Standard PS/2 Keyboard
+ Mice and other pointing devices
  - PS/2 Compatible Mouse
+ Monitors
  - Generic PnP Monitor
+ Network adapters
  - 802.11n Wireless LAN Card (driver 3.0.11.0)
  - Realtek PCIe FE Family Controller (driver 7.6.820.2009)
+ Processors
  - Intel(R) Atom(TM) CPU N270   @ 1.60GHz
  - Intel(R) Atom(TM) CPU N270   @ 1.60GHz
+ Sound, video and game controllers
  - Realtek High Definition Audio (driver 6.0.1.5936)
+ Storage volume shadow copies
  - Generic volume shadow copy
  - Generic volume shadow copy
  - Generic volume shadow copy
  - Generic volume shadow copy
  - Generic volume shadow copy
  - Generic volume shadow copy
  - Generic volume shadow copy
  - Generic volume shadow copy
  - Generic volume shadow copy
  - Generic volume shadow copy
+ System devices
  - ACPI Fixed Feature Button
  - ACPI Lid
  - ACPI Power Button
  - ACPI Sleep Button
  - ACPI Thermal Zone
  - Composite Bus Enumerator
  - Direct memory access controller
  - File as Volume Driver
  - High Definition Audio Controller
  - High precision event timer
  - Intel(R) 82801 PCI Bridge - 2448
  - Intel(R) 82802 Firmware Hub Device
  - Intel(R) ICH7M/U LPC Interface Controller - 27B9 (driver 9.1.1.1016)
  - Intel(R) N10/ICH7 Family PCI Express Root Port - 27D0 (driver 9.1.1.1016)
  - Intel(R) N10/ICH7 Family PCI Express Root Port - 27D2 (driver 9.1.1.1016)
  - Intel(R) N10/ICH7 Family PCI Express Root Port - 27D4 (driver 9.1.1.1016)
  - Intel(R) N10/ICH7 Family SMBus Controller - 27DA (driver 9.1.1.1016)
  - Microsoft ACPI-Compliant Embedded Controller
  - Microsoft ACPI-Compliant System
  - Microsoft System Management BIOS Driver
  - Microsoft Virtual Drive Enumerator Driver
  - Microsoft Windows Management Interface for ACPI
  - Mobile Intel(R) 945GME Express Processor to DRAM Controller - 27AC
  - Motherboard resources
  - Motherboard resources
  - Motherboard resources
  - Numeric data processor
  - PCI bus
  - Plug and Play Software Device Enumerator
  - Programmable interrupt controller
  - System CMOS/real time clock
  - System timer
  - Terminal Server Keyboard Driver
  - Terminal Server Mouse Driver
  - UMBus Enumerator
  - UMBus Root Bus Enumerator
  - Volume Manager
+ Universal Serial Bus controllers
  - Intel(R) N10/ICH7 Family USB Universal Host Controller - 27C8 (driver 9.1.1.1016)
  - Intel(R) N10/ICH7 Family USB Universal Host Controller - 27C9 (driver 9.1.1.1016)
  - Intel(R) N10/ICH7 Family USB Universal Host Controller - 27CA (driver 9.1.1.1016)
  - Intel(R) N10/ICH7 Family USB Universal Host Controller - 27CB (driver 9.1.1.1016)
  - Intel(R) N10/ICH7 Family USB2 Enhanced Host Controller - 27CC (driver 9.1.1.1016)
  - USB Composite Device
  - USB Root Hub
  - USB Root Hub
  - USB Root Hub
  - USB Root Hub
  - USB Root Hub

cpu registers:
ea开发者_运维百科x = 0165013d
ebx = 00f200d8
ecx = 002bc850
edx = 00000000
esi = 00b5dffd
edi = 0b7edfb8
eip = 280a264a
esp = 0012dbe8
ebp = 0012dbf0

stack dump:
0012dbe8  d8 00 f2 00 00 00 00 00 - 0c dc 12 00 0f 1d 0a 28  ...............(
0012dbf8  20 00 3c 0b 65 00 73 00 - d8 00 f2 00 6c 00 79 00  ..<.e.s.....l.y.
0012dc08  b0 20 72 07 b4 20 72 07 - 71 1a 00 28 20 00 3c 0b  ..r...r.q..(..<.
0012dc18  de 00 f2 00 65 00 73 00 - d8 00 f2 00 e4 ff ff ff  ....e.s.........
0012dc28  cc 20 72 07 98 1f 72 07 - 00 00 00 00 8c de 08 28  ..r...r........(
0012dc38  cc 20 72 07 00 00 00 00 - ff ff ff ff 0f 89 13 e7  ..r.............
0012dc48  07 00 00 00 18 0b e3 04 - 78 e9 12 00 00 00 00 00  ........x.......
0012dc58  70 dc 12 01 18 0b e3 04 - 01 02 00 00 00 00 70 07  p.............p.
0012dc68  d8 33 e0 00 10 00 00 00 - f0 00 00 00 00 00 00 00  .3..............
0012dc78  07 00 00 00 09 02 00 00 - 00 00 80 07 45 00 52 00  ............E.R.
0012dc88  53 00 00 00 11 00 00 00 - 00 00 00 00 07 00 00 00  S...............
0012dc98  00 00 00 00 bc 7d 72 07 - 09 00 20 00 00 00 00 00  .....}r.........
0012dca8  18 dd 12 00 0c 45 cc 76 - 02 00 00 00 07 00 00 00  .....E.v........
0012dcb8  78 5d 0f 28 eb 02 00 00 - c4 2f 0f 28 80 16 79 07  x].(...../.(..y.
0012dcc8  80 09 80 07 00 00 00 00 - c8 dc 12 00 cc dc 12 00  ................
0012dcd8  74 0f 80 07 00 00 00 00 - d8 dc 12 00 dc dc 12 00  t...............
0012dce8  00 00 00 00 00 00 00 00 - e8 dc 12 00 ec dc 12 00  ................
0012dcf8  30 98 c8 06 74 0f 80 07 - 03 00 00 00 74 07 15 00  0...t.......t...
0012dd08  ec 37 0f 28 00 00 00 00 - 01 00 00 00 00 00 00 00  .7.(............
0012dd18  01 02 00 00 06 00 00 00 - 00 00 00 00 00 00 00 00  ................

disassembling:
[...]
007b375d      mov     eax, [eax]
007b375f      mov     edx, [$771ba4]
007b3765      call    -$26359a ($5501d0)     ; Forms.TApplication.CreateForm
007b376a 49   mov     eax, [$7c6900]
007b376f      mov     eax, [eax]
007b3771    > call    -$263456 ($550320)     ; Forms.TApplication.Run
007b3776      jmp     loc_7b377e
007b3778 52   push    eax
007b3779      call    -$3a500e ($40e770)     ; Windows.SetForegroundWindow
007b377e 55   call    -$3acbff ($406b84)     ; System.@Halt0

EDIT 3: After logging every line of code, I found that the crook is the CreateChatWith.SendMessage Line! What do you suggest?

EDIT 4: Alright, by splitting the CreateChatWith, and the SendMessage, it was the SendMessage that causes it!

Thanks!


Your exception message is probably something like "Access Violation at address XXXXXXX. Blablabla". Take a note of that address and place a breakpoint somewhere in your Execute method. When executions stops at that breakpoint, choose "Find error" from the menu (under Edit or something) and enter the address. You will now jump to the code where the error occurred.

If it is somewhere in your Execute method, please let us know what line it is. Also I would suggest you use something like MadExcept to log your exceptions including a stack-trace.

When you don't know how to debug a dll with the Delphi debugger

After reading your post I suspect you don't know how to debug a dll with Delphi (no offence). This is how you do it:

  • Exit Skype
  • In your project options, set "Include TD32 info", set "Include remote debugging symbols" (not sure about this one, but it doesn't hurt)
  • Rebuild
  • Open "Debugger Options", make sure that "Stop on Delphi exceptions" is checked
  • Open "Run Parameters"
  • Set host application to Skype.exe
  • Press F9, Skype will now start
  • When your dll is loaded by Skype, blue dots will appear in your code. You can set breakpoints too.
  • When the error occurs the debugger will stop at the line where the error occurred.


Since there is not enough information to know specifically, I am going to take a bet. I bet the AVs are coming from these accesses on the local variable User:

ReceiverName    := User.DisplayName; // <------- Maybe here?
if Trim(ReceiverName) = '' then
  ReceiverName    := User.SkypeID; // <------- Maybe here?

I am guessing that the type of User is a pointer type, indicated by the type declaration:

User          : PUser;

I am guessing that this cast:

User := PUser(UserList.Items[I]);

is casting something that is not really of the same type. No validation is performed on the cast, the compiler happily tries to layer the structure of the of the declared type over the memory being pointed to. The problems come in when you try to refer to members of that structure, and the actual layout of what is present in the memory doesn't quite match.

If you could step through this code and inspect the data at each step, it should be very easy to find the error, assuming it already happens when I is small.

There are others here that will be able to guess better than I can though. Takers?


EDIT 3: After logging every line of code, I found that the crook is the CreateChatWith.SendMessage Line! What do you suggest?

I would split this line

 SkypeThr.CreateChatWith(User.SkypeID).SendMessage(FullMessage);

into two or more:

 SkypeThr.CreateChatWith(User.SkypeID);
 SkypeThr.SendMessage(FullMessage);

to further identify the bad code.


If you have triple checked everything in your code, then compare Pascal headers implementation of SendMessage() for Skype DLL with C headers and look for bug in header translation. What you send via SendMessage() must 100% match what it expects.

0

精彩评论

暂无评论...
验证码 换一张
取 消