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
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
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
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
Very many thanks for the explanation, now I see what is happening.
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[
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.
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.
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
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
10 matches
Mail list logo