[fpc-devel] Inconsistency detected in dynamic library

2009-11-16 Thread Hans-Peter Suter
When I execute a small program which links to a dynamic library, ld complains:

cha...@devmachine:/data/test/src/shlib$ ./TestExe
hello 42
Inconsistency detected by ld.so: dl-fini.c: 195: _dl_fini: Assertion
`ns != 0 || i == nloaded' failed!

This is on Debian Lenny (Free Pascal Compiler version 2.2.2
[2008/07/30] for i386
, GNU ld (GNU Binutils for Debian) 2.18.0.20080103). On my Mac the code works.

I do not have much experience with fpc (on linux) and dynamic
libraries and wanted to ask if there is something obvious which I do
wrong. And/or what next steps I should/could do?

(in google I found a similar problem
(http://www.mail-archive.com/fpc-pas...@lists.freepascal.org/msg12444.html)
but it doesn't help me).

The code is below. Thanks for tips and having a look!

Hans-Peter


- TestShlib.pas --
library TestShlib;
{$mode objfpc}{$H+}
uses
  SysUtils;
function hello: integer; cdecl;
  begin
result:= 42;
  end;
exports hello;
begin
end.

- TestExe.pas --
program TestExe;
{$mode objfpc}{$H+}
uses
  SysUtils;
function hello: integer; cdecl; external 'TestShlib';
begin
  WriteLn( Format( 'hello %d', [hello()] ) );
end.

- compile/link --
fpc -CD TestShlib.pas -o./TestShlib.so
fpc -k"-R ." -k-lTestShlib TestExe.pas
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] Inconsistency detected in dynamic library

2009-11-16 Thread Hans-Peter Suter
2009/11/16 Jonas Maebe :

> You may want to use at least FPC 2.2.4, several bugs related to dynamic 
> libraries on *nix platforms were fixed there.

Thanks for your answer! - I updated to FPC 2.2.4 (*) but the
inconsistency message is still there. The same happened when I tested
on another (VM) machine.


cha...@devmachine:/data/hs$ fpc -CD TestShlib.pas
Free Pascal Compiler version 2.2.4-3 [2009/06/03] for i386
Copyright (c) 1993-2008 by Florian Klaempfl
Target OS: Linux for i386
Compiling TestShlib.pas
Linking libTestShlib.so
11 lines compiled, 0.1 sec

cha...@devmachine:/data/hs$ fpc -k"-R ." -k"-lTestShlib" TestExe.pas
Free Pascal Compiler version 2.2.4-3 [2009/06/03] for i386
Copyright (c) 1993-2008 by Florian Klaempfl
Target OS: Linux for i386
Compiling TestExe.pas
Linking TestExe
8 lines compiled, 0.0 sec

cha...@devmachine:/data/hs$ ./TestExe
hello 42
Inconsistency detected by ld.so: dl-fini.c: 195: _dl_fini: Assertion
`ns != 0 || i == nloaded' failed!


Hans-Peter

(*) wget 
http://sourceforge.net/projects/lazarus/files/Lazarus%20Linux%20i386%20DEB/Lazarus%200.9.28.2/fpc-2.2.4-3.i386.deb.tar/download
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


[fpc-devel] Error: Data element too large / Compilation aborted .. unhandled exception .. AV

2017-03-15 Thread Hans-Peter Suter
Goedenavond,

The following snippet gives the above mentioned error message on Mac
(Yosem.) and aborts the compilation process on Ubuntu (14.04). I'm
using version 3.0.2 [2017/02/12] for i386 and 3.0.2 [2017/02/25] for
x86_64. There are several variants (mentioned in code) which influence the
outcome. Code is from a low-level header file which I likely won't ever
need but I thought it might be of interest nevertheless.

Hans-Peter

PS: in case this should go to Tracker/Mantis? could this do someone, maybe?
(otherwise let me know, thanks).

```pascal (file saved as a.pas)
{$MODE DELPHI}  // (1) _NOT_ using delphi mode works
unit a;

{==}
interface

type
  pSExp = pointer;
  aSExpArr = array[0..((MaxInt div SizeOf(pSExp)) - 1)] of pSExp;
  // aSExpArr = array[0..((MaxInt div 2*SizeOf(pSExp)) - 1)] of pSExp;
  // (2) using a _shorter_ array, eg. ^^ works on Ubuntu (Mac still Error)

  pFoo = ^aFoo;
  aFoo = record
rec: aSExpArr;
  end;

function ahoppla(_x: pFoo): aSExpArr;

{==}
implementation

type
  pData = ^aData;
  aData = record
offset: array[1..24] of byte;  // (3) uncommenting offset works
SExpArr: aSExpArr;
  end;

function ahoppla(_x: pFoo): aSExpArr;
  begin
ahoppla:= pData(_x)^.SExpArr;
// ahoppla:= _x.rec;   // (4) _not_ casting works on Ubuntu
(Mac error)
  end;

end {a}.
```
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel