Re: Program crash: GC destroys an object unexpectedly

2021-09-14 Thread eugene via Digitalmars-d-learn
On Tuesday, 14 September 2021 at 14:56:00 UTC, jfondren wrote: You could fix this by having a 128-bit struct and passing C an index into it It is another "not so funny joke", isn't it? Look ```c typedef union epoll_data { void *ptr; int fd; uint32_t u32; uin

Re: Program crash: GC destroys an object unexpectedly

2021-09-14 Thread eugene via Digitalmars-d-learn
On Tuesday, 14 September 2021 at 12:09:03 UTC, Steven Schveighoffer wrote: This project is too big and complex for me to diagnose by just reading, it would take some effort take a look at https://www.routledge.com/Modeling-Software-with-Finite-State-Machines-A-Practical-Approach/Wagner-Schmuki

Re: Program crash: GC destroys an object unexpectedly

2021-09-14 Thread eugene via Digitalmars-d-learn
On Tuesday, 14 September 2021 at 12:09:03 UTC, Steven Schveighoffer wrote: This project is too big and complex Really, "too big and complex"? It's as simple as a tabouret :) It's just a toy/hobby 'project'.

Re: Program crash: GC destroys an object unexpectedly

2021-09-14 Thread eugene via Digitalmars-d-learn
On Tuesday, 14 September 2021 at 12:52:44 UTC, Steven Schveighoffer wrote: But I agree that a superficial reading of your code seems like it ought to not be collected, and that problem is also worth figuring out. I have high confidence that it's probably not a design flaw in the GC, but rather

Re: Program crash: GC destroys an object unexpectedly

