Jump to content

David Heffernan

Members
  • Content Count

    3514
  • Joined

  • Last visited

  • Days Won

    174

Posts posted by David Heffernan


  1. 10 minutes ago, TurboMagic said:

    I would also expect that they are reported to me and in other big applications I have they actually are, but not in this one and reducing this might not be so easy.

     

    @Attila: what in my finalization sections could trigger a silend exit process? Do y<ou have any examples so I know what to look for?

    Calls to ExitProcess or TerminateProcess.

     

    My experience however is that guesswork is not much of a basic for solving problems. My experience is that debugging is way more effective. My advice is that you debug your problem. Cutting down to a minimal reproduction is one way to start doing that. 


  2. 9 hours ago, TurboMagic said:

    Ahem, the following code I had used to test will leak:

     

    var

      sl : TStringList;

    begin

      sl := TStringList.Create;

      sl.Add('This will leak David!');

      sl.Add('This will leak David!');

    end;

     

    See: no free, thus it will leak at least one TStringList.

     

    I had even put that construct into the dpr and put an exit after the last Add call, so the application quit immediately. But it didn't show any message box.

    Ok, doing that in the dpr and thus not running any VCL initialisation made in the dpr's main code migt be problematic for showing a message box,
    but the code above was in the FormClose event of the main form and got called!

    Those are reported as leaks for me. As I said, we need a minimal reproduction. 


  3. Works fine in any context. If you notice though, I supplied a complete program. You only supplied snippets, the latest of which does not compile. Perhaps if you want help finding the bug in your code you could supply a complete but minimal reproduction, just as I did. Then it would be simple for us to find the mistake. 


  4. Works fine here.  I wrote a version with the threading removed to make it simpler to understand.

     

    {$APPTYPE CONSOLE}
    
    uses
      System.SysUtils;
    
    function CaptureValue(Value: Integer): TProc;
    begin
      Result :=
        procedure
        begin
          Writeln(Value);
        end;
    end;
    
    procedure Main;
    var
      i, j: Integer;
      Procs: TArray<TProc>;
    begin
      SetLength(Procs, 10);
    
      for i := 0 to 9 do
        Procs[i] :=
          procedure
          begin
            Writeln(i);
          end;
      for j := 0 to 9 do
        Procs[j]();
    
    
      for i := 0 to 9 do
        Procs[i] := CaptureValue(i);
      for j := 0 to 9 do
        Procs[j]();
    end;
    
    begin
      Main;
      Readln;
    end.

    Output is

    10
    10
    10
    10
    10
    10
    10
    10
    10
    10
    0
    1
    2
    3
    4
    5
    6
    7
    8
    9

     


  5. 58 minutes ago, OmahaMax said:

    Yes, it is a simple TStringList. However, when the output is posted in the final inserter stage, the inserted output matches the stringlist results. One thread works, two threads fail to process the first input, three threads fail to process the first two inputs, and so forth. Results are the same with or without logging.

    Would be easier for people to help if you could post a minimal repro. 


  6. 1 hour ago, Steve Maughan said:

    Hi Stefan,

     

    Each item's value changes slightly on each iteration. Note also, finding the min item may take more than one comparison per change (if the min item's value changes such that it's not now the min item).

     

    Thanks,

     

    Steve

    On each iteration, each value is modified. So, during the iteration, just keep track of the smallest value that you have seen to date. 


  7. 1 hour ago, Lars Fosdal said:

    Depends on the dictionary, I guess.

    Race conditions rarely flag as errors, but cause inconsistent or erratic data, possibly leading to wrongful processing later on.

    In this case, at least one of the four parties would be denied access (due to exclusive write lock and - depending on the programmmer - exclusive read) to the file and hence should have/raise awareness of a problem. 

    But, whatever.

    Well, there are plenty of types for which races lead to errors. But how races manifest is not part of what defines them. A race is simply unserialised access to a shared resource. There aren't multiple definitions of this term. 

×