-
Notifications
You must be signed in to change notification settings - Fork 33
Try building on windows-2022 #294
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
Try building on windows-2022 #294
Conversation
src/flint/types/fmpz.pyx
Outdated
cdef char * s | ||
if COEFF_IS_MPZ(x[0]): | ||
s = fmpz_get_str(NULL, 16, x) | ||
v = int(str_from_chars(s), 16) | ||
v = int(bytes(s).decode('ascii'), 16) | ||
libc.stdlib.free(s) | ||
return v |
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'm not sure why this change seems to have fixed the problem. The function is defined as:
cdef inline str_from_chars(s):
return bytes(s).decode('ascii')
However actually inlining the function here prevents the crash that is only seen on Windows when building with windows-2022 or windows-2025 but not if built on windows-2019... (The crash happens when running on any Windows version but not if the binaries were built on windows-2019.)
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.
No, I was tricked. This change does not fix the problem. I fell for the classic printing things makes the segfault go away confusion.
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.
Maybe this should use flint_free
?
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.
Or maybe it didn't even work then. I might have looked at the wrong CI output. It is late and there are too many jobs to check...
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.
Maybe PyLong_FromString should be used:
https://docs.python.org/3/c-api/long.html#c.PyLong_FromString
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.
It seems that using flint_free
fixes this although now there is a crash somewhere else.
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.
All the observed problems were fixed by using flint_free when using fmpz_get_str
. I'm not sure why this issue appears now and not before.
It is probably worth reviewing all other uses of free
to see if they should be flint_free
...
e5b03e4
to
da48c45
Compare
Follows gh-291