does arc deep copy spawn parameters?

2023-05-14 Thread pixel
I came came across an unexpected problem with spawn recently and thought I would mention it here in the hope that someone can clarify the situation. The program below behaves erratically when compiled with --threads:on --gc:arc. Sometimes it runs ok, sometimes it reports 'SIGSEGV: Illegal storag

does arc deep copy spawn parameters?

2023-05-15 Thread pixel
Hi Araq The dev version of nim-1.9.3 (2023-05-08-devel-71f2e1a502ad231e3356217398e2d7fcd6137967) does not seem to offer me the option of --mm:atomicArc (I am using linux_x64) but with --mm:arc it runs the example code without any errors. I guess nim-1.6.12 that gives the problem has some subtl

does arc deep copy spawn parameters?

2023-06-12 Thread pixel
FWIW this code crashes about 50% of the time with nim v1.6 + arc std/threadpool type Ans = ref object x: float Tmp = ref object a,b,c,d,e,f,g,h,i,j,k : seq[float] proc calc( x:Tmp ): Ans = result = new(Ans) let n = 4

behaviour of procedures marked with 'lent'

2024-02-14 Thread pixel
Th documentation says that procedures marked with 'lent' return a hidden pointer. But the code below prints two different values which shows that a copy of the data is being returned instead of a pointer (Nim version 2.0.0 used) . I assume that I am misunderstanding how 'lent' works, can anyone

behaviour of procedures marked with 'lent'

2024-02-14 Thread pixel
Very many thanks for the explanation, now I see what is happening.

gc/malebolgia bug?

2024-03-12 Thread pixel
I was developing some code using Malebolgia and found an unexpected problem. This example code crashes crashes about 80% of the time when I run it: type Svec* = ref array[19,float] proc subfn( svec:Svec ) = discard 0 proc fn( svec:ptr Svec ) = let svec = svec[

gc/malebolgia bug?

2024-03-12 Thread pixel
Many thanks for explanation, and using atomicArc solves the problem. Somehow I never quite realised that Nim reference counting was playing a role here and would be affected by data races.

gc/malebolgia bug?

2024-03-16 Thread pixel
Thank you for the useful suggestion. The cursor pragma is turning out to be very useful in my code - maybe it could be upgraded into some kind of keyword in a future Nim version.

what is the type of exception raised by malebolgia?

2024-08-16 Thread pixel
The malebolgia documentation says that if a spawned task raises an exception then it will be rethrown after awaitAll. But the example code given below does not seem to do this: it prints 'other error' and only when I i remove 'm.spawn' does it print 'my error'. Very likely I am misunderstanding

what is the type of exception raised by malebolgia?

2024-08-16 Thread pixel
Many thanks for the prompt reply and the info. But why is malebolgia doing this (it seems a strange thing to do), and how can I get malebolgia to return the desired error type? (The ValueError that malebolgia returns in this example does contain "MyError" in its message string so if all else fa