Re: AA vs __gshared

2023-08-15 Thread IchorDev via Digitalmars-d-learn
On Tuesday, 15 August 2023 at 17:36:13 UTC, Steven Schveighoffer wrote: On 8/12/23 5:55 AM, IchorDev wrote: On Thursday, 10 August 2023 at 15:20:28 UTC, Steven Schveighoffer wrote: That shouldn't matter. Well, it does here. The AA is mutated during the loop, so perhaps this is an

Re: AA vs __gshared

2023-08-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/12/23 5:55 AM, IchorDev wrote: On Thursday, 10 August 2023 at 15:20:28 UTC, Steven Schveighoffer wrote: That shouldn't matter. Well, it does here. The AA is mutated during the loop, so perhaps this is an optimisation quirk where it works with `for` but segfaults in `foreach`? I've

Re: AA vs __gshared

2023-07-28 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/28/23 11:15 AM, IchorDev wrote: On Friday, 28 July 2023 at 11:15:31 UTC, Steven Schveighoffer wrote: All `__gshared` does is give you storage that is accessible from all threads, "All __gshared does is give you [a live bomb, ready to go off at any moment]" !! It seems like it's not

Re: AA vs __gshared

2023-07-28 Thread IchorDev via Digitalmars-d-learn
On Friday, 28 July 2023 at 11:15:31 UTC, Steven Schveighoffer wrote: All `__gshared` does is give you storage that is accessible from all threads, "All __gshared does is give you [a live bomb, ready to go off at any moment]" !! On Friday, 28 July 2023 at 14:10:16 UTC, Kagamin wrote: Your

Re: AA vs __gshared

2023-07-28 Thread Kagamin via Digitalmars-d-learn
Your error is using allocating the object with malloc. Since gc doesn't see your AA, the AA is freed and you get UAF.

Re: AA vs __gshared

2023-07-28 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/28/23 4:39 AM, IchorDev wrote: Issue is, this code I posted actually runs just fine, unlike the real code. My actual code does this HIGHLY SUSPICIOUS thing when printing their length each time before using them: ``` 766 766 765 766 767 768 768 768 768 768 768 768 768 768 768 768 768 768

Re: AA vs __gshared

2023-07-28 Thread IchorDev via Digitalmars-d-learn
On Thursday, 27 July 2023 at 21:31:02 UTC, Jonathan M Davis wrote: What should normally be happening is that you use shared, and then when you've protected the object so that you know that it can only be accessed on the current thread by the section of code that you're in (e.g. by locking a

Re: AA vs __gshared

2023-07-28 Thread IchorDev via Digitalmars-d-learn
On Friday, 28 July 2023 at 04:13:13 UTC, Kagamin wrote: The difference between them is purely formal if you're not on an old gdc, where shared was synchronized like C# volatile. I'm not sure that's correct. Also I always use the latest compiler versions where possible. start many threads

Re: AA vs __gshared

2023-07-27 Thread Kagamin via Digitalmars-d-learn
On Friday, 28 July 2023 at 03:54:53 UTC, IchorDev wrote: I was told that using `__gshared` is quite a bit faster at runtime than using `shared`, but I also don't really know anything concrete about `shared` because the spec is so incredibly vague about it. The difference between them is

Re: AA vs __gshared

2023-07-27 Thread IchorDev via Digitalmars-d-learn
On Thursday, 27 July 2023 at 21:31:02 UTC, Jonathan M Davis wrote: Now, as to what's happening in your code that's causing segfaults, the most likely culprit would be that you're accessing the AA without actually having done anything to prevent other threads from accessing it at the same

Re: AA vs __gshared

2023-07-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, July 27, 2023 9:57:51 AM MDT IchorDev via Digitalmars-d-learn wrote: > I've been getting a lot of segfaults from using associative > arrays recently. The faults happen seemingly at random, and from > pretty mundane stuff like `if(auto x = y in z)` that run very > often: > ``` >

Re: AA vs __gshared

2023-07-27 Thread Dennis via Digitalmars-d-learn
On Thursday, 27 July 2023 at 15:57:51 UTC, IchorDev wrote: The faults happen seemingly at random, and from pretty mundane stuff like `if(auto x = y in z)` that run very often: Are you accessing the AA from multiple threads?

AA vs __gshared

2023-07-27 Thread IchorDev via Digitalmars-d-learn
I've been getting a lot of segfaults from using associative arrays recently. The faults happen seemingly at random, and from pretty mundane stuff like `if(auto x = y in z)` that run very often: ``` Segmentation fault. #0 0x55670f4a in rt.aaA.Impl.findSlotLookup(ulong, scope