Forum > Linux

Runtime error when include cthreads lib

(1/1)

guiwunsch:
Hi.
I'm trying to code a multithread application in Lazarus, but I've noticed that when I include the "cthreads" lib (always the first line of my project.lpr file), on some Linux distros, I get a runtime error when running the application. I believe it's some broken library. However, I don't know how to identify it. Could you help me?

project1.lpr:

--- Code: ---program project1;

uses
  cthreads,
  cmem;

begin
  writeln('test');
end.
--- End code ---

error:

--- Code: ---[root@dockerinaja /]# ./project1
Runtime error 203 at $0000000000418D5C
  $0000000000418D5C
  $000000000040086D
--- End code ---

ldd ./project1:

--- Code: ---[root@dockerinaja /]# ldd /project1
        linux-vdso.so.1 (0x00007ffc43fbd000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f359ff5e000)
        libdl.so.2 => /lib64/libdl.so.2 (0x00007f359ff58000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f359fd92000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f359ff8b000)
--- End code ---

Handoko:
This is the default uses clause generated by Lazarus, maybe you can try:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---uses  {$IFDEF UNIX}{$IFDEF UseCThreads}  cthreads,  {$ENDIF}{$ENDIF}  Interfaces, // this includes the LCL widgetset  Forms, unit1  { you can add units after this };

guiwunsch:
I've tried it that way. I just removed it to simplify the code in my sample to show that even codding very "clean" it presents the same error. I believe it is nothing in the code, but in the Linux distribution, as the same code works in other distributions. However, I would like some tips, as I don't know where to start debugging this problem.

ccrause:

--- Quote from: guiwunsch on July 26, 2021, 04:22:05 am --- However, I would like some tips, as I don't know where to start debugging this problem.

--- End quote ---
Runtime error 203 means heap overflow. Perhaps remove cmem, or put it before cthreads.

guiwunsch:
I noticed that I had a very old version of Free Pascal. I just updated to version 3.2.0 and it fixed my problem. Thanks.

Navigation

[0] Message Index

Go to full version