Recent

Author Topic: [SOLVED] This is driving me mad: "Inconsistency detected by ld.so"  (Read 2627 times)

Cyrax

  • Hero Member
  • *****
  • Posts: 737
Re: This is driving me mad: "Inconsistency detected by ld.so"
« Reply #15 on: March 27, 2019, 12:41:22 pm »

Oh sorry, I didn't see the ulimit -Ha part from the quote text field.  :-[

It seems there is no limits. Please open a terminal in your program directory, execute ulimit -s 512 and then execute your program and see if there is errors or program misbehaves .
Definitely no expert here, but why should i lower my Stack-size from 8196 KB to 512? (ulimit -s is for the "soft"-limit?!)

Just for testing purposes. Every created thread (yes, every thread too and there can be several hundred of them running) and process allocates the default 8196 KB of memory.  And if there is about 1024 threads running then kernel will allocate about 8 192 MB ( that is 8 GB!)  for them. It is bit too much. So lowering it to between 512KB - 1024KB should suffice.

Cyrax

  • Hero Member
  • *****
  • Posts: 737

engkin

  • Hero Member
  • *****
  • Posts: 2513
Re: This is driving me mad: "Inconsistency detected by ld.so"
« Reply #17 on: March 27, 2019, 02:33:14 pm »
Don't let us guess, provide a sample project that shows the problem. ld.so is the dynamic linker. Works when you run your app.

Zvoni

  • Full Member
  • ***
  • Posts: 198
One System to rule them all, One IDE to find them,
One Code to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
People call me crazy, because i'm jumping out of perfectly fine aircrafts

Zvoni

  • Full Member
  • ***
  • Posts: 198
Re: This is driving me mad: "Inconsistency detected by ld.so"
« Reply #19 on: March 27, 2019, 04:57:36 pm »
Don't let us guess, provide a sample project that shows the problem. ld.so is the dynamic linker. Works when you run your app.
The problem seems to be the sqlite-connection-object in context of running the connection in its own thread.
I don‘t have the error with MySQL, and as Thaddy mentioned, they changed some sqlite-bindings in trunk, where it doesn‘t report the error, while i‘m on fpc304
One System to rule them all, One IDE to find them,
One Code to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
People call me crazy, because i'm jumping out of perfectly fine aircrafts

Zvoni

  • Full Member
  • ***
  • Posts: 198
Re: This is driving me mad: "Inconsistency detected by ld.so"
« Reply #20 on: March 30, 2019, 10:36:10 am »
@Thaddy
By any chance: In trunk, are you using sqlite_open_v2 for InternalConnect?
I‘ve looked through the sourcecode, and found sqlite_open being used, and the docs for sqlite say, in that case sqlite is run with compiletime-options regarding multiple threads.
The default compile-options for distro-binaries is mode 1 (Serialized?), so right now i don‘t have a clue if it‘s my sqlite-lib being in singlethread-mode, or what you mentioned.
I‘m going to setup a small test, if the error occurs in a naked, stripped down, code
One System to rule them all, One IDE to find them,
One Code to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
People call me crazy, because i'm jumping out of perfectly fine aircrafts

Thaddy

  • Hero Member
  • *****
  • Posts: 8179
Re: This is driving me mad: "Inconsistency detected by ld.so"
« Reply #21 on: March 30, 2019, 10:52:49 am »
@Thaddy
By any chance: In trunk, are you using sqlite_open_v2 for InternalConnect?
I‘ve looked through the sourcecode, and found sqlite_open being used, and the docs for sqlite say, in that case sqlite is run with compiletime-options regarding multiple threads.
The default compile-options for distro-binaries is mode 1 (Serialized?), so right now i don‘t have a clue if it‘s my sqlite-lib being in singlethread-mode, or what you mentioned.
I‘m going to setup a small test, if the error occurs in a naked, stripped down, code
Yes. The Sqlite3 component for SqlDb is adapted to use sqlite_open_v2 by default on my request. Target release is 3.2.0 .
See https://bugs.freepascal.org/view.php?id=34278 which also documents briefly the new options available.
(That change definitely made Sqlite3 more robust., on my side all kind of quirks disappeared after the change!)

In your case I would suggest a defensive approach and use:
Code: Pascal  [Select]
  1. OpenFlags := [sofReadWrite,sofCreate,sofFullMutex]; // and maybe one of the caching strategies
Unless you run into performance issues.  See the Sqlite3 documentation, which you can now use a bit better with FPC.
You also still have to keep in mind Cyrax remark about lowering the stack size on some platforms.
« Last Edit: March 30, 2019, 11:32:30 am by Thaddy »
Read the manuals and if you are a professional get a proper education in computer science. Makes the forum a lot cleaner.

Zvoni

  • Full Member
  • ***
  • Posts: 198
Re: This is driving me mad: "Inconsistency detected by ld.so"
« Reply #22 on: March 30, 2019, 11:58:30 am »
You also still have to keep in mind Cyrax remark about lowering the stack size on some platforms.
About that: Any pointers how to do that? Still fairly new to everything.
At a guess: there is somewhere in Project-Options a Flag i can set the stacksize....

EDIT. Found it.
The "-Cs"-Option?
Value is what? in Kb?
Like "-Cs 512" is setting Stacksize to 512 Kb?
« Last Edit: March 30, 2019, 12:00:25 pm by Zvoni »
One System to rule them all, One IDE to find them,
One Code to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
People call me crazy, because i'm jumping out of perfectly fine aircrafts

Thaddy

  • Hero Member
  • *****
  • Posts: 8179
