Re: Program crash: GC destroys an object unexpectedly

2021-09-19 Thread eugene via Digitalmars-d-learn
On Sunday, 19 September 2021 at 20:12:45 UTC, eugene wrote: On Monday, 13 September 2021 at 17:54:43 UTC, eugene wrote: full src is here http://zed.karelia.ru/0/e/edsm-in-d-2021-09-10.tar.gz I've also made two simple examples, just in case -

Re: Program crash: GC destroys an object unexpectedly

2021-09-19 Thread eugene via Digitalmars-d-learn
On Sunday, 19 September 2021 at 16:27:55 UTC, jfondren wrote: This is also a sufficient patch to prevent the segfault: ``` diff --git a/echo_client.d b/echo_client.d index 1f8270e..0b968a8 100644 --- a/echo_client.d +++ b/echo_client.d @@ -39,4 +39,6 @@ void main(string[] args) { auto md =

Re: Program crash: GC destroys an object unexpectedly

2021-09-19 Thread eugene via Digitalmars-d-learn
On Sunday, 19 September 2021 at 16:27:55 UTC, jfondren wrote: This is a sufficient patch to prevent the segfault: ``` diff --git a/echo_client.d b/echo_client.d index 1f8270e..5ec41df 100644 --- a/echo_client.d +++ b/echo_client.d @@ -32,7 +32,7 @@ void main(string[] args) { sm.run();

Re: Program crash: GC destroys an object unexpectedly

2021-09-19 Thread eugene via Digitalmars-d-learn
On Monday, 13 September 2021 at 17:54:43 UTC, eugene wrote: full src is here http://zed.karelia.ru/0/e/edsm-in-d-2021-09-10.tar.gz I've also made two simple examples, just in case - http://zed.karelia.ru/0/e/edsm-in-d-simple-example-1.tar.gz Program does nothing, just waits for ^c, does not

Re: Program crash: GC destroys an object unexpectedly

2021-09-19 Thread eugene via Digitalmars-d-learn
On Sunday, 19 September 2021 at 16:27:55 UTC, jfondren wrote: So the problem here is that ctrl-C causes that message to come but Stopper's been collected and that address contains garbage. This is exactly what I was trying to say... Thanx a lot for your in-depth investigation of the trouble!

Re: D's dll and classes

2021-09-19 Thread Paul Backus via Digitalmars-d-learn
On Sunday, 19 September 2021 at 12:00:22 UTC, Hipreme wrote: Basically: I have a main program which would contain a lot of code. I have a secondary program which I want to call code from the main program, but it will be compiled as a DLL to the main program call a single entry point from that

Re: Program crash: GC destroys an object unexpectedly

2021-09-19 Thread jfondren via Digitalmars-d-learn
On Sunday, 19 September 2021 at 08:51:31 UTC, eugene wrote: reference-containing struct that vanishes on the return of your corresponding function I do not think it's a problem, otherwise **both programs would not work at all**. The GC doesn't reliably punish objects living past there not

Re: Program crash: GC destroys an object unexpectedly

2021-09-19 Thread eugene via Digitalmars-d-learn
On Monday, 13 September 2021 at 17:18:30 UTC, eugene wrote: The instance of Stopper is created in the scope of main(): ```d void main(string[] args) { auto stopper = new Stopper(); stopper.run(); ``` Look... I have added stopper into an array... ```d Stopper[] stoppers; auto

D's dll and classes

2021-09-19 Thread Hipreme via Digitalmars-d-learn
I have a plenty of questions related to the DLL things, .di files. Basically: I have a main program which would contain a lot of code. I have a secondary program which I want to call code from the main program, but it will be compiled as a DLL to the main program call a single entry point

Re: Extract base type of any array?

2021-09-19 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/19/21 12:20 AM, jfondren wrote: On Sunday, 19 September 2021 at 03:58:41 UTC, Kirill wrote: How can I get the base type of any (multidimensional/static/dynamic/associative) array? Example: ``` void main() {     int[][] intArr;     double[4][] doubleArr;     string[string][] strArr;    

Re: Program crash: GC destroys an object unexpectedly

2021-09-19 Thread eugene via Digitalmars-d-learn
On Saturday, 18 September 2021 at 09:54:05 UTC, jfondren wrote: On Saturday, 18 September 2021 at 09:39:24 UTC, eugene wrote: The definition of this struct was taken from /usr/include/dmd/druntime/import/core/sys/linux/epoll.d ... If the reason for crash was in EpollEvent alignment, programs

Re: Program crash: GC destroys an object unexpectedly

2021-09-19 Thread eugene via Digitalmars-d-learn
On Wednesday, 15 September 2021 at 23:07:45 UTC, jfondren wrote: Yep. This patch is sufficient to prevent the segfault: Your idea (hold references to all event sources somewhere) is quite clear, but it confuses me a bit, since 1) there **are** references to all event sources **already**,

Re: Program crash: GC destroys an object unexpectedly

2021-09-19 Thread eugene via Digitalmars-d-learn
reference-containing struct that vanishes on the return of your corresponding function I do not think it's a problem, otherwise **both programs would not work at all**. However, echo-server works without any surprises; echo-client also works, except that EventSources pointed by sg0 and sg1

Re: How to do "C++ classes"?

2021-09-19 Thread rempas via Digitalmars-d-learn
On Saturday, 18 September 2021 at 22:16:32 UTC, Adam D Ruppe wrote: On Saturday, 18 September 2021 at 15:38:38 UTC, rempas wrote: I'm seeing in the page about "BeterC" and in the part about the [retained features](https://dlang.org/spec/betterc.html#retained), the #11 says about "COM classes

Re: GC seems to crash my C-code function

2021-09-19 Thread frame via Digitalmars-d-learn
On Sunday, 19 September 2021 at 02:18:20 UTC, Steven Schveighoffer wrote: ```d // option 1 output[p++] = (ulong(w - e) + 3) % 40; // option 2 output[p++] = cast(char)(((w - e) + 3) % 40); ``` Remember also, `char` is C's only way to say "byte". So this may just be data, and not unicode