Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2013-06

SIGSEGV on lclrescache.pas

5 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Dave Coventry

I have a unit in which I'm parsing a large text file.

I have around 50 (or more!) IF statements as below:

if Pos(' Center Point',OdReadstrings.Strings[i])>0 then val+=',PT='+getParam(PChar(OdReadstrings.Strings[i])) else if Pos(' Custom Scale',OdReadstrings.Strings[i])>0 then val+=',SC='+getParam(PChar(OdReadstrings.Strings[i])) else if Pos(' Check',OdReadstrings.Strings[i])=1 then val+=',FZ='+getParam(PChar(OdReadstrings.Strings[i])) else if Pos(' Min Extents',OdReadstrings.Strings[i])>0 then val+=',MN='+getParam(PChar(OdReadstrings.Strings[i])) else if Pos(' Max Extents',OdReadstrings.Strings[i])>0 then etc, etc.

No error is generated from this code, per se, but on closing the programme there is an External SIGSEVV genterated in lclrescache.pas at line 186.

The offending line:

Cache.RemoveItem(Self);

Can anyone see what's going on here? Alternatively, is there a better way of parsing a large text file for phrases?

Many thanks,

Dave Coventry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130617/497229a8/attachment.html>

Reply by email

Mattias Gaertner
to Dave Coventry
Show quoted text 20 lines
I have a unit in which I'm parsing a large text file. I have around 50 (or more!) IF statements as below: if Pos(' Center Point',OdReadstrings.Strings[i])>0 then val+=',PT='+getParam(PChar(OdReadstrings.Strings[i])) else if Pos(' Custom Scale',OdReadstrings.Strings[i])>0 then val+=',SC='+getParam(PChar(OdReadstrings.Strings[i])) else if Pos(' Check',OdReadstrings.Strings[i])=1 then val+=',FZ='+getParam(PChar(OdReadstrings.Strings[i])) else if Pos(' Min Extents',OdReadstrings.Strings[i])>0 then val+=',MN='+getParam(PChar(OdReadstrings.Strings[i])) else if Pos(' Max Extents',OdReadstrings.Strings[i])>0 then etc, etc. No error is generated from this code, per se, but on closing the programme there is an External SIGSEVV genterated in lclrescache.pas at line 186. The offending line: Cache.RemoveItem(Self);

I see no relationship to your code. Probably it is a side effect of a destroyed heap.
Why do you think that the the above Ifs causes lclrescache to crash?

Can anyone see what's going on here? Alternatively, is there a better way of parsing a large text file for phrases?
Fetch the string only once:
s:=OdReadstrings.Strings[i]
if Pos('  Center Point',s)>0 then
...

Even faster:
Parse the line for tokens and use hash maps.

Mattias

Reply by email

Dave Coventry
to Dave Coventry: I have a unit in which I'm parsing a large text file. I have around 50 (or more!) IF…

Appologies!

Sent to the wrong list, dammit :blush:

Dave Coventry wrote 28 lines
I have a unit in which I'm parsing a large text file. I have around 50 (or more!) IF statements as below: if Pos(' Center Point',OdReadstrings.Strings[i])>0 then val+=',PT='+getParam(PChar(OdReadstrings.Strings[i])) else if Pos(' Custom Scale',OdReadstrings.Strings[i])>0 then val+=',SC='+getParam(PChar(OdReadstrings.Strings[i])) else if Pos(' Check',OdReadstrings.Strings[i])=1 then val+=',FZ='+getParam(PChar(OdReadstrings.Strings[i])) else if Pos(' Min Extents',OdReadstrings.Strings[i])>0 then val+=',MN='+getParam(PChar(OdReadstrings.Strings[i])) else if Pos(' Max Extents',OdReadstrings.Strings[i])>0 then etc, etc. No error is generated from this code, per se, but on closing the programme there is an External SIGSEVV genterated in lclrescache.pas at line 186. The offending line: Cache.RemoveItem(Self); Can anyone see what's going on here? Alternatively, is there a better way of parsing a large text file for phrases? Many thanks, Dave Coventry

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130617/3eb27147/attachment.html>

Reply by email

Dave Coventry
to Dave Coventry

Ooops. No, it was the right list.

The Postgres User's list is also called "General", so I thought I'd confused the two.

More embarrassment....

Dave Coventry wrote 38 lines
Appologies! Sent to the wrong list, dammit :blush: On 17 June 2013 12:17, Dave Coventry wrote: > I have a unit in which I'm parsing a large text file. > > I have around 50 (or more!) IF statements as below: > > if Pos(' Center Point',OdReadstrings.Strings[i])>0 then > val+=',PT='+getParam(PChar(OdReadstrings.Strings[i])) > else if Pos(' Custom Scale',OdReadstrings.Strings[i])>0 then > val+=',SC='+getParam(PChar(OdReadstrings.Strings[i])) > else if Pos(' Check',OdReadstrings.Strings[i])=1 then > val+=',FZ='+getParam(PChar(OdReadstrings.Strings[i])) > else if Pos(' Min Extents',OdReadstrings.Strings[i])>0 then > val+=',MN='+getParam(PChar(OdReadstrings.Strings[i])) > else if Pos(' Max Extents',OdReadstrings.Strings[i])>0 then etc, etc. > > No error is generated from this code, per se, but on closing the > programme there is an External SIGSEVV genterated in lclrescache.pas at > line 186. > > The offending line: > > Cache.RemoveItem(Self); > > Can anyone see what's going on here? Alternatively, is there a better way > of parsing a large text file for phrases? > > Many thanks, > > Dave Coventry >

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130617/c586ba5a/attachment.html>

Reply by email

Dave Coventry
to Mattias Gaertner: On Mon, 17 Jun 2013 12:17:58 +0200 I see no relationship to your code. Probably it is a…

Thanks for the reply, Mattias.

Mattias Gaertner wrote 6 lines
I see no relationship to your code. Probably it is a side effect of a destroyed heap. Why do you think that the the above Ifs causes lclrescache to crash?

I can't either, but if I remove the code from the unit, the crash no longer occurs.

Fetch the string only once:

Show quoted text 7 lines
s:=OdReadstrings.Strings[i] if Pos(' Center Point',s)>0 then ... Even faster: Parse the line for tokens and use hash maps.

I'll look into that. Thanks.

Show quoted text 7 lines
-- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130617/77bc6bc1/attachment-0001.html>

Reply by email