开发者

Invalid pointer exception when closing app after upgrade from Delphi 2006 to Delphi XE

I've just upgraded a project from Delphi 2006 to Delphi XE. Everything is working as expected except I get an exceptio开发者_StackOverflown when I close my app.

It's not breaking on a code line. It breaks to the CPU window on a LEAVE command. I've attached a Eureka log if that is any help.

EurekaLog 6.0.25

Application:
------------------------------------------------------
  1.1 Start Date      : Fri, 3 Dec 2010 10:44:17 +0100
  1.2 Name/Description: LogoTid.exe
  1.3 Version Number  : 
  1.4 Parameters      : 
  1.5 Compilation Date: Fri, 3 Dec 2010 10:44:15 +0100
  1.6 Up Time         : 5 seconds

Exception:
----------------------------------------------------
  2.1 Date          : Fri, 3 Dec 2010 10:44:22 +0100
  2.2 Address       : 004062A0
  2.3 Module Name   : LogoTid.exe
  2.4 Module Version: 
  2.5 Type          : EInvalidPointer
  2.6 Message       : Invalid pointer operation.
  2.7 ID            : 5E21
  2.8 Count         : 1
  2.9 Status        : New
  2.10 Note         : 

User:
-------------------------------------------------------
  3.1 ID        : oda
  3.2 Name      : 
  3.3 Email     : 
  3.4 Company   : 
  3.5 Privileges: SeIncreaseQuotaPrivilege        - OFF
                  SeSecurityPrivilege             - OFF
                  SeTakeOwnershipPrivilege        - OFF
                  SeLoadDriverPrivilege           - OFF
                  SeSystemProfilePrivilege        - OFF
                  SeSystemtimePrivilege           - OFF
                  SeProfileSingleProcessPrivilege - OFF
                  SeIncreaseBasePriorityPrivilege - OFF
                  SeCreatePagefilePrivilege       - OFF
                  SeBackupPrivilege               - OFF
                  SeRestorePrivilege              - OFF
                  SeShutdownPrivilege             - OFF
                  SeDebugPrivilege                - ON
                  SeSystemEnvironmentPrivilege    - OFF
                  SeChangeNotifyPrivilege         - ON
                  SeRemoteShutdownPrivilege       - OFF
                  SeUndockPrivilege               - OFF
                  SeManageVolumePrivilege         - OFF
                  SeImpersonatePrivilege          - ON
                  SeCreateGlobalPrivilege         - ON
                  SeIncreaseWorkingSetPrivilege   - OFF
                  SeTimeZonePrivilege             - OFF
                  SeCreateSymbolicLinkPrivilege   - OFF

Active Controls:
------------------------------------------------------------------
  4.1 Form Class   : TAppBuilder
  4.2 Form Text    : LogoTid - Delphi XE - uMain [Running] [Built]
  4.3 Control Class: 
  4.4 Control Text : 

Computer:
------------------------------------------------------------------------------------------------
  5.1 Name          : OLE-LAPTOP
  5.2 Total Memory  : 3891 Mb
  5.3 Free Memory   : 778 Mb
  5.4 Total Disk    : 120 Gb
  5.5 Free Disk     : 57,93 Gb
  5.6 System Up Time: 1 day, 23 hours, 16 minutes, 56 seconds
  5.7 Processor     : Intel(R) Core(TM) i5 CPU       M 520  @ 2.40GHz
  5.8 Display Mode  : 1920 x 1200, 32 bit
  5.9 Display DPI   : 96
  5.10 Video Card   : Intel(R) Graphics Media Accelerator HD (driver 8.15.10.2025 - RAM 1721 MB)
  5.11 Printer      : RICOH Aficio 2232C RPCS (driver 1.0.0)

Operating System:
--------------------------------------------
  6.1 Type    : Microsoft Windows 7 (64 bit)
  6.2 Build # : 7600
  6.3 Update  : 
  6.4 Language: Danish
  6.5 Charset : 0


Call Stack Information:
-------------------------------------------------------------------
|Address |Module      |Unit       |Class|Procedure/Method   |Line |
-------------------------------------------------------------------
|Running Thread: ID=5632; Priority=0; Class=; [Main]              |
|-----------------------------------------------------------------|
|00D171A1|LogoTid.exe |LogoTid.dpr|     |                   |32[5]|
|76A73675|kernel32.dll|           |     |BaseThreadInitThunk|     |
-------------------------------------------------------------------



Assembler Information:
-----------------------------------------------------------------
; System.TObject.FreeInstance 
; ----------------------------
00406294  push    ebx
00406295  mov     ebx, eax
00406297  mov     eax, ebx
00406299  call    System.TObject.CleanupInstance
0040629E  mov     eax, ebx
004062A0  call    System._FreeMem                 ; <-- EXCEPTION
004062A5  pop     ebx
004062A6  ret

