Closed sm-Fifteen closed 4 years ago
Yes, you are right. I did not know Windows has a different view on long type.
One option to solve this problem might be to use PyLong_AsLongLong for APIs like set_ctx_id_cbk
and set_tag_cbk
and make sure we never shrink the value while passing internally(though it seems not much a problem since we use uintptr_t
for passing these values all around)
Thanks for reporting this!
I have a potential fix for the issue. Could you please also look at it? https://github.com/sumerc/yappi/pull/39
Thanks!
Can confirm pip install --upgrade --force-reinstall https://github.com/sumerc/yappi/archive/fix-issue38.zip
fixes the issue on my end.
Nice! Thanks. Merged in master.
If the callback passed to
set_context_id_callback
returns a number that is too large for a Clong
, yappi will throw an error along the lines ofwith the following error sometimes(?) being logged:
Having looked into it, this seems to be related to the use of
PyLong_AsLong
here:https://github.com/sumerc/yappi/blob/7b3f08f5ad9d56e806ef2ddd9bf81a17f25f0fff/yappi/_yappi.c#L363-L376
I ended up running into this issue when running code similar to this on Windows. As it happens,
id(my_object)
is a 64 bits unsigned integer on 64-bits CPython, but along
on Windows is only 32 bits; onlylong long
s are 64 bits. This could turn out to be an issue in other use cases, so something should probably be done to adress the potential mismatch between the range of Pythonint
s and C types.