-
Notifications
You must be signed in to change notification settings - Fork 166
One more test for rational solutions #5593
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Segfault in FLINT: |
|
On my computer the first call to |
|
@hannes14 did you already have a chance to look into this? |
|
from triage: @hannes14 will run this in the debugger to try to see what is going wrong |
|
So the crash is originating in ...
h = mapreduce(f -> evaluate(f, r), gcd, Gi)
h == 0 && error("Unexpected zero polynomial")
for a in roots(h) # <-- crash is inside `roots`Someone could insert code before the roots call to e.g. print |
|
This goes through quite a number of iterations before it crashes. Of course it is not clear if something is already wrong beforehand but does not crash. The final polynomial is linear: x+31. Then the Flint exception: Unable to allocate memory. |
|
I'll try to see if I can figure something out, but of course anyone else who knows a bit about FLINT and Nemo and its memory management (e.g. @thofma @lgoettgens @fieker ...) could also try... Let's see. |
|
Some pointers from a debugging/rr session: It seems to die in the conversion Oscar.jl/src/Rings/AlgClosureFp.jl Line 203 in 56f5eac
which calls this FqPolyRingElem constructor in Nemo https://github.com/Nemocas/Nemo.jl/blob/9067e0b89252866eb99e6fc6fa9bae68dac7a548/src/flint/FlintTypes.jl#L4475 and in then ends up in this call: But This step from julia code (Nemo) to flint is this call: Where to be continued ... but maybe someone already has an idea what to look at from these bits. |
benlorenz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed a change that seems reasonable and does fix this for me even though I don't fully understand the details.
I pushed it here to let CI check it more thoroughly.
| push!(b, k(data(a[i]))) | ||
| elseif da[i] == l | ||
| push!(b, data(a[i])) | ||
| push!(b, k(data(a[i]))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This conversion does seem to fix the crash and seems very reasonable to me, the object returned from data might not be in the correct field for the further operations.
The conversion function (R::FqPolyRing)(x::Vector{FqFieldElem}) will only check the parent of the first element of x but they will probably not be the same without the conversion here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch!
test/Rings/solving.jl
Outdated
| I=ideal([x^3 + 2*y^2 + 3, y^3 + 5*x + 7]) | ||
| pts = rational_solutions(I) | ||
| pts = rational_solutions(I) # this is intentional | ||
| @test length(pts) == 9 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On my computer the first call to
rational_pointstriggers SEGV. Why do we expect 8 points rather than 9?
Was this ever answered? Because now that it succeeds it does return 9 for me and I changed the expected output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we rename the second pts to pts2, and then check that both have the same length, and the same elements (up to ordering)?
Also, one could just print the result to visually verify that the outputs are distinct. And finally, perhaps we could do something like @test all( iszero(f(p)) for p in pts, f in gens(i)) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a set comparison and iszero checks now.
|
Great! Thanks a lot @benlorenz ! We expect 9 points. We added the 8 since the test sometimes was returning a wrong answer of 8 and sometimes segfaulting, and we wanted to distinguish this. It is very good news that now also the answer is correct! |
Co-authored-by: Benjamin Lorenz <[email protected]>
This segfaults on my computer (at least when called twice), let's see what happens here.