Any segfault is always a bug. Would you mind filing an issue with a self-contained example that can produce the segfault (plus Julia version info)?
On Fri, Apr 24, 2015 at 5:26 AM, Archibald Pontier < [email protected]> wrote: > Hi again, > > I found a way to prevent my code from crashing and it's really unexpected. > I modified some global variable which only affects functions that are > called by my emloop function and somehow it works. I have no idea why did > this affect my code though, and especially what it made it segfault instead > of just return an error. So now the serial version works, I'm still > struggling with pmap with plenty of "result shape unspecified" errors but > that's ok. > > All the best, > Archibald > > > On Friday, 24 April 2015 10:36:15 UTC+2, Archibald Pontier wrote: >> >> Hi everyone, >> >> Julia is (sometimes) segfaulting when running this function : >> >> function emloop(img, Sigma, mu, t, model, imgc, bg, FullTs) >> EMiter = 1; >> Check = typemax(Float64); >> GModels, Genes, >> (x, y) = size(img); >> D = zeros(x, y); E = zeros(x, y); B = zeros(x, y); >> >> # And we start the EM loop >> while EMiter <= maxEM && Check > ϵ >> # Calculate the betas & find the optimal transformation for the >> current iteration >> (D, E, B) = fastBetas(model, [], mu, Sigma, img); >> nt = findTransform(model, B, Gray((bg.r + bg.g + bg.b)/3), FullTs); >> >> # Now calculate the optimal parameters for the appearance model >> OldMu = mu; # For termination purposes >> (mu, Sigma) = calcTheta(img, D, E, B); >> >> # Apply the transformation found to the image >> img = RigidTransform(img, nt, bg, true, true); >> >> # Deal with the transformation >> Oldt = t; >> t += nt; >> t.tx %= x; >> t.ty %= y; >> >> # Termination criteria >> NormOldTT = sqrt((Oldt.tx - t.tx)^2 + (Oldt.ty - t.ty)^2 + (Oldt.θ - >> t.θ)^2); >> CheckMu = norm(OldMu.D - mu.D) + norm(OldMu.E - mu.E) + norm(OldMu.B >> - mu.B) >> Check = CheckMu + NormOldTT # Giving lots of weight to the >> transformation >> >> EMiter += 1; >> end >> >> return emdata(D, E, B, img, θ(Sigma, mu), t); >> end >> >> Some context: img is and Image{RGB{Float64}}, Sigma and mu are custom >> types : >> type Σ >> D::Array{Float64, 2} >> E::Array{Float64, 2} >> B::Array{Float64, 2} >> end >> >> type μ >> D::Array{Float64, 1} >> E::Array{Float64, 1} >> B::Array{Float64, 1} >> end >> >> t is another custom type to represent a rigid body transformation >> (translation_x, translation_y, rotation_angle), bg is, for example, >> RGB(0.0, 0.0, 0.0) (black), and FullTs is an array of transformations, >> namely all the transformations we consider. >> >> It's weird for multiple reasons: first of all, this code was running fine >> when not in a separate function returning a custom type (the custom type in >> the return is to ease the access since I want to call this function for an >> array of images with pmap and output all that which is not practical). >> Furthermore, sometimes it crashes with a segfault, sometimes with an >> undefined reference on this line, not always after the same EM iteration: >> CheckMu = norm(OldMu.D - mu.D) + norm(OldMu.E - mu.E) + norm(OldMu.B - >> mu.B) >> >> Thanks in advance for the help, >> Archibald >> >
