Recent

Author Topic: Crashes with subsequent tstringlist.loadfromfile  (Read 6045 times)

tharmo

  • New Member
  • *
  • Posts: 10
Crashes with subsequent tstringlist.loadfromfile
« on: October 18, 2011, 07:09:18 pm »
I'm trying to port my app from delphi (2007) to:
Lazarus 0.9.30-0 r FPC 2.4.2 x86_64-linux-gtk 2
I am new to lazarus and to linux.

Now I'm stuck on tstringlist.loadfromfile.
If I do it once it is ok, but twice crashes my program (and if I try to run it within lazarus, the whole computer freezez ... gotta do sudo killall -gtd in a ..  emergency box? (ctrl-alt f2))

This fails:
    sl1:=tstringlist.create;
    sl2:=tstringlist.create;
    sl2.loadfromfile('/home/t/test1');
    sl1.loadfromfile('/home/t/test2');
The files are identical, tiny files. It does not matter in which order I try to load then. Any clues? (I had some problems trying to uppgrade lazarus, so I grabbed what I got to work, perhaps  0.9.30-0 is not the one to have?)
 -Timo

99Percent

  • Full Member
  • ***
  • Posts: 160
Re: Crashes with subsequent tstringlist.loadfromfile
« Reply #1 on: October 18, 2011, 08:14:05 pm »
I have no problems with TStringLists using my version of Lazarus (0.9.31 r32759) but I am mystified also why you would have such an obvious problem. Perhaps its an OS issue (permissions, etc)?

tharmo

  • New Member
  • *
  • Posts: 10
Re: Crashes with subsequent tstringlist.loadfromfile
« Reply #2 on: October 18, 2011, 08:38:53 pm »
I am also very mystified but confident that the solution will be quite simple. Permissions etc. are ruled out, I think, because it works well with either one of the files separately. I'd prefer not to start by trying to up/downgrade fpc and lazarus, it was rather painful last time and I'm not quite sure how I finally managed to do it.

Troodon

  • Sr. Member
  • ****
  • Posts: 484
Re: Crashes with subsequent tstringlist.loadfromfile
« Reply #3 on: October 18, 2011, 08:48:11 pm »
Try the attached project. I don't have a Linux machine handy, I tested it on Win32.
Lazarus/FPC on Linux

tharmo

  • New Member
  • *
  • Posts: 10
Re: Crashes with subsequent tstringlist.loadfromfile
« Reply #4 on: October 19, 2011, 08:07:50 am »
Troodon, I cannot get yout simple example to crash not matter how maliciosly I try to twist it or my compiler options.

But it did crash my hopes for a simple solution. I noticed that the crash occurs only when running in a specific thread within indy http-server. It will take me some time before I can say anything worthwhile about this one.


99Percent

  • Full Member
  • ***
  • Posts: 160
Re: Crashes with subsequent tstringlist.loadfromfile
« Reply #5 on: October 19, 2011, 08:06:23 pm »
I would stay clear away from indy objects if possible. Try using Ararat Synapse instead.

Maybe your OS has file open restrictions per process/thread?

tharmo

  • New Member
  • *
  • Posts: 10
Re: Crashes with subsequent tstringlist.loadfromfile
« Reply #6 on: October 20, 2011, 08:16:52 am »
 I've been very happy with indy in windows, and have tons of code using it.  But I'll take a look at Synapse, thanks.
Meanwhile I've learned that my problem is not about indy, and not about the thread itself, it is something I do in that thread (before a certain point  loadfromfiles work, after it they don't. No files touched there. Working on it...)
-timo

tharmo

  • New Member
  • *
  • Posts: 10
Re: Crashes with subsequent tstringlist.loadfromfile
« Reply #7 on: October 21, 2011, 06:21:34 am »
Thank you for the efforts to help me. And sorry for misleading. Turned out that the problem is not  with the stringlists or anything I wrote about,  but with some twisting I was doing with ttextrec/stdout somewhere else. Somehow it manifested in crashes only when I tried to do the second loadfromfile and my poorly designed debugging methods (to circumvent crashes of  the debugger, perhaps caused by the same twisting) wrongly indicated that point in the code as the culprit.
 -Timo

 

TinyPortal © 2005-2018