Recent

Author Topic: Threading application Linux exception: 'External: SIGABRT'  (Read 6027 times)

MaartenJB

  • Full Member
  • ***
  • Posts: 116
Threading application Linux exception: 'External: SIGABRT'
« on: January 16, 2012, 07:51:55 pm »
Hi,

Iv'e got a problem when using threads in linux. On windows it works great, but Linux does not like my code.

This is my main code in the thread:

Code: [Select]
procedure TMyThread.Execute;
var
  myBitMap : TBitmap;
  myMemImage : TFPMemoryImage;
  myImgReader: TFPReaderJpeg;
begin
  myMemImage  :=  TFPMemoryImage.create(0, 0);
  myImgReader := TFPReaderJPEG.Create;
  myBitmap := TBitmap.Create;
  try
    myMemImage.UsePalette := False;
//  myImgReader.Scale:= jsEighth;

    myMemImage.LoadFromFile('test.jpg', myImgReader);
    myBitmap.Assign(myMemImage);  <<======================== Problem Area, do not DEBUG past this point, computer might freeze!
  finally
    myMemImage.Free;
    myImgReader.Free;
    myBitmap.Free;
  end;
end;

This is the exception I get:

Code: [Select]
Project test raised exception class 'External: SIGABRT'.
I've made a small test application containing the problem:

(Caution: do not DEBUG past: myBitmap.Assign(myMemImage); Computer might freeze! )

http://home.kpn.nl/bakk2340/lazarus/trd-test.tar

Does anyone know what might be the problem here?

Thanks in advance,  Maarten
« Last Edit: January 16, 2012, 11:14:33 pm by MaartenJB »

MaartenJB

  • Full Member
  • ***
  • Posts: 116
Re: Threading application Linux exception: 'External: SIGABRT'
« Reply #1 on: January 28, 2012, 03:05:47 pm »
Anyone?

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4608
  • I like bugs.
Re: Threading application Linux exception: 'External: SIGABRT'
« Reply #2 on: January 28, 2012, 03:24:05 pm »
Did you add cthreads to uses section?

Juha
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

MaartenJB

  • Full Member
  • ***
  • Posts: 116
Re: Threading application Linux exception: 'External: SIGABRT'
« Reply #3 on: January 28, 2012, 05:01:24 pm »
Yes:

Code: [Select]
program test;

{$mode objfpc}{$H+}
uses
{$ifdef unix}
  cthreads, cmem, // the c memory manager is on some systems much faster for multi-threading
{$endif}
  Interfaces, // this includes the LCL widgetset
  Forms, f_test, trd_test
  { you can add units after this };
......

MaartenJB

  • Full Member
  • ***
  • Posts: 116
Re: Threading application Linux exception: 'External: SIGABRT'
« Reply #4 on: February 05, 2012, 04:32:27 pm »
Finally found a workaround, for anyone interested:

Code: [Select]
procedure TMyThread.Execute;
var
  myBitMap    : TBitmap;
  myMemImage  : TFPMemoryImage;
  myJpgReader : TFPReaderJpeg;
  myBmpWriter : TFPWriterBMP;
  myBmpStream : TMemoryStream;
begin
  myMemImage  := TFPMemoryImage.create(0, 0);
  myJpgReader := TFPReaderJPEG.Create;
  myBitmap    := TBitmap.Create;
  myBmpStream := TMemoryStream.Create;
  myBmpWriter := TFPWriterBMP.Create;
  try
    myMemImage.UsePalette := False;
    myJpgReader.Scale:= jsEighth;

    myMemImage.LoadFromFile('test.jpg', myJpgReader);
    myMemImage.SaveToStream(myBmpStream, myBmpWriter);

    myBmpStream.Position := 0;
    myBitMap.LoadFromStream(myBmpStream, myBmpStream.Size);
    myBitMap.SaveToFile('/root/tes.bmp');
  finally
    myMemImage.Free;
    myJpgReader.Free;
    myBitmap.Free;
    myBmpStream.Free;
    myBmpWriter.Free;
  end;
end;

 

TinyPortal © 2005-2018