View Issue Details

IDProjectCategoryView StatusLast Update
0031441LazarusIDEpublic2019-11-04 18:41
ReporterAndrei DatcuAssigned ToJuha Manninen 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionno change required 
PlatformWin32OSWindowsOS Version7 64 bit
Product Version1.6.2Product Build 
Target VersionFixed in Version 
Summary0031441: Running program that uses TRegIniFile from Lazarus IDE results in program crashing with SIGSEGV
DescriptionIf I have a program/LCL Application that uses TRegIniFile and I run it from the IDE, I always get a fatal exception when running the object's destructor.
Steps To ReproduceOpen the attached project in Lazarus 1.6.2. Run the project.
Additional InformationLet's take the following snippet

  rf := TRegIniFile.Create('Software\BogusName');
  try
    c := rf.ReadInteger('ReadOptions', 'CheckSignature', 0); // Always returns 0
  finally
    rf.Free; // Always crashes if here if the Reg Key exists. If it doesn't, then there's no crash
  end;

 
TagsNo tags attached.
Fixed in Revision
LazTarget-
WidgetsetWin32/Win64
Attached Files

Activities

Andrei Datcu

2017-02-24 19:03

reporter  

162 bug test.zip (1,736 bytes)

Andrei Datcu

2017-02-24 19:09

reporter   ~0098428

This is a regression, because I cannot reproduce the issue with an older 1.3 trunk build compiled with FPC 2.6.5

Bart Broersma

2017-02-24 19:44

developer   ~0098430

It only crashes in the debugger.
Looks like a gdb issue.
What gdb versions do you have with Laz 1.6 and with Laz 1.3?

Ondrej Pokorny

2017-02-24 20:39

developer   ~0098432

Try to set DisableLoadSymbolsForLibraries to true in IDE Options -> Debugger.

Bart Broersma

2017-02-24 20:58

developer   ~0098433

> Try to set DisableLoadSymbolsForLibraries to true in IDE Options -> Debugger.
Did not help (laz trunk with gdb 7.2)

Bart Broersma

2017-02-24 21:05

developer   ~0098434

If you compile with 2.6.4 it does not crash in gdb (7.2)

jamie philbrook

2017-02-26 15:56

reporter   ~0098473

Last edited: 2017-02-26 15:58

View 2 revisions

I wanted to add, I just had an issue with the use of TStringList.
The TIniFile.Create uses this to load the list in memory if it exist, and I bet it is failing the same way my attempt of use is.
 
 Tstrings.LoadFromFile uses a TfileStream(name, FmOpenRead or FmShareDenyWrite);

 In my case the file I am loading is in the same work folder as the project
and GetLastError reports it as a code 32,"Share violation" and any code after
that expecting valid data will fault or Ship out of block because there is
no exception block to generate a clear error.

  To fix my problem I had to create a TfileStream(Name, fmOpenRead, FmShareDenyDone);
 And the StringList.LoadeFromStream(This_Stream); Which works..

 With the TiniFile.Create, The LoadFromFile is only performed if the FileExist.

Bart Broersma

2017-02-26 17:07

developer   ~0098475

@jamie: I see no relation to this bugreport.

jamie philbrook

2017-02-26 21:04

reporter   ~0098480

I am trying to point you in a direction that looks exactly the same issue..
The ini file may already have a handle attached to it that could of been left
in the WRITE&READ mode and then comes along Tinifile again, wanting to load the
file, because now it exist using FileExit function. Tstrings.LoadFromFile sets
it for fmOpen or FmShareDenyWrite; which it may already be in WRITE mode.

 This is the problem with my use of the TstrlingList, I had to work around it.
 Inifile, has the same loading procedures with no work around in case it fails
due to file permissions.

Juha Manninen

2017-02-28 12:25

developer   ~0098502

Please upload a patch that fixes the problem for you.

jamie philbrook

2017-03-05 19:58

reporter   ~0098668

Last edited: 2017-03-05 19:59

View 2 revisions

There is no error in the TRegInifile component..
Its misuse of the code..

 TregInifile.Create(FileName); needs the whole section string value in there.

 using
 rf := TRegIniFile.Create('full section name required');
 C := Rf.ReadInteger(Rf.Filename, 'CheckSignature', 0);
 ---------------------^^^^^^^^^^^---That's the key!

 I am sure by now it's been figured out.

 as for my issue.,. That too is basically a user issue of having the file
aleady opened elsewhere, file permission issies, which looked a lot like what
this issue was at first.
 
 I can work around my issue, which I have.

 I think you can close this issue as pilot error on the TRegIniFile issues.

 P.S.
   You can specify full Section name in the ReadInteger call and have it work too.

Juha Manninen

2017-03-05 20:18

developer   ~0098670

I don't know what "pilot error on the TRegIniFile issues" means but I resolve this now as "no change required".

Issue History

Date Modified Username Field Change
2017-02-24 19:03 Andrei Datcu New Issue
2017-02-24 19:03 Andrei Datcu File Added: 162 bug test.zip
2017-02-24 19:09 Andrei Datcu Note Added: 0098428
2017-02-24 19:44 Bart Broersma Note Added: 0098430
2017-02-24 20:39 Ondrej Pokorny Note Added: 0098432
2017-02-24 20:58 Bart Broersma Note Added: 0098433
2017-02-24 21:05 Bart Broersma Note Added: 0098434
2017-02-26 15:56 jamie philbrook Note Added: 0098473
2017-02-26 15:58 jamie philbrook Note Edited: 0098473 View Revisions
2017-02-26 17:07 Bart Broersma Note Added: 0098475
2017-02-26 21:04 jamie philbrook Note Added: 0098480
2017-02-28 12:25 Juha Manninen Note Added: 0098502
2017-03-05 19:58 jamie philbrook Note Added: 0098668
2017-03-05 19:59 jamie philbrook Note Edited: 0098668 View Revisions
2017-03-05 20:18 Juha Manninen LazTarget => -
2017-03-05 20:18 Juha Manninen Note Added: 0098670
2017-03-05 20:18 Juha Manninen Status new => resolved
2017-03-05 20:18 Juha Manninen Resolution open => no change required
2017-03-05 20:18 Juha Manninen Assigned To => Juha Manninen