update mem info on every refresh on Solaris platform#1918
Merged
BenBE merged 1 commit intohtop-dev:mainfrom Mar 6, 2026
Merged
update mem info on every refresh on Solaris platform#1918BenBE merged 1 commit intohtop-dev:mainfrom
BenBE merged 1 commit intohtop-dev:mainfrom
Conversation
Member
|
@ViryBe thanks for looking into it.
It'd be really good to test this no a Solaris machine before proceeding further - is there anyone out there who can help? |
Author
|
yeah, I'll try to install solaris in a VM to test the patch if I have some time in the following days |
BenBE
reviewed
Mar 4, 2026
Member
BenBE
left a comment
There was a problem hiding this comment.
Just a minor stylistic note, apart from that the change looks reasonable. Testing on Solaris might be nice.
Use `kstat_chain_update` instead of 2 calls to `kstat_open` and `kstat_close`. Furthemore, the memory info was previously read only once and kept in a static variable. However, the pointer to the memory info is invalidated when the kstat chain is updated, such as when the cpu count changes. From the Illumos `kstat_chain_update` man page: ``` [...] any kstat_t structures retrieved by the kstat_lookup(3KSTAT) function or data pointers obtained through the kstat_data_lookup(3KSTAT) function are invalidated by a call to kstat_chain_update(). [...] ```
Author
|
Thanks for the feedback @BenBE. I tested in a Solaris 11.4 VM and I can confirm that the bug is also present and the fix works as intended. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
htopcrashes on illumos when the cpu count changes.Tested with latest main branch on an illumos system. I unfortunately don't have a Solaris machine to test on it, but according to the man pages the bug should be the same.
How to reproduce:
htopin a terminalhtopcrashed in first terminal.Issue and Fix
The memory info was previously read only once and kept in a static variable. However, the pointer to the memory info is invalidated when the kstat chain is updated, such as when the cpu count changes.
From the Illumos
kstat_chain_updateman page:So, re-reading the struct
kstat_ton every memory scan ensure that the pointermeminfois always valid.Note that I also replace the 2 calls to
kstat_openandkstat_closeby a singlekstat_chain_update.