Watch, Follow, &
Connect with Us

Welcome, Guest
Guest Settings
Help

Thread: Invalid address specified to RtlSizeHeap


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 5 - Last Post: Sep 13, 2017 10:56 AM Last Post By: sverker johansson Threads: [ Previous | Next ]
sverker johansson

Posts: 12
Registered: 9/28/08
Invalid address specified to RtlSizeHeap  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 11, 2017 12:33 AM
My code
{
.
WideString wstOptionInfo;
.
oleServerObj.OleFunction(L"Init_E", &status, wstPathToMeasCaseName.c_bstr(),
wstOptionInfo.c_bstr(), wstKxxxxFields.c_bstr(), wstExportFilePrefix.c_bstr());
.
}

if wstOptionInfo.c_bstr() is shorter then previous call to oleServerObj.OleFunction I get the message

Debug Output: HEAP[M7005.exe]: Process M7005.exe (1500)
Debug Output:
Invalid address specified to RtlSizeHeap( 00F80000, 010334A0 )

when the program reach the end bracket }

CX10 , Windows 10

/Sverker Johansson
sverker johansson

Posts: 12
Registered: 9/28/08
Re: Invalid address specified to RtlSizeHeap  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 11, 2017 7:58 AM   in response to: sverker johansson in response to: sverker johansson
sverker johansson wrote:
My code
{
.
WideString wstOptionInfo;
.
oleServerObj.OleFunction(L"Init_E", &status, wstPathToMeasCaseName.c_bstr(),
wstOptionInfo.c_bstr(), wstKxxxxFields.c_bstr(), wstExportFilePrefix.c_bstr());
.
}

if wstOptionInfo.c_bstr() is shorter then previous call to oleServerObj.OleFunction I get the message

Debug Output: HEAP[M7005.exe]: Process M7005.exe (1500)
Debug Output:
Invalid address specified to RtlSizeHeap( 00F80000, 010334A0 )

when the program reach the end bracket }

CX10 , Windows 10

/Sverker Johansson

Sorry it should be
if wstOptionInfo.c_bstr() is LONGER then previous call to oleServerOb

The error only occurs in IDE not if I run the .exe file directly .
/Sverker
sverker johansson

Posts: 12
Registered: 9/28/08
Re: Invalid address specified to RtlSizeHeap  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 12, 2017 2:10 AM   in response to: sverker johansson in response to: sverker johansson
sverker johansson wrote:
My code
{
.
WideString wstOptionInfo;
.
oleServerObj.OleFunction(L"Init_E", &status, wstPathToMeasCaseName.c_bstr(),
wstOptionInfo.c_bstr(), wstKxxxxFields.c_bstr(), wstExportFilePrefix.c_bstr());
.
}

if wstOptionInfo.c_bstr() is shorter then previous call to oleServerObj.OleFunction I get the message

Debug Output: HEAP[M7005.exe]: Process M7005.exe (1500)
Debug Output:
Invalid address specified to RtlSizeHeap( 00F80000, 010334A0 )

when the program reach the end bracket }

CX10 , Windows 10

/Sverker Johansson
After further tests, I have found that the error occurs if any of WideStrinfs is longer than 243 bytes
/Sverker
sverker johansson

Posts: 12
Registered: 9/28/08
Re: Invalid address specified to RtlSizeHeap  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 13, 2017 4:49 AM   in response to: sverker johansson in response to: sverker johansson
To clean up the problem, I have created a client and a server.
The error occurs if iNoChar> 16381 and Client runs in C ++ Builder.
If, on the other hand, the client .exe file is running, everything works OK. (Up to iNoChar> 150000).