Re: This is driving me mad: "Inconsistency detected by ld.so"
« Reply #23 on: March 30, 2019, 12:05:19 pm »
You also still have to keep in mind Cyrax remark about lowering the stack size on some platforms.
About that: Any pointers how to do that? Still fairly new to everything.
At a guess: there is somewhere in Project-Options a Flag i can set the stacksize....

EDIT. Found it.
The "-Cs"-Option?
Value is what? in Kb?
Like "-Cs 512" is setting Stacksize to 512 Kb?
You can also set {$MINSTACKSIZE number} and  {$MAXSTACKSIZE number} in your code. The minimum value for {$maxstacksize} is 2048, though, you can't set it to 512, but 2048 should suffice in most cases.
Note that this goes for threading with TThread. If you want your threads to have a different or smaller stacksize, you should not use TThread but any of the beginthread methods: https://www.freepascal.org/docs-html/rtl/system/beginthread.html

I rarely use TThread in scenario's such as yours, because beginthread is more comfortable and has more control.
« Last Edit: March 30, 2019, 12:44:53 pm by Thaddy »
Read the manuals and if you are a professional get a proper education in computer science. Makes the forum a lot cleaner.

Cyrax

  • Hero Member
  • *****
  • Posts: 737
Re: This is driving me mad: "Inconsistency detected by ld.so"
« Reply #24 on: March 30, 2019, 12:19:13 pm »
You also still have to keep in mind Cyrax remark about lowering the stack size on some platforms.
About that: Any pointers how to do that? Still fairly new to everything.
At a guess: there is somewhere in Project-Options a Flag i can set the stacksize....

EDIT. Found it.
The "-Cs"-Option?
Value is what? in Kb?
Like "-Cs 512" is setting Stacksize to 512 Kb?

Open terminal window and execute command ulimit -s 512 and after executing that command, execute your program.

How to open terminal window : https://askubuntu.com/questions/183775/how-do-i-open-a-terminal

Zvoni

  • Full Member
  • ***
  • Posts: 198
Re: This is driving me mad: "Inconsistency detected by ld.so"
« Reply #25 on: March 30, 2019, 01:06:42 pm »
I‘m going to setup a small test, if the error occurs in a naked, stripped down, code

Oh, come on. I just set up a barebone test in the scenario i have (albeit not in a library, but a console-program), and sqlite doesn't throw any errors in the threads.
Create FakeMainThread, take over as MainThread,
FakeMainThread creates Childthreads, which itself create the TSQL-Trinity with Type 'SQLite3',
connect to test-database, and no error is thrown by any of the TSQL-Objects accessing data of the DB

*sigh*
Back to square one, and off i go bug-hunting.......

[CLOSED]
One System to rule them all, One IDE to find them,
One Code to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
People call me crazy, because i'm jumping out of perfectly fine aircrafts

Zvoni

  • Full Member
  • ***
  • Posts: 198
Re: This is driving me mad: "Inconsistency detected by ld.so"
« Reply #26 on: March 30, 2019, 01:46:22 pm »
You also still have to keep in mind Cyrax remark about lowering the stack size on some platforms.
About that: Any pointers how to do that? Still fairly new to everything.
At a guess: there is somewhere in Project-Options a Flag i can set the stacksize....

EDIT. Found it.
The "-Cs"-Option?
Value is what? in Kb?
Like "-Cs 512" is setting Stacksize to 512 Kb?

How curious.
Setting Stacksize in Project-Options to anything other than 0 results:
512 --> won't complile. No messages, no nothing
1024 (and higher) --> Stackoverflow Error

Switching off "-Ct"
512 --> won't complile. No messages, no nothing
1024 (and higher) --> seems (!) to work
One System to rule them all, One IDE to find them,
One Code to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
People call me crazy, because i'm jumping out of perfectly fine aircrafts

engkin

  • Hero Member
  • *****
  • Posts: 2513
Re: This is driving me mad: "Inconsistency detected by ld.so"
« Reply #27 on: March 30, 2019, 03:15:44 pm »
It is a parameter you pass to the thread constructor.

Zvoni

  • Full Member
  • ***
  • Posts: 198
Re: This is driving me mad: "Inconsistency detected by ld.so"
« Reply #28 on: March 30, 2019, 06:56:26 pm »
It is a parameter you pass to the thread constructor.

Ahhh, OK. Have seen it, looked it up, but since no example ever shows its use, i ignored it.

EDIT: Nope, whatever i pass to the inherited constructor (512,1024,2048,4096) results in an Exception "Could not Create Thread"
The Stacksize in Project-options was set to 0 for this test.

EDIT2:
Writeln('DefaultStackSize = '+DefaultStackSize.ToString);    --> 4194304
What's that? Apples? Bytes? Beers?

EDIT3:
*GNARF*
passing 524288 works (a.k.a 512kb)
« Last Edit: March 30, 2019, 07:08:39 pm by Zvoni »
One System to rule them all, One IDE to find them,
One Code to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
People call me crazy, because i'm jumping out of perfectly fine aircrafts

Zvoni

  • Full Member
  • ***
  • Posts: 198
Re: This is driving me mad: "Inconsistency detected by ld.so"
« Reply #29 on: March 31, 2019, 02:21:17 pm »
OK, we can close this Thread.
I've rebuild my code-base in a new project, and nowhere the afore mentioned error occurs. Seems to have been a bug in my code (no idea where)
One System to rule them all, One IDE to find them,
One Code to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
People call me crazy, because i'm jumping out of perfectly fine aircrafts