Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-08 Thread Basile B. via Digitalmars-d-learn
On Friday, 8 September 2023 at 19:14:47 UTC, H. S. Teoh wrote: [...] My guess is that you have a double-free somewhere, or there's a buffer overrun. Or maybe some bad interaction with the GC, e.g. if you tried to free a pointer from the GC heap. That cant be a GC problem as rempas project is

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-08 Thread Basile B. via Digitalmars-d-learn
On Friday, 8 September 2023 at 18:59:21 UTC, rempas wrote: On Friday, 8 September 2023 at 16:02:36 UTC, Basile B. wrote: Could this be a problem of copy construction ? I don't think so. My idea was that if you dont have defined a copy constructor and if an instance is assigned to another,

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-08 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Sep 08, 2023 at 06:59:21PM +, rempas via Digitalmars-d-learn wrote: > On Friday, 8 September 2023 at 16:02:36 UTC, Basile B. wrote: > > > > Could this be a problem of copy construction ? > > I don't think so. The assertion seems to be violated when `malloc` is used. > And when I

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-08 Thread rempas via Digitalmars-d-learn
On Friday, 8 September 2023 at 16:02:36 UTC, Basile B. wrote: Could this be a problem of copy construction ? I don't think so. The assertion seems to be violated when `malloc` is used. And when I assert the result in the `_ptr` field. Really weird...

Re: I don't understand betterC

