#43 top-3.8beta1 will segfault with high thread ids

v3.8beta
open
nobody
5
2009-07-02
2009-07-02
Markus Weber
No

top-3.8beta1 might segfault in hash.c if thread ids get big (in this case on Solaris 10 10/08, x86/64bit):

From the debug output:

[...]
getptable: processing 16006.5
getptable: 16006.5: new thread
getptable: processing 16006.656377

segfault

From dbx:

signal SEGV (no mapping at the fault address) in hash_lookup_pidthr at line 1470 in file "hash.c"
1470 k1 = h->key;
(dbx) where
=>[1] hash_lookup_pidthr(ht = 0x432550, key = RECORD), line 1470 in "hash.c"
[2] getptable(baseptr = 0x42eb80), line 2096 in "m_sunos5.c"
[3] get_process_info(si = 0xfffffd7fffdffa90, sel = 0x432410, compare_index = 0), line 1531 in "m_sunos5.c"
[4] main(argc = 1, argv = 0xfffffd7fffdffb98), line 944 in "top.c"

(dbx) print key
key = {
k_pid = 16006
k_thr = 649832
}

I guess this is due to id_t being int or whatever. Attached a diff, which fixes it (I know, probably not that many casts are needed ;-).

Cheers, Markus

Discussion

  • Markus Weber
    Markus Weber
    2009-07-02

    preliminary patch for hash.c / high thread IDs

     
    Attachments