using RunCommand to wrap LXD linux container crashes lazarus / 23-Operating Systems ---------------------------------------------------------------------- nomorelogic · 2025-02-06 14:35 hello everyone I have a problem using RunCommand (unit process); this is a special case as I am doing some testing with linux LXD containers. My system is DEVUAN: Code: [Select]uname -a Linux myhost 6.1.0-30-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.124-1 (2025-01-12) x86_64 GNU/Linux LXD version: Code: [Select]$ lxc --version 5.0.2 . The program is trivial and, once compiled, it must be launched from the shell as root user or using "sudo": Code: [Select]sudo ./testlxc. Below is the code. Code: [Select]program testlxc; uses process; const   LXC_BIN = ‘/usr/bin/lxc’; var AStdOut: string; begin   Writeln(LXC_BIN + ‘ LIST ’);   RunCommand(LXC_BIN, [‘list’], AStdOut); // this works   Writeln(‘output: >>’);   Writeln(AStdOut);   Writeln(‘<<’);   Writeln(LXC_BIN + ‘ INIT ’);   RunCommand(LXC_BIN, [‘init’, ‘ubuntu:20.04’, ‘u1’], AStdOut); // here it crashes   Writeln(‘output: >>’);   Writeln(AStdOut);   Writeln(‘<<’); end. . The first invocation of RunCommand with parameter ‘list’ works correctly as expected. The second invocation with parameter ‘init’, on the other hand, crashes. The result is as follows: Code: [Select]$ sudo ./testlxc /usr/bin/lxc LIST output: >> +------+---------+------+------+-----------+-----------+ | NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS | +------+---------+------+------+-----------+-----------+ | m1 | STOPPED | | CONTAINER | 0 | +------+---------+------+------+-----------+-----------+ << /usr/bin/lxc INIT Running from terminal: Code: [Select]sudo lxc list. or Code: [Select]sudo lxc init ubuntu:20.04 u1everything works correctly and smoothly. I can't see where the problem lies. Any ideas? thanks nomorelogic ---------------------------------------------------------------------- MarkMLl · 2025-02-06 15:31 I'd suggest that the first thing to try would be running it as root rather than using sudo. If that fails in the same way I'd suggest supplying a couple of dummy parameters in the first RunCommand() invocation, so that you can be sure that you're comparing like with like. I've not used LXD, but from my experience with Docker etc. I think you need to focus on whether it's RunCommand() which is crashing (i.e. before transferring control into lxc), or lxc (after control has been transferred into it) because e.g. it wants some resource which it still can't get at despite the use of sudo. MarkMLl ---------------------------------------------------------------------- nomorelogic · 2025-02-06 16:18 thanks for your suggestions I ran the test as root user, unfortunately not much changed I also added some parameters to the first invocation of RunCommand 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 testlxc;uses process; const  LXC_BIN = '/usr/bin/lxc'; var AStdOut: string;begin   Writeln(LXC_BIN + ' LIST ');  RunCommand(LXC_BIN, ['list', '-f', 'json'], AStdOut);   // <- works  Writeln('output: >>');  Writeln(AStdOut);  Writeln('<<');    Writeln(LXC_BIN + ' INIT ');  RunCommand(LXC_BIN, ['init', 'ubuntu:20.04', 'u1'], AStdOut);    // <- crashes  Writeln('output: >>');  Writeln(AStdOut);  Writeln('<<'); end.  this is the output (executed as root) 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 # ./testlxc /usr/bin/lxc LIST output: >>[{"architecture":"x86_64","config":{"image .architecture":"amd64","image.description":"Macaroni OS Eagle Minimal amd64 (20250127_15:11)","image.os":"Macaroni OS","image.release":"curr ent","image.serial":"20250127_15:11","image.type":"squashfs","volatile .base_image":"00e40cbff9f6be5a7524cc3ee64cc5bafe28b85e8a94cf72193450af 30f2d2f5","volatile.cloud-init.instance-id":"ce50a30b-7add-4ecd-aee5- be0d7b7a0e50","volatile.eth0.hwaddr":"00:16:3e:e1:1f:8d","volatile.idm ap.base":"0","volatile.idmap.current":"[{\"Isuid\":true,\"Isgid\":fals e,\"Hostid\":165536,\"Nsid\":0,\"Maprange\":10000001},{\"Isuid\":false ,\"Isgid\":true,\"Hostid\":165536,\"Nsid\":0,\"Maprange\":10000001}]", "volatile.idmap.next":"[{\"Isuid\":true,\"Isgid\":false,\"Hostid\":165 536,\"Nsid\":0,\"Maprange\":10000001},{\"Isuid\":false,\"Isgid\":true, \"Hostid\":165536,\"Nsid\":0,\"Maprange\":10000001}]","volatile.last_s tate.idmap":"[{\"Isuid\":true,\"Isgid\":false,\"Hostid\":165536,\"Nsid \":0,\"Maprange\":10000001},{\"Isuid\":false,\"Isgid\":true,\"Hostid\" :165536,\"Nsid\":0,\"Maprange\":10000001}]","volatile.last_state.power ":"STOPPED","volatile.uuid":"d134e8c3-9f00-4b14-a863- a7a393e21e13"},"devices":{"sharedsrc":{"path":"/tmp","source":"/media/ dati/dev/lxc/test001/","type":"disk"}},"ephemeral":false,"profiles":[" default"],"stateful":false,"description":"","created_at":"2025-01- 30T14:44:59.593127664Z","expanded_config":{"image.architecture":"amd64 ","image.description":"Macaroni OS Eagle Minimal amd64 (20250127_15:11)","image.os":"Macaroni OS","image.release":"current"," image.serial":"20250127_15:11","image.type":"squashfs","volatile.base_ image":"00e40cbff9f6be5a7524cc3ee64cc5bafe28b85e8a94cf72193450af30f2d2 f5","volatile.cloud-init.instance-id":"ce50a30b-7add-4ecd-aee5- be0d7b7a0e50","volatile.eth0.hwaddr":"00:16:3e:e1:1f:8d","volatile.idm ap.base":"0","volatile.idmap.current":"[{\"Isuid\":true,\"Isgid\":fals e,\"Hostid\":165536,\"Nsid\":0,\"Maprange\":10000001},{\"Isuid\":false ,\"Isgid\":true,\"Hostid\":165536,\"Nsid\":0,\"Maprange\":10000001}]", "volatile.idmap.next":"[{\"Isuid\":true,\"Isgid\":false,\"Hostid\":165 536,\"Nsid\":0,\"Maprange\":10000001},{\"Isuid\":false,\"Isgid\":true, \"Hostid\":165536,\"Nsid\":0,\"Maprange\":10000001}]","volatile.last_s tate.idmap":"[{\"Isuid\":true,\"Isgid\":false,\"Hostid\":165536,\"Nsid \":0,\"Maprange\":10000001},{\"Isuid\":false,\"Isgid\":true,\"Hostid\" :165536,\"Nsid\":0,\"Maprange\":10000001}]","volatile.last_state.power ":"STOPPED","volatile.uuid":"d134e8c3-9f00-4b14-a863- a7a393e21e13"},"expanded_devices":{"eth0":{"name":"eth0","network":"lx dbr0","type":"nic"},"root":{"path":"/","pool":"default","type":"disk"} ,"sharedsrc":{"path":"/tmp","source":"/media/dati/dev/lxc/test001/","t ype":"disk"}},"name":"m1","status":"Stopped","status_code":102,"last_u sed_at":"2025-02- 03T16:35:51.011958116Z","location":"none","type":"container","project" :"default","backups":null,"state":{"status":"Stopped","status_code":10 2,"disk":{"root":{"usage":169681408}},"memory":{"usage":0,"usage_peak" :0,"swap_usage":0,"swap_usage_peak":0},"network":null,"pid":0,"process es":0,"cpu":{"usage":0}},"snapshots":null}] <>[{"architecture":"x86_64",  [...cut...]  ,"snapshots":null}] <#include  int main() {  int status = 0;   printf("lxc LIST\n");  printf("Output >> \n");  status = system("/usr/bin/lxc list -f json");  printf("<< (Status=%d)\n\n", status);   printf("lxc INIT\n");  printf("Output >> \n");  status = system("/usr/bin/lxc init ubuntu:20.04 u1");  printf("<< (Status=%d)\n");   return 0;}  this is the correct output 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 sudo ./testlxc lxc LISTOutput >> [{"architecture":"x86_64", ...[cut] ...,"snapshots":null}]<< (Status=0) lxc INITOutput >> Creating u1<< (Status=-1768918016)  I'm starting to get a little confused. I will investigate further. ---------------------------------------------------------------------- MarkMLl · 2025-02-07 15:45 Gut feeling is that it's something to do with RunCommand(), e.g. the shell/environment variables being corrupted. I wonder what would happen if you replaced the two invocations of RunCommand() with invocations of distinct TProcess instances? My rationale there is that in principle at least there will be no retained state between the instances... it's what I tend to use and (touch wood) I've never had any inexplicable problems. MarkMLl ---------------------------------------------------------------------- MarkMLl · 2025-02-07 20:10 I'm a bit uncomfortable here: I was considering loading up what you've got onto a machine so that I could write it up for colleagues, but I notice from https://en.wikipedia.org/wiki/LXC that LXC and LXD appear to be distinct: can you tell me exactly what Debian-style packages you installed to get to your current position? MarkMLl ---------------------------------------------------------------------- nomorelogic · 2025-02-08 11:46 Quote from: MarkMLl on February 07, 2025, 09:10:09 pmcan you tell me exactly what Debian-style packages you installed to get to your current position? Of course. I first installed LXC and then LXD and I did both installations via Synaptic. I am not sure if it is necessary to install LXC but this is what I did in my case. For LXC: lxclxc-templateslxcfsliblxc-commonliblxc1libvirt-daemon-driver-lxc For LXD (subsequent installation) lxdlxd-agentlxd-client After LXD installation, I ran ‘lxd init’, confirming with enter each of the proposed defaults. It is correct to say that LXC and LXD are different, although the latter (LXD) rests on LXC. To easily distinguish the 2 systems: LXD: for image management, there is a single command  called ‘lxc’ which accepts parameters (the one I am using now in my tests) LXC: for image management, it has a series of commands starting with ‘lxc-’, such as ‘lxc-create’, ‘lxc-attach’ and so on Thank you nomorelogic ---------------------------------------------------------------------- nomorelogic · 2025-02-08 11:59 Quote from: MarkMLl on February 07, 2025, 04:45:40 pmI wonder what would happen if you replaced the two invocations of RunCommand() with invocations of distinct TProcess instances? I did the test you suggested and using 2 successive invocations of TProcess works! This is the code. 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 testlxc2;uses process; const  LXC_BIN = '/usr/bin/lxc'; var AStdOut: string;  AProcess: TProcess;begin   Writeln(LXC_BIN + ' LIST using TProcess');  AProcess := TProcess.Create(nil);  try    AProcess.Executable:= LXC_BIN;    AProcess.Parameters.Add('list');    AProcess.Parameters.Add('-f');    AProcess.Parameters.Add('json');    AProcess.Options := AProcess.Options + [poWaitOnExit];    Writeln('Output >>');    AProcess.Execute;   finally    AProcess.Free;    Writeln('<< Output of "LIST"');  end;   Writeln('');   Writeln(LXC_BIN + ' INIT using TProcess');  AProcess := TProcess.Create(nil);  try    AProcess.Executable:= LXC_BIN;    AProcess.Parameters.Add('init');    AProcess.Parameters.Add('ubuntu:20.04');    AProcess.Parameters.Add('u1');    AProcess.Options := AProcess.Options + [poWaitOnExit];    Writeln('Output >>');    AProcess.Execute;   finally    AProcess.Free;    Writeln('<< Output of "INIT"');  end;   Writeln(''); end.  At this point I would say that, at least in this case, there is a bug in RunCommand. ---------------------------------------------------------------------- MarkMLl · 2025-02-08 12:09 Quote from: nomorelogic on February 08, 2025, 12:46:02 pmIt is correct to say that LXC and LXD are different, although the latter (LXD) rests on LXC. To easily distinguish the 2 systems: LXD: for image management, there is a single command  called ‘lxc’ which accepts parameters (the one I am using now in my tests) LXC: for image management, it has a series of commands starting with ‘lxc-’, such as ‘lxc-create’, ‘lxc-attach’ and so on Trying to sort things out for my own edification as much as anything else... So LXD is on top of LXC, rather than the two being in some way in competition or one being a fork of the other. Docker is at more or less the same level as LXD, although I don't believe it relies on LXC these days. I've explored this for things like FPGA development and have come up against security features which I had to relax before I could e.g. get USB port access. Snap, AppImage etc. are at more or less the same level as Docker. I'm using these to encapsulate things like Ghidra and FreeCAD. runc is at a lower level, looking at my desktop system I think it was pulled in as part of the basic Debian system. Virtualisation (Qemu, KVM etc.) and paravirtualisation (UML) are of course completely distinct. I was tempted to just stick LXC on a system until I got snared by the runc rabbithole, but I'd rather not get too deeply into it right now since I'm trying to do a hardware repair (no schematic, no silkscreened component labels...). Maybe later. I'd note that since I routinely SSH into Docker containers it would probably be possible to have the Lazarus IDE on the host but gdbserver (accessed via a socket) in the guest/container. However in almost all cases it would be better to have the whole IDE in the guest, with either VNC or X11 piped through SSH. I'm not sure whether that has any direct relevance to your attempts to find out what LXD is doing ... ... if I had to recommend a course of action I'd suggest using TProcess as I mentioned earlier. MarkMLl ---------------------------------------------------------------------- MarkMLl · 2025-02-08 12:11 Posts crossed but I didn't edit my last one. Quote from: nomorelogic on February 08, 2025, 12:59:58 pmAt this point I would say that, at least in this case, there is a bug in RunCommand. OK, suggest you raise a bug report. Glad that you've got something that allows you to make progress. MarkMLl ---------------------------------------------------------------------- nomorelogic · 2025-02-08 12:14 Quote from: nomorelogic on February 08, 2025, 12:59:58 pmAt this point I would say that, at least in this case, there is a bug in RunCommand. if, using TProcess, I intercept the standard output I have the same result as RunCommand: crash at the same point. The code: 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 testlxc3;uses Classes, SysUtils, process; const  LXC_BIN = '/usr/bin/lxc';  BUF_SIZE = 2048; var AProcess: TProcess;    OutStream : TStream;    BytesRead    : longint;    Buffer       : array[1..BUF_SIZE] of byte;begin   // ----------------------------------------------------  Writeln(LXC_BIN + ' LIST using TProcess');  AProcess := TProcess.Create(nil);  try    OutStream := TMemoryStream.Create;    AProcess.Executable:= LXC_BIN;  AProcess.Parameters.Add('list');    AProcess.Parameters.Add('-f');  AProcess.Parameters.Add('json');    AProcess.Options := [poUsePipes];    AProcess.Execute;     repeat        BytesRead := AProcess.Output.Read(Buffer, BUF_SIZE);        OutStream.Write(Buffer, BytesRead)    until BytesRead = 0;     with TStringList.Create do    begin        OutStream.Position := 0;        LoadFromStream(OutStream);        Writeln('Output (', Count, ' lines) >>');        writeln(Text);        Writeln('<< Output of "LIST"');      Free;      end;   finally    OutStream.Free;    AProcess.Free;  end;   Writeln('');   // ----------------------------------------------------  Writeln(LXC_BIN + ' INIT using TProcess');  AProcess := TProcess.Create(nil);  try    OutStream := TMemoryStream.Create;    AProcess.Executable:= LXC_BIN;  AProcess.Parameters.Add('init');    AProcess.Parameters.Add('ubuntu:20.04');    AProcess.Parameters.Add('u1');    AProcess.Options := [poUsePipes];  AProcess.Execute;     repeat        BytesRead := AProcess.Output.Read(Buffer, BUF_SIZE);        OutStream.Write(Buffer, BytesRead)    until BytesRead = 0;     with TStringList.Create do    begin        OutStream.Position := 0;        LoadFromStream(OutStream);        Writeln('Output (', Count, ' lines) >>');        writeln(Text);        Writeln('<< Output of "INIT"');      Free;      end;   finally    OutStream.Free;    AProcess.Free;  end; end. ---------------------------------------------------------------------- nomorelogic · 2025-02-08 12:27 Quote from: MarkMLl on February 08, 2025, 01:09:43 pmI'd note that since I routinely SSH into Docker containers it would probably be possible to have the Lazarus IDE on the host but gdbserver (accessed via a socket) in the guest/container. However in almost all cases it would be better to have the whole IDE in the guest, with either VNC or X11 piped through SSH. I'm not sure whether that has any direct relevance to your attempts to find out what LXD is doing ... ... if I had to recommend a course of action I'd suggest using TProcess as I mentioned earlier. This of gdbserver is something I must try out. Speaking of remote... In the past I have also done some testing with docker and lazarus. In this link there is a docker image made by me with xrdp + Lazarus. https://hub.docker.com/r/nomorelogic/lazarus_184_xrdp Once launched you can, with an RDP client, use Lazarus within the image. I can't try it now but in the link there are instructions on how to use it. ---------------------------------------------------------------------- MarkMLl · 2025-02-08 12:36 Quote from: nomorelogic on February 08, 2025, 01:27:27 pmOnce launched you can, with an RDP client, use Lazarus within the image. I can't try it now but in the link there are instructions on how to use it. Yes, I normally build a Debian container, SSH into it, and add the development stuff I need. X11 through SSH normally works well, but there's an issue- possibly based on the widgetset version- where some software spends all its time polling input devices (i.e. generating lots of network traffic). In that scenario VNC (hence also RDP etc.) is a lifesaver. MarkMLl ---------------------------------------------------------------------- MarkMLl · 2025-02-08 13:17 Quote from: nomorelogic on February 08, 2025, 01:14:48 pmif, using TProcess, I intercept the standard output I have the same result as RunCommand: crash at the same point. For the purpose of a bug report, can you distill that to something that the maintainers will almost certainly find on any Linux system? MarkMLl ---------------------------------------------------------------------- nomorelogic · 2025-02-08 18:57 do you mean if I can replicate the bug by avoiding using lxc? if that is the case, I think that nothing more is needed than to install lxd. Edit: In the sense that the case I have is quite strange: lxc with parameter “list” works, with parameter “init” does not. ---------------------------------------------------------------------- MarkMLl · 2025-02-08 19:54 Quote from: nomorelogic on February 08, 2025, 07:57:06 pmdo you mean if I can replicate the bug by avoiding using lxc? if that is the case, I think that nothing more is needed than to install lxd. Edit: In the sense that the case I have is quite strange: lxc with parameter “list” works, with parameter “init” does not. The problem there is that the FPC developers probably won't have LXC/LXD on their systems, and it's probably not something that can be reliably tested inside another containerisation system. Incidentally: going back to my earlier comment about shell/environment variables getting screwed (or for that matter a variable associated with RunCommand() not being restored): what happens if you swap the order? Is it  lxc init  that fails, or the second invocation of RunCommand()? What happens if you invoke RunCommand() to run  lxc list  twice? MarkMLl ---------------------------------------------------------------------- nomorelogic · 2025-02-08 21:39 ok i got it these are tests i can do in case it will be the second execution that fails or even the second execution of the same command, I can try to replicate the crash by avoiding LXD/LXC nomorelogic ---------------------------------------------------------------------- nomorelogic · 2025-02-10 13:53 I have carried out some tests and I believe that this indicates a problem in the execution of ‘lxc’ with the ‘init’ parameter when reading the standard output TProcess: execution of ‘lxc list’ twice (result = no crash) 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 testlxc4;uses Classes, SysUtils, process; const  LXC_BIN = '/usr/bin/lxc';  BUF_SIZE = 2048; var AProcess: TProcess;    OutStream : TStream;    BytesRead    : longint;    Buffer       : array[1..BUF_SIZE] of byte;begin   // ----------------------------------------------------  Writeln(LXC_BIN + ' LIST using TProcess');  AProcess := TProcess.Create(nil);  try    OutStream := TMemoryStream.Create;    AProcess.Executable:= LXC_BIN;  AProcess.Parameters.Add('list');    AProcess.Parameters.Add('-f');  AProcess.Parameters.Add('json');    AProcess.Options := [poUsePipes];    AProcess.Execute;     repeat        BytesRead := AProcess.Output.Read(Buffer, BUF_SIZE);        OutStream.Write(Buffer, BytesRead)    until BytesRead = 0;     with TStringList.Create do    begin        OutStream.Position := 0;        LoadFromStream(OutStream);        Writeln('Output (', Count, ' lines) >>');        writeln(Text);        Writeln('<< Output of "LIST"');      Free;      end;   finally    OutStream.Free;    AProcess.Free;  end;   Writeln('');   // ----------------------------------------------------  Writeln(LXC_BIN + ' LIST using TProcess');  AProcess := TProcess.Create(nil);  try    OutStream := TMemoryStream.Create;    AProcess.Executable:= LXC_BIN;  AProcess.Parameters.Add('list');    AProcess.Parameters.Add('-f');  AProcess.Parameters.Add('json');    AProcess.Options := [poUsePipes];    AProcess.Execute;     repeat        BytesRead := AProcess.Output.Read(Buffer, BUF_SIZE);        OutStream.Write(Buffer, BytesRead)    until BytesRead = 0;     with TStringList.Create do    begin        OutStream.Position := 0;        LoadFromStream(OutStream);        Writeln('Output (', Count, ' lines) >>');        writeln(Text);        Writeln('<< Output of "LIST"');      Free;      end;   finally    OutStream.Free;    AProcess.Free;  end;  end.   TProcess: execution of (1) lxc init (2) lxc list (result = crash on lxc init) 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 testlxc5;uses Classes, SysUtils, process; const  LXC_BIN = '/usr/bin/lxc';  BUF_SIZE = 2048; var AProcess: TProcess;    OutStream : TStream;    BytesRead    : longint;    Buffer       : array[1..BUF_SIZE] of byte;begin   // ----------------------------------------------------  Writeln(LXC_BIN + ' INIT using TProcess');  AProcess := TProcess.Create(nil);  try    OutStream := TMemoryStream.Create;    AProcess.Executable:= LXC_BIN;  AProcess.Parameters.Add('init');    AProcess.Parameters.Add('ubuntu:20.04');    AProcess.Parameters.Add('u1');    AProcess.Options := [poUsePipes];  AProcess.Execute;     repeat        BytesRead := AProcess.Output.Read(Buffer, BUF_SIZE);        OutStream.Write(Buffer, BytesRead)    until BytesRead = 0;     with TStringList.Create do    begin        OutStream.Position := 0;        LoadFromStream(OutStream);        Writeln('Output (', Count, ' lines) >>');        writeln(Text);        Writeln('<< Output of "INIT"');      Free;      end;   finally    OutStream.Free;    AProcess.Free;  end;   Writeln('');   // ----------------------------------------------------  Writeln(LXC_BIN + ' LIST using TProcess');  AProcess := TProcess.Create(nil);  try    OutStream := TMemoryStream.Create;    AProcess.Executable:= LXC_BIN;  AProcess.Parameters.Add('list');    AProcess.Parameters.Add('-f');  AProcess.Parameters.Add('json');    AProcess.Options := [poUsePipes];    AProcess.Execute;     repeat        BytesRead := AProcess.Output.Read(Buffer, BUF_SIZE);        OutStream.Write(Buffer, BytesRead)    until BytesRead = 0;     with TStringList.Create do    begin        OutStream.Position := 0;        LoadFromStream(OutStream);        Writeln('Output (', Count, ' lines) >>');        writeln(Text);        Writeln('<< Output of "LIST"');      Free;      end;   finally    OutStream.Free;    AProcess.Free;  end;  end.  TProcess: single execution of ‘lxc init’ (result = crash) 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 testlxc6;uses Classes, SysUtils, process; const  LXC_BIN = '/usr/bin/lxc';  BUF_SIZE = 2048; var AProcess: TProcess;    OutStream : TStream;    BytesRead    : longint;    Buffer       : array[1..BUF_SIZE] of byte;begin   // ----------------------------------------------------  Writeln(LXC_BIN + ' INIT using TProcess');  AProcess := TProcess.Create(nil);  try    OutStream := TMemoryStream.Create;    AProcess.Executable:= LXC_BIN;  AProcess.Parameters.Add('init');    AProcess.Parameters.Add('ubuntu:20.04');    AProcess.Options := [poUsePipes];    AProcess.Execute;     repeat        BytesRead := AProcess.Output.Read(Buffer, BUF_SIZE);        OutStream.Write(Buffer, BytesRead)    until BytesRead = 0;     with TStringList.Create do    begin        OutStream.Position := 0;        LoadFromStream(OutStream);        Writeln('Output (', Count, ' lines) >>');        writeln(Text);        Writeln('<< Output of "INIT"');      Free;      end;   finally    OutStream.Free;    AProcess.Free;  end;   Writeln('');   end.  TProcess: single execution of ‘docker pull’ (result = no crash) 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 testlxc6;uses Classes, SysUtils, process; const  LXC_BIN = '/usr/bin/docker';  BUF_SIZE = 2048; var AProcess: TProcess;    OutStream : TStream;    BytesRead    : longint;    Buffer       : array[1..BUF_SIZE] of byte;begin   // ----------------------------------------------------  Writeln(LXC_BIN + ' PULL using TProcess');  AProcess := TProcess.Create(nil);  try    OutStream := TMemoryStream.Create;    AProcess.Executable:= LXC_BIN;  AProcess.Parameters.Add('pull');    AProcess.Parameters.Add('ubuntu:latest');    AProcess.Options := [poUsePipes];    AProcess.Execute;     repeat        BytesRead := AProcess.Output.Read(Buffer, BUF_SIZE);        OutStream.Write(Buffer, BytesRead)    until BytesRead = 0;     with TStringList.Create do    begin        OutStream.Position := 0;        LoadFromStream(OutStream);        Writeln('Output (', Count, ' lines) >>');        writeln(Text);        Writeln('<< Output of "INIT"');      Free;      end;   finally    OutStream.Free;    AProcess.Free;  end;   Writeln('');   end.  c++: single execution of ‘lxc init reading standard output (result = no crash) Code: C  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i #include #include  int main() {    FILE *fp;    char buffer[128];     // Run the command    // fp = popen("/usr/bin/lxc list -f json", "r");    fp = popen("/usr/bin/lxc init ubuntu:20.04", "r");    if (fp == NULL) {        perror("popen error");        return -1;    }     // Read output a line at a time - output it.    while (fgets(buffer, sizeof(buffer), fp) != NULL) {        printf("%s", buffer); // Process the output as needed    }     // Close the process    pclose(fp);    return 0;}  I did all these tests with the fpc trunk. Before reporting the bug, I'll do them again with fpc 3.2.2, I'll keep you updated. nomorelogic ---------------------------------------------------------------------- MarkMLl · 2025-02-10 14:06 Suggest you check that  lxc init  isn't sending its output to stderr rather than stdout. MarkMLl ---------------------------------------------------------------------- nomorelogic · 2025-02-10 19:14 Testet Std Error too, nothing change. I created a new issue: https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/41419