Recent

Author Topic: Linux application memory corruption  (Read 1920 times)

Grahame Grieve

  • Sr. Member
  • ****
  • Posts: 365
Linux application memory corruption
« on: October 07, 2021, 03:23:35 am »
I have a linux application (a console application) that runs fine on ubuntu, under the debugger or not. But when a friends runs it in docker - also ubuntu - it totally fails with one of a series of weird memory corruption issues. it fails somewhere in the code below, but that seems solid to me, and I can't see why it would lead to memory corruption for him and not me. Does anyone have any idea what I should be looking for?

procedure initialiseTZData(filename : String);
var
  stream : TFileStream;
  z : TZDecompressionStream;
  tar : TTarArchive;
  entry : TTarDirRec;
  bi : TBytesStream;
begin
  GTimeZoneData := TPascalTZ.create;
  stream := TFileStream.Create(filename, fmOpenRead);
  try
    z := TZDecompressionStream.Create(stream, 15+16);
    try
      tar := TTarArchive.Create(z);
      try
        while tar.FindNext(entry) do
        begin
          if (StringArrayExists(TZ_FILES_STANDARD, entry.name)) then
          begin
            bi := TBytesStream.Create;
            try
              tar.ReadFile(bi);
              bi.position := 0;
              GTimeZoneData.ParseDatabaseFromStream(bi);
            finally
              bi.free;
            end;
          end;
        end;
      finally
        tar.free;
      end;
    finally
      z.free;
    end;
  finally
    stream.Free;
  end;
  GLocalTZ := TTimeZone.create('');
end;       

Grahame Grieve

  • Sr. Member
  • ****
  • Posts: 365
Re: Linux application memory corruption
« Reply #1 on: October 07, 2021, 05:25:35 am »
Progress of a sort; the docker builds the binary, and the binary it builds is corrupt - something to do with the compile process. I will provide an update when I have some progress

ttomas

  • Full Member
  • ***
  • Posts: 245
Re: Linux application memory corruption
« Reply #2 on: October 07, 2021, 04:59:48 pm »
Check your docker image os version, libc exists and version, all other libs your app use.
You can try
https://github.com/Docker-Hub-frolvlad/docker-alpine-fpc
« Last Edit: October 07, 2021, 05:06:21 pm by ttomas »

Grahame Grieve

  • Sr. Member
  • ****
  • Posts: 365
Re: Linux application memory corruption
« Reply #3 on: October 08, 2021, 03:04:23 am »
Thanks. Somehow it was the compile. We've got our CI build scripts here: https://github.com/grahamegrieve/fhirserver/tree/master/build, and they build good binaries

 

TinyPortal © 2005-2018