2021-09-14 Thread eugene via Digitalmars-d-learn
On Tuesday, 14 September 2021 at 12:53:27 UTC, Adam D Ruppe wrote: I had a problem just like this before because I was sending objects through the pipe. And while they were in the pipe - ```rust pub fn msg(&self, code: u32) { let ptr: *const u32 = &code; let n = unsafe { wri

Re: Program crash: GC destroys an object unexpectedly

2021-09-14 Thread eugene via Digitalmars-d-learn
On Tuesday, 14 September 2021 at 12:53:27 UTC, Adam D Ruppe wrote: I had a problem just like this before because I was sending objects through the pipe. This reminds my (not very successfull) attempts to implement the idea in Rust: ```rust pub struct Edsm { name: String, pub states:

Re: Program crash: GC destroys an object unexpectedly

2021-09-14 Thread eugene via Digitalmars-d-learn
On Tuesday, 14 September 2021 at 12:13:15 UTC, Steven Schveighoffer wrote: On 9/14/21 7:31 AM, eugene wrote: On Monday, 13 September 2021 at 17:18:30 UTC, eugene wrote:     EventSource s = events[k].es;     ulong ecode = s.eventCode(events[k].event_mask); // < SIGSEGV Not

Re: Program crash: GC destroys an object unexpectedly

2021-09-14 Thread eugene via Digitalmars-d-learn
On Tuesday, 14 September 2021 at 12:09:03 UTC, Steven Schveighoffer wrote: Though as I have learned helping C converts before, most of the time things like this have to do with forgetting to store a GC reference somewhere. Yeah, in my first version I had ```d foreach (k; 0 .. nConnections

Re: Program crash: GC destroys an object unexpectedly

2021-09-14 Thread eugene via Digitalmars-d-learn
On Monday, 13 September 2021 at 17:18:30 UTC, eugene wrote: Then after pressing ^C (SIGINT) the program gets SIGSEGV, since references to sg0 and sg1 are no longer valid (they are "sitting" in epoll_event structure). ... forget to mention, crashes here: ```d bool wait() { const i

Re: Program crash: GC destroys an object unexpectedly

2021-09-14 Thread eugene via Digitalmars-d-learn
On Monday, 13 September 2021 at 18:45:22 UTC, jfondren wrote: ```d auto p = cast(EpollEvent*) pureMalloc(EpollEvent.sizeof); ``` What? Allocate struct epoll_event on the heap? It is a feeble joke ;) ```c static int ecap__add(int fd, void *dptr) { struct epoll_event waitfor =

Re: Program crash: GC destroys an object unexpectedly

2021-09-14 Thread eugene via Digitalmars-d-learn
On Tuesday, 14 September 2021 at 05:49:58 UTC, Tejas wrote: Umm is it okay that he declared variables `init` and `idle` of type `Stage` inside the constructor? States of a machine are in associative array. All other machines create their states in constructor, local variables are for using addR

Re: Program crash: GC destroys an object unexpectedly

2021-09-13 Thread eugene via Digitalmars-d-learn
On Monday, 13 September 2021 at 18:45:22 UTC, jfondren wrote: Instead of using a temporary EpollEvent array in EventQueue.wait, you could make the array an instance variable and have registerEventSource populate it directly Actually, initial version of all that was using array, allocated in co

Re: Program crash: GC destroys an object unexpectedly

2021-09-13 Thread eugene via Digitalmars-d-learn
On Monday, 13 September 2021 at 18:42:47 UTC, Steven Schveighoffer wrote: And you are registering your signals using the `+=` operator. That was a sort of exercise with operator overloading. Now, with your stopper code that you showed, it looks like you are storing the reference to stopper ri

Re: Program crash: GC destroys an object unexpectedly

2021-09-13 Thread eugene via Digitalmars-d-learn
On Monday, 13 September 2021 at 17:56:34 UTC, user1234 wrote: thx, so the problem is not what I suspected to be (mixed gc-managed and manually managed memory). sorrry... I am actually C coder and do not have much experience with GC languages, so I did not even attempt to try use D without GC ye

Re: Program crash: GC destroys an object unexpectedly

2021-09-13 Thread eugene via Digitalmars-d-learn
On Monday, 13 September 2021 at 17:18:30 UTC, eugene wrote: And the most strange thing is this It is echo-server/echo-client pair. And it is echo-client that crashes upon SIGINT. echo-server contains very similar code class Listener : StageMachine { enum ulong M0_WORK = 0; enum ulong

Re: Program crash: GC destroys an object unexpectedly

2021-09-13 Thread eugene via Digitalmars-d-learn
On Monday, 13 September 2021 at 17:40:41 UTC, user1234 wrote: The problems seems to lies in `newSignal()` which "would" not allocate using the GC. final Signal newSignal(int signum) { Signal sg = new Signal(signum); sg.owner = this; sg.number = sg_number++; s

Program crash: GC destroys an object unexpectedly

2021-09-13 Thread eugene via Digitalmars-d-learn
Code snippets ```d class Stopper : StageMachine { enum ulong M0_IDLE = 0; Signal sg0, sg1; this() { super("STOPPER"); Stage init, idle; init = addStage("INIT", &stopperInitEnter); idle = addStage("IDLE", &stopperIdleEnter); init.addReflex("M

Re: GDC - program runs in one thread, DMD - in 4 threads, why?

2021-09-10 Thread eugene via Digitalmars-d-learn
On Friday, 10 September 2021 at 12:59:08 UTC, bauss wrote: It's just used to speed-up the GC. Yeah, I got the point, but to be absolutely honest, I (>20 years of C coding) do not like GC as such. I believe manual free() is not that 'hard'. And one must still release other resources. (in C I wri

Re: GDC - program runs in one thread, DMD - in 4 threads, why?

2021-09-10 Thread eugene via Digitalmars-d-learn
On Friday, 10 September 2021 at 12:10:58 UTC, Adam D Ruppe wrote: btw why do the threads cause you trouble? Well... probably it is subjective thing - just do not 'like' when a program is doing something that is not explicitly in it's source (I am C coder, you guessed). More specifically - I ha

Re: GDC - program runs in one thread, DMD - in 4 threads, why?

2021-09-10 Thread eugene via Digitalmars-d-learn
On Friday, 10 September 2021 at 11:53:04 UTC, eugene wrote: On Friday, 10 September 2021 at 11:32:02 UTC, Adam D Ruppe wrote: You either pass as an argument *to your application* --DRT-gcopt=parallel:0 oops... :) ps xH | grep [e]cho 5727 pts/14 S+ 0:13 ./echo-server --DRT-gcopt=parall

Re: GDC - program runs in one thread, DMD - in 4 threads, why?

2021-09-10 Thread eugene via Digitalmars-d-learn
On Friday, 10 September 2021 at 11:32:02 UTC, Adam D Ruppe wrote: You either pass as an argument *to your application* --DRT-gcopt=parallel:0 oops... :)

Re: GDC - program runs in one thread, DMD - in 4 threads, why?

2021-09-10 Thread eugene via Digitalmars-d-learn
On Friday, 10 September 2021 at 11:09:10 UTC, bauss wrote: --DRT-gcopt=parallel:2 on the command line. A value of 0 disables parallel marking completely. but it does not: make -f Makefile-dmd dmd --DRT-gcopt=parallel:0 engine/*.d common-sm/*.d server-sm/*.d pool.d echo_server.d -ofecho-server

Re: GDC - program runs in one thread, DMD - in 4 threads, why?

2021-09-10 Thread eugene via Digitalmars-d-learn
On Friday, 10 September 2021 at 11:09:10 UTC, bauss wrote: Here's the specific change: https://dlang.org/changelog/2.087.0.html#gc_parallel thanx a lot!

Re: GDC - program runs in one thread, DMD - in 4 threads, why?

2021-09-10 Thread eugene via Digitalmars-d-learn
On Friday, 10 September 2021 at 10:20:52 UTC, drug wrote: It is off-topic a bit I am newbie - have been learning D for about 2 months or so. I understand that my question is not about the language itself, just picked forum for new users. but I think none can compare gdc 4.9.2 to same pictur

GDC - program runs in one thread, DMD - in 4 threads, why?

2021-09-10 Thread eugene via Digitalmars-d-learn
Here is test program (which is using DList aggressively) ```d import std.stdio : writeln; import core.sys.posix.unistd : sleep; //import std.container.dlist; // dmd (v2.097.2) import std.container: DList; // gdc (4.9.2) void main() { auto list = DList!(int)(); int k; while (true) {

Re: the best language I have ever met(?)

2016-12-05 Thread eugene via Digitalmars-d-learn
On Monday, 5 December 2016 at 16:07:41 UTC, Igor Shirkalin wrote: I didnt count, but its about ten thousend a year, i.e. nothing. if you earned nothing using D language why do you recommend it?))) People usually earn money using programming langs.

Re: the best language I have ever met(?)

2016-12-03 Thread eugene via Digitalmars-d-learn
On Friday, 18 November 2016 at 17:54:52 UTC, Igor Shirkalin wrote: That was preface. Now I have server written in D for C++ pretty ancient client. Most things are three times shorter in size and clear (@clear? suffix). All programming paradigms were used. I have the same text in russian, but wh

Re: D to C++

2016-08-30 Thread eugene via Digitalmars-d-learn
On Tuesday, 30 August 2016 at 13:33:44 UTC, Nick wrote: Is it possible to compile from D to C++? Explanation: I do some competition programming and would like to write it in D instead of C++ :) maybe will help https://wiki.dlang.org/Calypso

<    1   2