Closed veremenko-y closed 5 months ago
I am thinking something like
--- a/Applications/util/ps.c
+++ b/Applications/util/ps.c
@@ -472,7 +472,9 @@ int do_ps(void)
close(pfd);
return 1;
}
- ppid_slot[i] = ptab[i].p_tab.p_pptr - ptab[0].p_tab.p_pptr;
+ /* Work out which slot is referenced from the node size as our own ptab struct
+ may not exactly size match the kernel */
+ ppid_slot[i] = ((uint8_t *)ptab[i].p_tab.p_pptr - (uint8_t *)ptab[0].p_tab.p_pptr) / nodesize;
/* Learn our tty internal reference as we go */
if (ptab[i].p_tab.p_status && ptab[i].p_tab.p_pid == pid)
tty = ptab[i].p_tab.p_tty;
might be more robust ?
That would do definitely do. No sneaky UB. We could also assert if % nodesize
is not 0.
I get memory exceptions on
rpipico
. I bisected it to 7fd6add4cc5a16beaf7bac9bf2826b2c4515f21b, but still investigating the cause.Not all commands break, but to guarantee an exception
ps -al
seems to work. I experienced it withed
as well, but don't have solid way to reproduce it.It's not problem with the utility itself, I get the same behavior if I run
ps
version made prior top_tab
change.