1

In a service running under system account the code below hangs in the TMemIniFile.Create without errors. If we replace it with TIniFile, it works fine.
It's a Delphi Tokyo 10.2.3 Win32 app running under Windows Server 2012R2. There's no concurrent access to the INI file.
This is the first time (first client) we see this, it has been running fine on many machines.

I have no idea what to look for further. Any ideas?
It 'works' now because we switched to TIniFile, but I'd like to find the cause. From other posts I read here, TINIfile seems to be more finicky than TMemINIfile, my situation is the reverse.
There are no special characters in the INI file and it is created with an ASCII editor.

// This is set in the ServiceCreate:
FIniFileNaam := ChangeFileExt(ParamStr(0),'.INI'); 

// This is called from the ServiceStart:

procedure TTimetellServiceBase.LeesINI;
var lIniFile : TMemIniFile;
begin
   LogMessage(FIniFileNaam, EVENTLOG_INFORMATION_TYPE, cCatInfo, cReadINI);  // Logs to event log, we see this
   FStartDir := ExtractFilePath(ParamStr(0));

   if assigned(FLaunchThreadLijst) then FreeAndNil(FLaunchThreadLijst);
   FLaunchThreadLijst := TStringList.Create;
   try
      if FileExists(FIniFileNaam) then
      begin
         // Lees waarden uit INI file
         lIniFile := TMemIniFile.Create(FIniFileNaam);  // This is the call that hangs. The service is unresponsive now.
         try
            FLaunchThreadLijst.CommaText := lIniFile.ReadString(INISECTIE_SERVICETASKS,'RunIniFiles','');
            FMaxTaskDuration := lIniFile.ReadInteger(INISECTIE_SERVICETASKS,'MaxTaskDuration',FMaxTaskDuration);
         finally
            FreeAndNil(lIniFile);
         end;
      end;

   finally
      if (FLaunchThreadLijst.Count = 0) and FileExists(FStartDir + FExeName) then
         FLaunchThreadLijst.Add(SDEFAULTTHREADNAME);
      LogMessage(Format('FLaunchThreadLijst.CommaText: %s (%d items)',[FLaunchThreadLijst.CommaText,FLaunchThreadLijst.Count]), EVENTLOG_INFORMATION_TYPE, cCatInfo, cLaunchList);
   end;
end;

FWIW, INI file contents:

[TASKMANAGER]
RunIniFiles=TTTasks.ini
MaxTaskDuration=2
RestartIniFiles=
KillIniFiles=
Jan Doggen
  • 8,799
  • 13
  • 70
  • 144
  • What is your question? It seems like you want to use UTF8 enconding here. – Ilyes Apr 17 '18 at 13:08
  • @Sami No, I don't use any encoding. And I was wondering if this sounded familiar or if there are suspicious parts in my code. – Jan Doggen Apr 17 '18 at 13:10
  • 1
    Aaah, so you better post this question on **[CodeReview](https://codereview.stackexchange.com/)** – Ilyes Apr 17 '18 at 13:15
  • @Jan, what happens if you create an MVCE with the offending code? – whosrdaddy Apr 17 '18 at 13:20
  • 2
    @Sami: Code Review is about reviewing code that works as expected. A question containing the phrase *"the code below hangs"* will most probably be closed as off-topic. – Martin R Apr 17 '18 at 13:20
  • @MartinR That's what I see here, unless I'm wrong. – Ilyes Apr 17 '18 at 13:23
  • @whosrdaddy I would've done if it happened more often, but this is on a customers' server where one of our consultants is installing software remotely, so we cannot experiment on it too much. We mixed the above code with additional LogMessage() calls so that we could see in the event log where it went wrong. But I feel uncomfortable doing more on that production server. I wish it was on one of our machines, and I understand why this very open question is getting downvotes. Yet I fear an underlying issue that we may have overlooked. – Jan Doggen Apr 17 '18 at 13:24
  • If you had madExcept in the process then you could use madTraceProcess to get all the thread call stacks when the process is hung. Yes you might be able to work this out by guessing but by far the best approach is to debug using evidence. – David Heffernan Apr 17 '18 at 13:48
  • Jan, seeing that you have a workaround and you want to find out what is the problem, one possible step is to recreate the customer's environment on a local VM, try to reproduce the problem and then (remote) debug your application. – whosrdaddy Apr 17 '18 at 13:56

0 Answers0