Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7066769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:07:14+00:00 2026-05-28T05:07:14+00:00

I am having problems using SOAP in XE/XE2 from a thread. (I didn’t test

  • 0

I am having problems using SOAP in XE/XE2 from a thread. (I didn’t test it with older Delphis.) A simple code that works in the main thread crashes while destroying the THTTPReqResp instance with Invalid pointer operation.

This is the complete program. The form contains only one button which triggers btnTestClick event:

unit Unit79;

interface

uses
  SysUtils, Forms, Classes, Controls, StdCtrls, ComObj,
  ActiveX, InvokeRegistry, SOAPHTTPTrans, Rio, SOAPHTTPClient;

type
  TForm79 = class(TForm)
    btnTest: TButton;
    procedure btnTestClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form79: TForm79;

implementation

{$R *.dfm}

procedure TForm79.btnTestClick(Sender: TObject);
begin
  TThread.CreateAnonymousThread(
    procedure
    var
      FHTTPReqResp: THTTPReqResp;
      FHTTPRIO: THTTPRIO;
    begin
      if CoInitializeEx(NIL, COINIT_MULTITHREADED or COINIT_SPEED_OVER_MEMORY) = S_OK then try
        FHTTPReqResp := THTTPReqResp.Create(nil);
        with FHTTPReqResp do begin
          Name := 'HTTPReqResp1';
          UseUTF8InHeader := True;
          InvokeOptions := [soIgnoreInvalidCerts, soAutoCheckAccessPointViaUDDI];
          WebNodeOptions := [];
        end;
        FHTTPRIO := THTTPRIO.Create(nil);
        with FHTTPRIO do begin
          Name := 'HTTPRIO1';
          HTTPWebNode := FHTTPReqResp;
        end;
        //
        FreeAndNil(FHTTPRIO);
        FreeAndNil(FHTTPReqResp); //<-- crashes here
      finally CoUninitialize; end;
    end
  ).Start;
end;

end.

The exception is raised in TObject.FreeInstance on the _FreeMem call.

procedure TObject.FreeInstance;
begin
  CleanupInstance;
  _FreeMem(Self);
end;

The call stack leading to this problem is

:75bab9bc KERNELBASE.RaiseException + 0x58 System.TObject.FreeInstance
System.ErrorAt(2,$4052E1) System.Error(reInvalidPtr)
System.TObject.FreeInstance System._ClassDestroy(???)
Soap.SOAPHTTPTrans.THTTPReqResp.Destroy System.TObject.Free
frmMain.TMainForm.btnTestClick$4934$ActRec.$0$Body
System.Classes.TAnonymousThread.Execute
System.Classes.ThreadProc($F83530) System.ThreadWrapper($F51050)
:76a4339a kernel32.BaseThreadInitThunk + 0x12 :77b59ef2
ntdll.RtlInitializeExceptionChain + 0x63 :77b59ec5
ntdll.RtlInitializeExceptionChain + 0x36

I have absolutely no idea what’s going on, why _ClassDestroy is called at all and why the code crashes 🙁 Can somebody please a) explain what I’m doing wrong and b) fix my code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:07:14+00:00Added an answer on May 28, 2026 at 5:07 am

    “Invalid pointer operation” means you’re freeing something that doesn’t represent valid memory. That can sometimes indicate stack or heap corruption, but it more likely indicates that you’re freeing something that has already been freed.

    It’s no surprise that _ClassDestroy is called. FHTTPReqResp is non-null, so when FreeAndNil calls Free on it, Free calls Destroy.

    It would appear that your THTTPRIO object acquires ownership of the THTTPReqResp you give it. If that’s the case, then the solution is simple: don’t free it yourself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having problems using textures that are larger than the OpenGL window or the
I'm having problems redirecting stdio of another program using subprocess module. Just reading from
this week I'm having problems logging in LinkedIn using ruby mechanize. My code is
I am having some problems building a properly formatted SOAP message using XMLDocument in
Currently I’m having some difficulties with using new Magento's soap v2 from c# interface.
I am having problems using choosing an image from my camera roll and assigning
i having problems using this code in order to include a photo in my
I'm having some problems using Sinatra with Capybara. I want to test a pure
I'm having problems using PHP SimpleXMLElement and simpleSMLToArray() function to parse a SOAP Response.
This should be simple, but I am having problems. Using the eBay .Net library,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.