2023-09-08 Thread rempas via Digitalmars-d-learn
On Monday, 4 September 2023 at 07:39:21 UTC, confused wrote: So then I guess I'd still like to know how I'm expected to store and access an array of characters without the C runtime as I tried in my original post. You are going to allocate memory using the system call of your operation

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-08 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 08/09/2023 7:59 PM, rempas wrote: |Fatal glibc error: malloc.c:2594 (sysmalloc): assertion failed: (old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)| I would strongly suggest

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-08 Thread Basile B. via Digitalmars-d-learn
On Friday, 8 September 2023 at 07:59:37 UTC, rempas wrote: I do have the following struct: [...] Is there any possible that there is a compiler bug? I do use ldc2 and `betterC`! Could this be a problem of copy construction ?

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-08 Thread rempas via Digitalmars-d-learn
On Friday, 8 September 2023 at 07:59:37 UTC, rempas wrote: [I do have ... I do use ldc2 and `betterC`!] For anyone who is still following, first of all thanks! Second, I have bad news and good news! The bad news is that I tested in an Linux Mint system (mine is an Arch Linux) and the it

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-08 Thread rempas via Digitalmars-d-learn
On Friday, 8 September 2023 at 14:40:13 UTC, Richard (Rikki) Andrew Cattermole wrote: No, for this you need ModuleInfo. The order is sequential on what it sees first. Personally I test using full D rather than -betterC. For dub: ```json "configurations": [ { "name":

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-08 Thread rempas via Digitalmars-d-learn
On Friday, 8 September 2023 at 14:50:17 UTC, Kagamin wrote: Did you run this example program above? Does it crash? I didn't as I suppose that it would had no problems as it works for you. Either that, or it will be indeed a problem with my Glibc. I did run it now after your reply and it

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-08 Thread Kagamin via Digitalmars-d-learn
On Friday, 8 September 2023 at 13:32:00 UTC, rempas wrote: On Friday, 8 September 2023 at 13:05:47 UTC, evilrat wrote: ```d import core.stdc.stdlib; import core.stdc.stdio; alias u64 = ulong; alias i64 = long; struct Vec(T) { private: T* _ptr = null; // The pointer to the data u64 _cap =

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-08 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 09/09/2023 2:20 AM, rempas wrote: Do they have automatic symbol order resolution? Which is, testing symbols that other symbol depend on first? Or is it random? No, for this you need ModuleInfo. The order is sequential on what it sees first. Personally I test using full D rather than

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-08 Thread rempas via Digitalmars-d-learn
On Friday, 8 September 2023 at 13:34:42 UTC, Richard (Rikki) Andrew Cattermole wrote: In case you didn't know, all you need to get unittests working in -betterC is: ```d foreach (module_; allModules) { foreach (unitTest;

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-08 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
In case you didn't know, all you need to get unittests working in -betterC is: ```d foreach (module_; allModules) { foreach (unitTest; __traits(getUnitTests, module_)) { unitTest();

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-08 Thread rempas via Digitalmars-d-learn
On Friday, 8 September 2023 at 13:05:47 UTC, evilrat wrote: You run with -unittest compiler flag? Well, that does nothing for me with betterc (without it is ok). I did stupid and unsafe things like malloc(0) and writing out of bounds but still no crash, it works fine. I guess it depends

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-08 Thread bachmeier via Digitalmars-d-learn
On Friday, 8 September 2023 at 07:59:37 UTC, rempas wrote: I do have the following struct: ```d struct Vec(T) { private: T* _ptr = null; // The pointer to the data u64 _cap = 0; // Total amount of elements (not bytes) we can store public: /* Create a vector by just allocating memory

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-08 Thread evilrat via Digitalmars-d-learn
On Friday, 8 September 2023 at 11:50:52 UTC, rempas wrote: That's interesting, I wasn't able to find something else! The bug happens when I run the testing suit and well... the tests before pass so I cannot find anything that goes wrong except for the fact that I do not free the memory that

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-08 Thread rempas via Digitalmars-d-learn
On Friday, 8 September 2023 at 09:25:59 UTC, Hipreme wrote: Hello, not completely unrelated to your problem, I have also done something like that, and when you're in D, don't use simply a pointer and length like that, use the `slice` operator. See references:

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-08 Thread rempas via Digitalmars-d-learn
On Friday, 8 September 2023 at 09:07:12 UTC, evilrat wrote: Hard to tell from that code but it is quite unlikely there is a compiler bug in such simple use case. I assume you already tried debugging your program, right? Yep! I have spent days and it's these kinds of bugs that burn me off

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-08 Thread Hipreme via Digitalmars-d-learn
On Friday, 8 September 2023 at 07:59:37 UTC, rempas wrote: I do have the following struct: ```d struct Vec(T) { private: T* _ptr = null; // The pointer to the data u64 _cap = 0; // Total amount of elements (not bytes) we can store public: /* Create a vector by just allocating memory

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-08 Thread evilrat via Digitalmars-d-learn
On Friday, 8 September 2023 at 07:59:37 UTC, rempas wrote: I do have the following struct: ```d struct Vec(T) { private: T* _ptr = null; // The pointer to the data u64 _cap = 0; // Total amount of elements (not bytes) we can store public: /* Create a vector by just allocating memory

malloc error when trying to assign the returned pointer to a struct field

2023-09-08 Thread rempas via Digitalmars-d-learn
I do have the following struct: ```d struct Vec(T) { private: T* _ptr = null; // The pointer to the data u64 _cap = 0; // Total amount of elements (not bytes) we can store public: /* Create a vector by just allocating memory for it. The null terminator is not set for strings as,

Re: D web browser?

2023-09-08 Thread Sergey via Digitalmars-d-learn
On Friday, 8 September 2023 at 06:42:13 UTC, Joe wrote: Is there a D library that lets one access the web through a browser like interface? I need to access some URLS as if I was browsing them(it needs to run scripts in the page). E.g., C# has WebBrowser that lets one programmatically control

Re: D web browser?

2023-09-08 Thread Ferhat Kurtulmuş via Digitalmars-d-learn
On Friday, 8 September 2023 at 06:42:13 UTC, Joe wrote: Is there a D library that lets one access the web through a browser like interface? I need to access some URLS as if I was browsing them(it needs to run scripts in the page). E.g., C# has WebBrowser that lets one programmatically control