[Regression] dix: Fix overzealous caching of ResourceClientBits()
Commit c7311654 cached the value of ResourceClientBits(), but that value
depends on the MaxClients
value set either from the command line or
from the configuration file.
For the latter, a call to ResourceClientBits() is issued before the configuration file is read, meaning that the cached value is from the default, not from the maximum number of clients set in the configuration file.
That obviously causes all sort of issues, including memory corruption and crashes of the Xserver when reaching the default limit value.
To avoid that issue, also keep the LimitClient value, and recompute the ilog2() value if that changes, as on startup when the value is set from the the xorg.conf ServerFlags section.
Fixes: c7311654 - dix: cache ResourceClientBits() value
Closes: #1310 (closed)
Signed-off-by: Olivier Fourdan ofourdan@redhat.com
Merge request reports
Activity
assigned to @ofourdan
added 1 commit
- c7c431d5 - dix: Fix overzealous caching of ResourceClientBits()
added dix label
mentioned in issue #1310 (closed)
Looks like the ilog2 in resource.c is exceedingly inefficient. This will do it better with GCC (maybe want to guard it with a configure check?):
unsigned int ilog2(int val) { if (val <= 0) return 0; static const int offset = (sizeof(val) * 8) - 1; return offset - __builtin_clz(val); }
Note that ResourceClientBits appears to be the only consumer of ilog2, so you could inline it and drop the
val <= 0
check too. Then it's a single instruction (x86) or two (PPC). No need to cache.- Resolved by Olivier Fourdan
Or if you really don't want to calculate it here, maybe just add a
LimitClientsBits
in parallel toLimitClients
, and calculate it once inconfigServerFlags
after the value is initialised?
added 1 commit
- 64358260 - dix: Fix overzealous caching of ResourceClientBits()
added 3 commits
-
64358260...6907b6ea - 2 commits from branch
xorg:master
- 2645ec46 - dix: Fix overzealous caching of ResourceClientBits()
-
64358260...6907b6ea - 2 commits from branch
- Resolved by Olivier Fourdan
If you're only trying to recompute this on server reset then using
serverGeneration
for the trigger is maybe a little clearer (there's plenty of examples in-tree of how it's used). Which is probably the right thing, here, because changing the client limit dynamically would mean the XID space per client is no longer fixed among clients, which absolutely nothing is prepared for, but since there's no actual mechanism to make that change at runtime, meh.With or without any of that addressed,
Reviewed-by: Adam Jackson <ajax@redhat.com>
added 6 commits
-
2645ec46...24d7d93f - 5 commits from branch
xorg:master
- 2efa6d65 - dix: Fix overzealous caching of ResourceClientBits()
-
2645ec46...24d7d93f - 5 commits from branch
enabled an automatic merge when the pipeline for 2efa6d65 succeeds
mentioned in merge request !181