-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[FreeBSD] psutil.virtual_memory() fails without COMPAT_FREEBSD7 in the kernel #2113
Comments
This is bad. Does adding Thanks |
Looking further, either Looking at the code, there are references to
together with the following references to
so, the delta is Looking at preprocessor output, |
Recent FreeBSD Ports bug reports and analysis which may help @giampaolo Prior report and subsequent analysis/isolation on twitter: https://twitter.com/Tubsta/status/1532236245740359680 See also: |
Setting priority = critical. PRs are welcome. |
I've been affected by this on FreeBSD as well. Yes, including <sys/param.h> or <osreldate.h> in mem.c fixes the problem. Please note that COMPAT_FREEBSD7 is in the GENERIC kernel only on Intel. Other platforms, including arm64, came later and thus don't include COMPAT_FREEBSD7. I've submitted a quick patch to the FreeBSD ports system to un-break the port quickly: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=264807 |
- Bump PORTREVISION for package change psutil 5.9.1 does not include <sys/param.h> in arch/freebsd/mem.c, causing the __FreeBSD_version check there not not work properly and thus breaking the port on systems without COMPAT_FREEBSD7. PR: 264807 Reference: giampaolo/psutil#2113
@Torsten-B Thanks for your patch, are you able to produce a PR here for I also see other Might we have issues elsewhere in psutil too? cc @giampaolo |
I've tested that before submitting the PR to the FreeBSD ports tree and all cases in pstuil/arch/freebsd/ that had a __FreeBSD_version check either already included it directly or ended up pulling in sys/param.h indirectly via other included headers. I'll create a PR tonight my time (UTC+0200) |
Pull request: #2114 |
Fixed by #2114. |
Summary
Description
I have a FreeBSD 13.1-STABLE system using a custom kernel without
COMPAT_FREEBSD7
andpsutil.virtual_memory()
fails as follows:The problem is that the test at
psutil/psutil/arch/freebsd/mem.c
Line 33 in 5ca6870
<osreldate.h>
, hence__FreeBSD_version
is undefined (defaulting to 0), meaning thatbuffers
defaults toint
, whereas it should belong
for recent FreeBSD versions.I checked this by taking the compilation command:
and converting it to just preprocess (
-E -dD
instead of-c -o ...
), which generates (in part):note the
int buffers;
. This works for a GENERIC kernel because that includesCOMPAT_FREEBSD7
, which means that eitherint
orlong
is accepted. (The sysctlvfs.bufspace
is defined at https://cgit.freebsd.org/src/tree/sys/kern/vfs_bio.c?h=stable/13#n208 and the implementation beginning at https://cgit.freebsd.org/src/tree/sys/kern/vfs_bio.c?h=stable/13#n469 tests whetherCOMPAT_FREEBSD7
is defined).Searching through the code, there's no include of
<osreldate.h>
anywhere so I suspect none of the__FreeBSD_version
tests work as intended.The text was updated successfully, but these errors were encountered: