View Issue Details

IDProjectCategoryView StatusLast Update
0034856FPCRTLpublic2019-03-02 11:44
ReporterBenito van der ZanderAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.3.1Product Buildr40721 
Target Version3.2.0Fixed in Version3.3.1 
Summary0034856: access violation when program ends after calling TEncoding.FreeEncodings
DescriptionWhen TEncoding.FreeEncodings has been called the program does not terminate properly
Steps To Reproduceprogram Project1;

{$mode objfpc}{$H+}

uses
  classes, sysutils;

begin
  TEncoding.FreeEncodings;
  writeln('a');
end.

prints

$ /tmp/project1
a
An unhandled exception occurred at $0000000000000000:
EAccessViolation: Access violation
  $0000000000000000


Additional InformationThis works fine:

program Project1;

{$mode objfpc}{$H+}

uses
  sysutils;

begin
  TEncoding.FreeEncodings;
  writeln('a');
end.



and this

program Project1;

{$mode objfpc}{$H+}

uses
  classes, sysutils;

begin
  writeln('a');
end.



TagsNo tags attached.
Fixed in Revision41547
FPCOldBugId
FPCTarget
Attached Files

Relationships

related to 0032961 resolvedMattias Gaertner Lazarus There is a problem with the default code page and streams 

Activities

Benito van der Zander

2019-02-27 00:54

reporter   ~0114478

This is caused by the classaliaslist stringlist having a default encoding and freeing it after it has been freed, because an already freed encoding is not a standard encoding anymore.

destructor TSTrings.Destroy;
...
  if (FDefaultEncoding<>nil) and not TEncoding.IsStandardEncoding(FDefaultEncoding) then
    FreeAndNil(FDefaultEncoding);

Michael Van Canneyt

2019-03-02 11:43

administrator   ~0114554

You are correct in your observation that it's impossible to avoid AVs if FreeEncoding can be called at will. I moved the procedure to the protected section.

Issue History

Date Modified Username Field Change
2019-01-12 23:56 Benito van der Zander New Issue
2019-02-27 00:54 Benito van der Zander Note Added: 0114478
2019-03-02 11:43 Michael Van Canneyt Fixed in Revision => 41547
2019-03-02 11:43 Michael Van Canneyt Note Added: 0114554
2019-03-02 11:43 Michael Van Canneyt Status new => resolved
2019-03-02 11:43 Michael Van Canneyt Fixed in Version => 3.3.1
2019-03-02 11:43 Michael Van Canneyt Resolution open => fixed
2019-03-02 11:43 Michael Van Canneyt Assigned To => Michael Van Canneyt
2019-03-02 11:43 Michael Van Canneyt Target Version => 3.2.0
2019-03-02 11:44 Michael Van Canneyt Relationship added related to 0032961