cfbolz changed the topic of #pypy to: PyPy, the flexible snake (IRC logs: https://quodlibet.duckdns.org/irc/pypy/latest.log.html#irc-end ) | use cffi for calling C | if a pep adds a mere 25-30 [C-API] functions or so, it's a drop in the ocean (cough) - Armin
<viblo>
Im trying to convert a project using CFFI from ABI to API mode
<viblo>
it works fine on linux (or, at least all my tests pass), but on windows there's one that fail which involves some callbacks, and the result is that python exits directly.
<viblo>
Anyone have any idea what I can do?
<viblo>
I have tried both with cpython 3.8 and latest pypy
<tos9>
I can test changes to rlib by running the modules in rlib/test right? Or do I need to translate to see the changes?
<tos9>
viblo: you mean your test case crashes python and you're trying to get more info on what happened?
<viblo>
yes, exactly
<viblo>
python crashes (silently exits) when it reaches a specific place
<viblo>
which uses some callbacks from the c-side into python
<tos9>
I am not a cffi expert, but 80% of the time this happens to me it's me forgetting to keep around a reference to an object from ffi.new etc.
<tos9>
make sure you're not doing that inline in the functions you're calling
<tos9>
e.g. do_something_with(ffi.new(...))
<tos9>
beyond that, stepping through with a debugger is a thing, did you try that?
<viblo>
the python code is quite old, and has been running in ABI-mode for a long time on linux, windows and osx
<viblo>
so I think it should be correct
<viblo>
but will double check :)
<viblo>
I tried compiling my code with debug=True
<tos9>
I don't think that will help, it will just show you stuff during compilation IIRC
<viblo>
after that I cant import the module at all
<tos9>
you need to find where exactly it's segfaulting or whatever
<tos9>
it's unfortunately probably also possible that there's a bug in cffi windows support, not sure how likely that is but probably nonzero -- if you paste a reproducible example someone who *is* a cffi expert may have better advice
<tos9>
(otherwise probably either way stick around and someone with better knowledge will chime up)
<tos9>
ok answering my own question it looks like yeah running rlib tests does the translation itself, cool, I think I never remember that
<tos9>
hmmmmm and some tests fail, ok guess I hunt down buildbot
<tos9>
but macos names the fields differently, so just going one by one to the places that have that `if TIMESPEC` check
<tos9>
(it just calls them st_atime, with the e at the end)
<mattip>
you might need to change the actual definitions of some of the fields in ALL_STATS_FIELDS ?
<tos9>
(figured it out)
<tos9>
5 tests down, 1 still failing
forgottenone has quit [Quit: Konversation terminated!]
forgottenone has joined #pypy
<tos9>
mattip: just to make sure I don't do dumb mercurial things, the correct workflow is `hg branch whatever` then `hg push --new-branch -b whatever` right?
<mattip>
that will create a permanent branch, which I like
<viblo>
mattip: so I have found the specif case that cause the issue now. One callback is defined to return a struct. If I instead change the c-code to return a pointer to struct instead, and then update python code accordingly it works
<mattip>
so basically correct, just add a hg commit -m"fix something"
<viblo>
so something happening when returning a plain struct...
<mattip>
ahh. that seems to remind me of an ffi bug
<mattip>
so it is not that bug, since 16 is an allowed size
<viblo>
(just a note, I use cffi 1.14.0)
<mattip>
what version of cpython/pypy?
<viblo>
cpython 3.8.4 / pypy 7.3.1
<viblo>
but Ive tried with cpython 3.7 also
<viblo>
I will have to leave for bed now, but big thanks for the help so far. At least I have a (quite ugly) workaround of changing c-code to use pointer :) Ill contine to test things tomorrow.
speeder39_ has quit [Quit: Connection closed for inactivity]