//==== Client ==================================================================
#include <vcl.h>
#include <windows\rtl\system.win.comobj.hpp> // xe2jz
#pragma hdrstop
#include "frmClient.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TfrmClientForm *frmClientForm;
//---------------------------------------------------------------------------
__fastcall TfrmClientForm::TfrmClientForm(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TfrmClientForm::btnInitComClick(TObject *Sender)
{
AnsiString asT = "RtlSizeHeapServer.DataSend";
UnicodeString ucT = asT;
oleServerObj = oleServerObj = CreateOleObject(ucT.w_str());
}
//---------------------------------------------------------------------------
void __fastcall TfrmClientForm::btnSendAbcClick(TObject *Sender)
{
WideString wsT;
int iNoChar = 16381;
for(int i = 0 ; i < iNoChar; i++)
wsT += "a";
lblMsgLength->Caption = wsT.Length();
BSTR bstr = wsT.c_bstr();
oleServerObj.OleFunction(L"Send", wsT.c_bstr());
}
// ==== Server ====================================================================
#include <vcl.h>
#pragma hdrstop
#include "frmServer.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TfrmServerForm *frmServerForm;
//---------------------------------------------------------------------------
__fastcall TfrmServerForm::TfrmServerForm(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
//
// DATASENDIMPL : Implementation of TDataSendImpl (CoClass: DataSend, Interface: IDataSend)
//
#include <vcl.h>
#pragma hdrstop
#include "frmServer.h"
#include "DataSendImpl.h"
//
// TDataSendImpl
//
__fastcall TDataSendImpl::TDataSendImpl()
{
}
//
// TDataSendImpl
//
__fastcall TDataSendImpl::TDataSendImpl(const System::_di_IInterface Controller)
: inherited(Controller)
{
}
//
// TDataSendImpl
//
__fastcall TDataSendImpl::TDataSendImpl(Comobj::TComObjectFactory* Factory,
const System::_di_IInterface Controller)
: inherited(Factory, Controller)
{
}
//
// TDataSendImpl - Class Factory
//
static void createFactory()
{
new TCppAutoObjectFactory<TDataSendImpl>(Comserv::GetComServer(),
__classid(TDataSendImpl),
CLSID_DataSend,
Comobj::ciMultiInstance,
Comobj::tmApartment);
}
#pragma startup createFactory 32
STDMETHODIMP TDataSendImpl::Send(BSTR bstrIn)
{
AnsiString asT = bstrIn;
frmServerForm->lblInMsg->Caption = asT;
frmServerForm->lblMsgLength->Caption = asT.Length();
}

/Sverker
Remy Lebeau (Te...


Posts: 8,641
Registered: 12/23/01
Re: Invalid address specified to RtlSizeHeap  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 13, 2017 8:28 AM   in response to: sverker johansson in response to: sverker johansson
sverker johansson wrote:

oleServerObj = oleServerObj = CreateOleObject(ucT.w_str());

Is this a typo? Or are you really assigning oleServerObj to itself?

For that matter, why are you using late binding via Variant to begin
with, instead of using early binding via IDataSend directly?

for(int i = 0 ; i < iNoChar; i++)
wsT += "a";

That is horribly inefficient for a WideString, which uses the COM
memory manager instead of the RTL's memory manager. Use StringOfChar()
instead:

WideString wsT = StringOfChar(L'a', iNoChar);


Or, at least pre-allocate the WideString before filling it in a loop:

WideString wsT;
wsT.SetLength(iNoChar);
for(int i = 1 ; i <= iNoChar; i++)
    wsT[i] = L'a';


--
Remy Lebeau (TeamB)
sverker johansson

Posts: 12
Registered: 9/28/08
Re: Invalid address specified to RtlSizeHeap  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 13, 2017 10:56 AM   in response to: sverker johansson in response to: sverker johansson
Sorry, of course, it should be only one oleServerObj and that's the case in my code that I use

I change my code to
WideString wsT = StringOfChar(L'a', iNoChar);
But the result i the same. If iNoChar >16381 i get the message

Debug Output: HEAP[M7005.exe]: Process M7005.exe (760)
Debug Output:
Invalid address specified to RtlSizeHeap( 00940000, 00990010 )
Proess Client.exe(9684)
Non_user breakpoint at $770c0758, Process Client.exe (9684)

/Sverker Johansson
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02