Re: Program crash: GC destroys an object unexpectedly

2021-09-14 Thread Ali Çehreli via Digitalmars-d-learn
On 9/14/21 9:56 AM, eugene wrote: > On Tuesday, 14 September 2021 at 16:43:50 UTC, jfondren wrote: >> The misaligned pointer and the >> reference-containing struct that vanishes on the return of your >> corresponding function are both problems for this. > > where did you find 'misaligned

Re: Program crash: GC destroys an object unexpectedly

2021-09-14 Thread eugene via Digitalmars-d-learn
On Tuesday, 14 September 2021 at 18:33:33 UTC, Steven Schveighoffer wrote: People are trying to help you here. Then, answer the questions. Why those sg0 and sg1 are 'collected' by this so f... antstic GC?

Re: Program crash: GC destroys an object unexpectedly

2021-09-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/14/21 2:05 PM, eugene wrote: On Tuesday, 14 September 2021 at 17:02:32 UTC, jfondren wrote: It doesn't seem like communication between us is possible and you are wrong, as usual ,) in the "a five-pound phone won't sell" way. I am not a 'selling boy' My suggestion remains: try

Re: Program crash: GC destroys an object unexpectedly

2021-09-14 Thread eugene via Digitalmars-d-learn
On Tuesday, 14 September 2021 at 17:02:32 UTC, jfondren wrote: It doesn't seem like communication between us is possible and you are wrong, as usual ,) in the "a five-pound phone won't sell" way. I am not a 'selling boy' My suggestion remains: try troubleshooting by making your program

Re: Which operators cannot be overloaded and why not?

2021-09-14 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Sep 13, 2021 at 06:19:20PM +, NonNull via Digitalmars-d-learn wrote: > On Monday, 13 September 2021 at 16:12:34 UTC, H. S. Teoh wrote: > > On Mon, Sep 13, 2021 at 02:12:36PM +, NonNull via > > Digitalmars-d-learn wrote: > > > Which operators cannot be overloaded and why not? > > >

Re: Program crash: GC destroys an object unexpectedly

2021-09-14 Thread jfondren via Digitalmars-d-learn
On Tuesday, 14 September 2021 at 16:56:52 UTC, eugene wrote: On Tuesday, 14 September 2021 at 16:43:50 UTC, jfondren wrote: GC needs to be able to stop your program nice fantasies... and find all of the live objects in it. The misaligned pointer and the reference-containing struct that

Re: Program crash: GC destroys an object unexpectedly

2021-09-14 Thread eugene via Digitalmars-d-learn
On Tuesday, 14 September 2021 at 16:43:50 UTC, jfondren wrote: GC needs to be able to stop your program nice fantasies... and find all of the live objects in it. The misaligned pointer and the reference-containing struct that vanishes on the return of your corresponding function are both

Re: Program crash: GC destroys an object unexpectedly

2021-09-14 Thread jfondren via Digitalmars-d-learn
On Tuesday, 14 September 2021 at 16:15:20 UTC, eugene wrote: On Tuesday, 14 September 2021 at 16:07:00 UTC, jfondren wrote: No. And when was the first one? here: On Monday, 13 September 2021 at 18:45:22 UTC, jfondren wrote: auto p = cast(EpollEvent*) pureMalloc(EpollEvent.sizeof); What?

Re: Program crash: GC destroys an object unexpectedly

2021-09-14 Thread eugene via Digitalmars-d-learn
On Tuesday, 14 September 2021 at 16:07:00 UTC, jfondren wrote: No. And when was the first one? here: On Monday, 13 September 2021 at 18:45:22 UTC, jfondren wrote: auto p = cast(EpollEvent*) pureMalloc(EpollEvent.sizeof); What? Allocate struct epoll_event on the heap? It is a feeble joke

Re: Program crash: GC destroys an object unexpectedly

2021-09-14 Thread jfondren via Digitalmars-d-learn
On Tuesday, 14 September 2021 at 15:37:27 UTC, eugene wrote: 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? No. And when was the first one? ```d align

Re: Program crash: GC destroys an object unexpectedly

2021-09-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/14/21 10:56 AM, jfondren wrote: On Tuesday, 14 September 2021 at 14:40:55 UTC, eugene wrote: 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

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;

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

Re: Program crash: GC destroys an object unexpectedly

2021-09-14 Thread jfondren via Digitalmars-d-learn
On Tuesday, 14 September 2021 at 14:40:55 UTC, eugene wrote: 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'. A 5-pound phone isn't

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(, code: u32) { let ptr: *const u32 = let n = unsafe {

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

Re: Program crash: GC destroys an object unexpectedly

2021-09-14 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 14 September 2021 at 12:42:51 UTC, eugene wrote: I understand your idea, but even if this will help, the question remains - why that particular object is so special for GC. I had a problem just like this before because I was sending objects through the pipe. And while they were in

Re: Program crash: GC destroys an object unexpectedly

2021-09-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/14/21 8:42 AM, eugene wrote: On Tuesday, 14 September 2021 at 12:09:03 UTC, Steven Schveighoffer wrote: I still recommend pinning the object when adding the epoll event and seeing if that helps. I understand your idea, but even if this will help, the question remains - why that

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

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 ..

Re: Recommendations on parsing XML via an InputRange

2021-09-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/13/21 10:43 PM, Chris Piker wrote: Hi D I just finished a ~1K line project using `dxml` as the XML reader for my data streams.  It works well in my test examples using memory mapped files, but like an impulse shopper I didn't notice that dxml requires `ForwardRange` objects.  That's

Re: Program crash: GC destroys an object unexpectedly

2021-09-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/14/21 7:31 AM, eugene wrote: 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:

Re: Program crash: GC destroys an object unexpectedly

2021-09-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On 9/14/21 1:49 AM, Tejas wrote: On Monday, 13 September 2021 at 18:42:47 UTC, Steven Schveighoffer wrote: On 9/13/21 1:54 PM, eugene wrote: [...] The GC only scans things that it knows about. Inside your EventQueue you have this code: [...] Umm is it okay that he declared variables

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

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

Re: Development of the foundation of a programming language

2021-09-14 Thread max haughton via Digitalmars-d-learn
On Tuesday, 14 September 2021 at 05:06:01 UTC, Elronnd wrote: On Tuesday, 14 September 2021 at 03:24:45 UTC, max haughton wrote: On Tuesday, 14 September 2021 at 03:19:46 UTC, Elronnd wrote: On Monday, 13 September 2021 at 11:40:10 UTC, max haughton wrote: The dragon book barely mentions SSA