As reported in https://sourceware.org/bugzilla/show_bug.cgi?id=31003, GDB uses td_ta_thr_iter() to iterate threads found in a core file, but is encountering circular linkage that means td_ta_thr_iter() never terminates. td_ta_thr_iter() doesn't implement loop detection itself, and it appears that it doesn't allow the callback function to return a value indicating that it has detected a loop. Perhaps a callback return code can be added that allows the callback to indicate this condition, and which causes td_ta_thr_iter() to halt iteration and indicate same to its caller.
If the callback returns non-zero the function returns with TD_DBERR.
Exactly. I'm proposing that if the callback returns 'loop detected' the function returns a specific 'loop detected' error code so that the caller can react accordingly.
What's wrong with the existing TD_DBERR?
Because TD_DBERR doesn't distinguish the fact that iteration terminated because a loop was detected, as opposed to some other kind of error. In fact, is there any reason for td_ta_thr_iter() not to return the exact error code returned by the callback?
The callback can record the fact locally before returning.
I guess that's fair enough. Feel free to close.
Per comment 6.