You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The fix for this is already planned, as mentioned in #259, but I am documenting it here as an open issue for posterity.
Describe the bug
An integrand function of, say, an AreaIntegral, is not allowed to modify state (see #259). This results in a Segmentation Fault if run in multithreaded setting.
To Reproduce
Run the following code using morpho6 -w4
import constants
import meshtools
var mb = MeshBuilder()
mb.addvertex([0,0])
mb.addvertex([1,0])
mb.addvertex([0,1])
mb.addface([0,1,2])
var m = mb.build()
var f = Field(m, fn (x,y) Matrix([x,2*y]))
var r
fn integrand(x, n) {
var g = grad(n)
r = []
for (u in g) r.append(u.clone())
return 0
}
var total = AreaIntegral(integrand, f).total(m)
print r[0]
Note that r is defined in the global scope and being modified inside the integrand.
Expected behavior
Some clear error pointing out that the variable r cannot be modified inside the integrand.
Currently, this generates a segmentation fault.
The text was updated successfully, but these errors were encountered:
Globals run inside parallel code should be protected within the morpho runtime by locks; this isn't yet done by the compiler & VM and is an important target of future work. In the meantime the workaround is simply to ensure functions passed to the Integral functions are pure, i.e. don't have side effects.
The fix for this is already planned, as mentioned in #259, but I am documenting it here as an open issue for posterity.
Describe the bug
An integrand function of, say, an AreaIntegral, is not allowed to modify state (see #259). This results in a Segmentation Fault if run in multithreaded setting.
To Reproduce
Run the following code using
morpho6 -w4
Note that
r
is defined in the global scope and being modified inside the integrand.Expected behavior
Some clear error pointing out that the variable
r
cannot be modified inside the integrand.Currently, this generates a segmentation fault.
The text was updated successfully, but these errors were encountered: