giordano / PolynomialRoots.jl

Fast complex polynomial root finder, with support for arbitrary precision calculations
Other
54 stars 15 forks source link

Segmentation fault #4

Closed Goysa2 closed 7 years ago

Goysa2 commented 7 years ago

Hi,

I am using this package to compute the roots of a 3rd degree polynomial in a large function.

Basically if I did dR=roots([dφt,2*A,3*B,(1/α)]) (where all the parameters are all previously defined) dans tried to access dR[1] I had a seg fault. But I was able to show dR: dR = Complex{Float64}[-4.56475-7.96937im,-4.56475+7.96937im,9.12951+0.0im]

But if I do ```dR_1=roots([dφt,2A,3B,(1/α)]); dR = copy(dR_1)



I don't have the seg fault and I can manipulate dR fine... Is that normal? 

I am running on Julia 0.5.2 and ubuntu 16.04
Thanks
giordano commented 7 years ago

I'd say that it isn't normal, but I need a reproducible example in order to investigate. Could you please provide a complete recipe to reproduce the issue?

Goysa2 commented 7 years ago

The way I got to this error is long. Should I share the procedure here?

giordano commented 7 years ago

Well, I can't dig into an issue if I can't reproduce it :-) The shorter the example, the better, the important is that you can sistematically reproduce the error with the recipe you provide

Goysa2 commented 7 years ago

I'll try to see if I can a "short way" to create that error, because right now you'd get all kind of unrelated error because I'm using packages that are still in development on my local git branch !

giordano commented 7 years ago

Can you provide the value of those variables shown in the first post? Can you reproduce the issue if you assign them those values and then call roots as you did in that message?

giordano commented 7 years ago
julia> using PolynomialRoots

julia> dφt, A, B, α = 1, 2, 3, 4
(1, 2, 3, 4)

julia> dR=roots([dφt,2*A,3*B,(1/α)])
3-element Array{Complex{Float64},1}:
  -35.5531-2.77556e-17im
 -0.223433-0.250171im   
 -0.223433+0.250171im   

julia> dR[1]
-35.55313384165278 - 2.7755575615628914e-17im

julia> dR[2]
-0.2234330791736101 - 0.25017058601497394im

julia> dR[3]
-0.22343307917361008 + 0.25017058601497394im

As you can see, I can't reproduce your segmentation fault (which is a pretty serious error) using dummy values for those variables. Unless you can provide more information, I'll be unable to find the culprit.

What type do those variables have? Float64? Complex{Float64}? Other custom types?

Goysa2 commented 7 years ago

Hi sorry for taking so much time to get back to this thread. I was on Julia 0.5.2 when I had that bug, but now I am on Julia 0.6.0 and this error doesn't happen anymore. Everything works fine!

The problem was most likely with my computer. Since I tried to replicate the error on the computer of my colleagues on Julia 0.5.2 and I couldn't. I don't know why I had this issue or how it solved itself...

Sorry for bothering you with that!

giordano commented 7 years ago

Every bug report is precious, but please always provide a minimal working example reproducing the issue ;-)