Jump to content

David Heffernan

Members
  • Content Count

    3536
  • Joined

  • Last visited

  • Days Won

    175

Posts posted by David Heffernan


  1. So often this is caused by a defect in your code. You supply an argument that is invalid. Perhaps an object that has already been destroyed. So full fastmm4 debug is useful. 

     

    You would debug this by trying to create a minimal example that reproduces the issue. That's the starting point. 


  2. 45 minutes ago, Nathan Wild said:

    This is not a multithrreaded application.  Or at least my application is not.  Is suppose it is possible the ODBC interface is for some reason?

    No reason at all to suspect that multithreading is the issue here. You aren't likely to get good leads from people making random guesses. Hard debugging is the way forward. 


  3. 1 hour ago, A.M. Hoornweg said:

    Hello all,

     

    I'd like to know if it is possible to activate the FastMM4 Option "AlwaysClearFreedMemory" temporarily/on demand in code? 

    The reason being that some of my routines work with confidential passwords/hashes.  Delphi often uses temporary "hidden" strings and interfaces (for example when concatenating strings) so there's the risk of legible stuff remaining in RAM when such a routine exits.  

    That's surely not the right solution to the problem. The right solution is to implement the critical code following standard security practices.  And to then get it audited by a security expert.

    • Like 1

  4. 31 minutes ago, A.M. Hoornweg said:

    The default calling convention in Delphi is "register" (the compiler tries to pass parameters in registers if possible to speed things up). 

     

    The "Stdcall" convention is used throughout by the 32-bit Windows API (which consists of DLL's).  So, for consistency's sake, it makes sense to adopt that calling convention for your own 32-bit DLL's as well. "Stdcall" tells the compiler that the caller of the function will pass all parameters on the stack in a right-to-left sequence and that the function itself is responsible for cleaning up the stack before returning.

     

    As Remy Lebeau pointed out, in 64-bit Windows there's only one calling convention. So you could do something like this:

     

    //in the DLL:

    Procedure MyProc; {$ifdef win32} Stdcall;{$endif} Export;

    begin

    ..

    end;

    ... exports 'MyProc';

     

     

    //In the exe:

    Procedure MyProc; {$ifdef win32} Stdcall;{$endif} external 'mydll.dll';

     

     

     

     

     

     

     

    As discussed above the conditional code simply adds clutter for no benefit. The compiler has already handled the issue for you. Remove the conditional, and let the compiler ignore stdcall in x64.

     

    A second point is the use of the export directive. It is also always ignored (a hangover from 16 bit days). Again it should be removed.  Therefore the best practise would be to write:

     

    procedure MyProc; stdcall;

    And that's it.  Obviously you still need the exports list somewhere.

    • Like 2
×