Problem running delphi app on AMD64 chips

Posted on 2005-04-15
Last Modified: 2010-04-05
Hi, we have an app written in Delphi 5 that will not run (wont even start up) on some AMD64 chip machines running XP.
We have never had a problem with any other machine (Intel / AMD, or Operating system).
Some AMD machines that have displayed this problem have been fixed by applying a bios update, but other machines still have problems even after the bios update has been run.
I searched on Google and there are some issues with Windows XP Service Pack 2 and some new security feature re stack allocation etc, but found nothing pointing to any particular calls etc...I suspect this may be the cause, but I am not sure what calls need to be checked / changed to suit XP Sp2.

I am probably asking this question prematurely, as we are currently sourcing an AMD64 machine to try and work out why, but I was wondering if anybody else had experienced this?

Question by:insomniac92
    LVL 13

    Expert Comment

    does this happen only to Delphi applications?
    LVL 2

    Author Comment

    It is only one particular Delphi app that we have this problem with. It is written in-house, and has been sold commercially for a couple of years with no problem. It is only the AMD64 chips (and only some of them) that seem to cause an issue.
    LVL 20

    Expert Comment

    My AMD64 is configured so that every application crashes which isn't properly written (boot.ini "/NoExecute=OptOut"). I've already noticed that BCB5 isn't properly written and needs to be listed in the OptOut settings. Delphi5 runs just fine, though. And also small D5 compiled exes run just fine on my PC.
    LVL 2

    Author Comment

    Thanks, we now have an AMD64 machine. I've tried turning that switch to AlwaysOff, but the app still locks.
    It is always after it has done a http call to one of our servers to retreive data, I am guessing it is about to write this data to the hdd, then the whole machine just error, no keyboard, no mouse.. dead!
    I could understand if this happened on all machines, but its only a few AMD 64's that have this same issue.
    I guess (reluctantly) the next step is to install the dev environment on the test machine and debug it from there.

    LVL 2

    Author Comment

    Ok, we have narrowed it down to this line of code.

    Move(DataRec.Data[Position], iTemp, SizeOf(Integer));

    If we change this to say sizeOf(Double) then it all works fine - we dont want to do this if possible as we would need to modify all of our existing data to store as double values rather than integers.
    Running it on an Intel CPU works fine with SizeOf(Integer).
    Something has changed in the way AMD64 chips handle integer data types.
    We have checked the sizeof(integer) and it returns 4 bytes - on both the intel and AMD - as expected.
    If we leave it as SizeOf(Integer) the AMD machine locks completely.

    The declarations are below.

    iTemp : integer;
    Position : integer;

    TPackedByteArray = packed array of byte;

    TDataRecord = packed record
        NextRecord : integer;
        PreviousRecord : integer;
        dDateTime: TDateTime;
        Data : TPackedByteArray;

    Any ideas?
    LVL 20

    Accepted Solution

    Are you sure that DataRec.Data[Position] holds 4 bytes? There's definately no change in AMD64 chips about how they handle integer. If there would be such a change, no single program would run ok on AMD64, anymore. Also changeing sizeOf(Integer) to sizeOf(Double) is very bad, cause the Move would then write more bytes than iTemp can hold, which would overwrite parts of the stack.
    LVL 2

    Author Comment

    okay problem fixed.
    turns out to be a different line, but still moving memory with itemp and sizeof(integer).
    we were initially populating itemp with trunc(some double value) to get just the whole integer value.
    It turns out that trunc returns an int64, which is 8 bytes on a 64 bit machine, then we were trying to move this into a 4 byte integer.
    We got rid of the trunc by using ceil instead.
    Thanks for your help.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
    Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now