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 7023469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:42:54+00:00 2026-05-27T23:42:54+00:00

I’m still having trouble with the same application as mentioned here Delphi CopyMemory vs

  • 0

I’m still having trouble with the same application as mentioned here
Delphi CopyMemory vs C++ memcpy

Whilst I had a satisfactory answer to my original question, I’m struggling to understand a subsequent crash…

I have a delphi app, that uses a networking library and a server app (that exists somewhere on the work) which uses the same networking library. The networking library appears to work correctly is written in C++ (not by me). The library handles all the communications for me, so I need only supply an array of bytes to the library. I can successfully send to, and receive data from my server – And the data is correct in both directions.

I receive data from the server in a helper procedure. The procedure runs correctly to the “end;” (quite literally). The procedure ends (I’m successfully through all comms at this stage and now solely concerned with Delphi), and the debugger takes me into _DynArrayClear – where my application crashes. From the help I read “The Delphi compiler automatically inserts calls to this function whenever appropriate.”

I’ll add some more background if it helps… The networking library populates a byte array which is defined as void *data in a content struct (see below)

struct content {
  void *data;
  int size;
}

I believe all I need to do, once this data is populated is perform a CopyMemory operation in Delphi…

Could someone please help me understand what I’ve done wrong?!

// should be: function THelper.ReceiveData: TBytes; - 
// but my crash happens with either a function or a procedure
procedure THelper.ReceiveData; 
var
  lMsg: Pointer;
  lSize: Integer;
  lData: TBytes;
  lRecvResult: Integer;
begin
  lMsg := nil;

  // Remote call to receive data returns an integer indicating success
  lRecvResult := lib_receive_data(lMsg, Integer(Flags));
  TUtils.CheckError(lRecvResult);

  SetLength(lData, 5);
  CopyMemory(@lData[0], lMsg, 5); // where 5 is the length of data to copy
end; // takes me into _DynArrayClear 



// The application crashes after exiting _DynArrayClear 
// For clarity @@noFinalize is entered at line 20795
// I get all the way to the 'end;' at line 20801 in System.pas
// 
// Then from _DynArrayClear I press F7 and immediately get access violation at 0xcdcdcdcd: read address of 0xcdcdcdcd and the following is the call stack...

:7789fada ntdll.NtQueryInformationProcess + 0x12
:77890143 ntdll.KiUserExceptionDispatcher + 0xf
:778c6a8b ; ntdll.dll
:77890143 ntdll.KiUserExceptionDispatcher + 0xf
:778c6a8b ; ntdll.dll
:77890143 ntdll.KiUserExceptionDispatcher + 0xf
:778c6a8b ; ntdll.dll
:77890143 ntdll.KiUserExceptionDispatcher + 0xf
:778c6a8b ; ntdll.dll
:77890143 ntdll.KiUserExceptionDispatcher + 0xf
:778c6a8b ; ntdll.dll
:77890143 ntdll.KiUserExceptionDispatcher + 0xf
:778c6a8b ; ntdll.dll
:77890143 ntdll.KiUserExceptionDispatcher + 0xf
:778c6a8b ; ntdll.dll
  • 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-27T23:42:55+00:00Added an answer on May 27, 2026 at 11:42 pm

    lRecvResult := lib_receive_data(lMsg, Integer(Flags));

    What is the first parameter of lib_receive_data() actually declared as? You are passing in a local Pointer variable that is initially set to nil, so I assume the parameter is a var that get assigned some meaningful memory address when lib_receive_data() exits? What does lib_receive_data() actually output?

    You meantion a content structure, but I don’t see you using it anywhere. And you declare an lSize variable, but you do not use it, either. What does the documentation for lib_receive_data() actually say?

    SetLength(lData, 5);
    CopyMemory(@lData[0], lMsg, 5); // where 5 is the length of data to copy

    Are you absolutely sure that lMsg always points to a bufer that contains at least 5 bytes? What does the return value of lib_receive_data() represent? It is a byte count, or just a status code?

    The fact that you are getting errors at an address like 0xcdcdcdcd suggests you are likely trampling the TBytes memory, which would lead to a crash in _DynArrayClear() when the TBytes is being deallocated.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.