OS X: Exception when using dylib with Interfaces unit lazarus / 33-macOS - Mac OS X ---------------------------------------------------------------------- tk · 2016-06-02 13:47 Hi, have following exception under OS X (Yosemite on VMware) when using a simplest dylib with Interfaces unit: Library source: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i library testlib; {$R *.res} uses CThreads, Interfaces; beginend.  Test program source: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program test; {$mode objfpc}{$H+} uses  {$IFDEF UNIX}{$IFDEF UseCThreads}  cthreads,  {$ENDIF}{$ENDIF}  Interfaces, // this includes the LCL widgetset  Forms, main  { you can add units after this }; {$R *.res} begin  RequireDerivedFormResource:=True;  Application.Initialize;  Application.CreateForm(TForm1, Form1);  Application.Run;end. Main.pas: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit main; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls; type   { TForm1 }   TForm1 = class(TForm)    Button1: TButton;    procedure Button1Click(Sender: TObject);  private    { private declarations }  public    { public declarations }  end; var  Form1: TForm1; implementation {$R *.lfm} uses  DynLibs,  LCLIntf, LCLType, LMessages;  { TForm1 } procedure TForm1.Button1Click(Sender: TObject);var  HLib: THandle;  S: string;begin  S := ExtractFilePath(Application.ExeName);  HLib := LoadLibrary(S + 'libtestlib.dylib');  FreeLibrary(HLib);end; end.  The library is loaded and unloaded without error (HLib is valid) but after the main program terminates there is SIGSEGV exception in file NSObject.inc in procedure NSObject.release. Is only problem under OS X, tested with widgetsets both carbon and cocoa. When I just remove the Interfaces unit from the library there is no exception (and dylib size 10x smaller). I need the Interfaces unit because I use forms in the library (which under Win and Linux works fine). Bug in LCL? Thank you ---------------------------------------------------------------------- skalogryz · 2016-06-02 14:42 Quote from: tk on June 02, 2016, 03:47:04 pmI need the Interfaces unit because I use forms in the library (which under Win and Linux works fine). Bug in LCL? Very likely. Please file the bug report with the sample project attached. ---------------------------------------------------------------------- tk · 2016-06-02 15:26 Bug report: http://bugs.freepascal.org/view.php?id=30231 EDIT: In the bug report there is temporary workaround described which I've found now.