Registers:
-----------------------------
EAX: 02AF8058   EDI: 00000001
EBX: 004062A5   ESI: 004062A5
ECX: 0041D700   ESP: 0018FE98
EDX: 004062A5   EIP: 004062A0

Stack:               Memory Dump:
------------------   ---------------------------------------------------------------------------
0018FE98: FFFFFF02   004062A0: E8 3B E7 FF FF 5B C3 90 83 C0 CC 8B 00 C3 8B C0  .;...[..........
0018FE9C: 00404B78   004062B0: 84 D2 74 08 83 C4 F0 E8 54 05 00 00 84 D2 74 0F  ..t.....T.....t.
0018FEA0: 02B1CEC0   004062C0: E8 A3 05 00 00 64 8F 05 00 00 00 00 83 C4 0C C3  .....d..........
0018FEA4: 02B1CEC0   004062D0: E8 E3 05 00 00 84 D2 7E 05 E8 82 05 00 00 C3 90  .......~........
0018FEA8: 00404BC2   004062E0: 85 C0 74 07 B2 01 8B 08 FF 51 FC C3 53 56 57 89  ..t......Q..SVW.
0018FEAC: 02B1CEC0   004062F0: C3 89 D7 AB 8B 4B CC 31 C0 51 C1 E9 02 49 F3 AB  .....K.1.Q...I..
0018FEB0: 0018FEE8   00406300: 59 83 E1 03 F3 AA 89 D0 89 E2 8B 4B AC 85 C9 74  Y..........K...t
0018FEB4: 004062A5   00406310: 01 51 8B 5B D0 85 DB 74 04 8B 1B EB ED 39 D4 74  .Q.[...t.....9.t
0018FEB8: 03A02F01   00406320: 1D 5B 8B 0B 83 C3 04 8B 73 10 85 F6 74 06 8B 7B  .[......s...t..{
0018FEBC: 00406865   00406330: 14 89 34 07 83 C3 1C 49 75 ED 39 D4 75 E3 5F 5E  ..4....Iu.9.u._^
0018FEC0: 0045B949   00406340: 5B C3 8B C0 53 56 89 C3 89 C6 8B 36 8B 56 B4 8B  [...SV.....6.V..
0018FEC4: 03A02FA0   00406350: 76 D0 85 D2 74 07 E8 85 36 00 00 89 D8 85 F6 75  v...t...6......u
0018FEC8: 03A02F01   00406360: E9 89 D8 E8 78 06 00 00 5E 5B C3 90 87 D1 81 F9  ....x...^[......
0018FECC: 004062EB   00406370: 00 00 00 FF 73 11 81 F9 00 00 00 FE 72 07 0F BF  ....s.......r...
0018FED0: 00912606   00406380: C9 03 08 FF 21 FF E1 81 E1 FF FF FF 00 01 C1 89  ....!...........
0018FED4: 00000000   00406390: D0 8B 11 E9 A8 59 00 00 C3 8D 40 00 3B C2 0F 94  .....Y....@.;...

--- Edit

Ok, tried turning of parts of my program until the error went away, and found the troublemaker.

It's my webservice WSDL generated proxy. If I create the proxy object without calling any functions on the service, it throws the error.

I've created a test project without any other code than the proxy object creation and it also throws the error. I've also tried with another webservice, same error. Both webservices was created with Delphi 2006 (.net 1.1).

Lastly I tried with a .net 4.0 webservice created in VS2010. No problems. So either Delphi XE is projects is not compatible with .net 1.1 webservices or Delphi 2006 webservices. Either way it's a mess.

Any thouhts on how to solve this, maybe a workaround?


The log won't help here. It looks like a memory corruption issue, which can happen if your code performs indexed operations on strings (writing to string's character position, for example) and you have not fixed all code where string is casted to PChar or similar code.

In other words, you have to perform careful analysis of your code. Start with turning off some modules and code blocks completely until the exception disappears. Then start adding them one by one.


Likely related to the fact that the string is now a Unicode string (2 bytes per char), and not an AnsiString (1 byte per char). If you play with the raw bytes of strings, this is a major problem. To solve it, simply replace all string to AnsiString and all char to AnsiChar. Of course, you will lose Unicode support by doing this. A better fix is to rework your string handling routines. Often, what is necessary is only to add some multiplicative factors sizeof(char) (=2) every here and there.

Example (old code):

byteSize = length(str);

Example (new code):

byteSize = length(str) * sizeof(char);


Found a solution / workaround.

The error occurs if you use a Webservice directly in a form.

Create an empty vcl forms project, use the wsdl generator to generate a webservice proxy. Include proxy class in uses section. Declare a private object of the proxy, and then in the form create use the proxy class getXXXXXXX function to initiate your object. Run the project.

When you close the form, you get an exception.

The solution / workaround is to create your own class, and talk to the webservice proxy through this class.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