Recent

Author Topic: Runtime error when include cthreads lib  (Read 5225 times)

guiwunsch

  • Newbie
  • Posts: 6
Runtime error when include cthreads lib
« on: July 26, 2021, 01:23:36 am »
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: [Select]
program project1;

uses
  cthreads,
  cmem;

begin
  writeln('test');
end.

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

ldd ./project1:
Code: [Select]
[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)

Handoko

  • Hero Member
  • *****
  • Posts: 5122
  • My goal: build my own game engine using Lazarus
Re: Runtime error when include cthreads lib
« Reply #1 on: July 26, 2021, 04:13:53 am »
This is the default uses clause generated by Lazarus, maybe you can try:

Code: Pascal  [Select][+][-]
  1. uses
  2.   {$IFDEF UNIX}{$IFDEF UseCThreads}
  3.   cthreads,
  4.   {$ENDIF}{$ENDIF}
  5.   Interfaces, // this includes the LCL widgetset
  6.   Forms, unit1
  7.   { you can add units after this };

guiwunsch

  • Newbie
  • Posts: 6
Re: Runtime error when include cthreads lib
« Reply #2 on: July 26, 2021, 04:22:05 am »
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

  • Hero Member
  • *****
  • Posts: 843
Re: Runtime error when include cthreads lib
« Reply #3 on: July 26, 2021, 08:14:58 am »
However, I would like some tips, as I don't know where to start debugging this problem.
Runtime error 203 means heap overflow. Perhaps remove cmem, or put it before cthreads.

guiwunsch

  • Newbie
  • Posts: 6
Re: Runtime error when include cthreads lib
« Reply #4 on: August 01, 2021, 12:54:07 am »
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.

 

TinyPortal © 2005-2018