<!DOCTYPE html>
<!-- BaNnErBlUrFlE-BoDy-start -->
<!-- Preheader Text : BEGIN -->
<div style="display:none !important;display:none;visibility:hidden;mso-hide:all;font-size:1px;color:#ffffff;line-height:1px;max-height:0px;opacity:0;overflow:hidden;">
On 30 Oct 2026, Kris Van Hees told this: > --- a/libdtrace/dt_btf. c > +++ b/libdtrace/dt_btf. c > @@ -100,8 +100,14 @@ static btf_type_t * > dt_btf_real_type_by_id(const dt_btf_t *btf, int32_t id) > { > btf_type_t *type = dt_btf_type_by_id(btf,</div>
<!-- Preheader Text : END -->
<!-- Email Banner : BEGIN -->
<div style="display:none !important;display:none;visibility:hidden;mso-hide:all;font-size:1px;color:#ffffff;line-height:1px;max-height:0px;opacity:0;overflow:hidden;"></div>
<!-- Email Banner : END -->
<!-- BaNnErBlUrFlE-BoDy-end -->
<html>
<head><!-- BaNnErBlUrFlE-HeAdEr-start -->
<style>
#pfptBannercl0obg0 { all: revert !important; display: block !important;
visibility: visible !important; opacity: 1 !important;
background-color: #c2d4d4 !important;
max-width: none !important; max-height: none !important }
.pfptPrimaryButtoncl0obg0:hover, .pfptPrimaryButtoncl0obg0:focus {
background-color: #a2b1b1 !important; }
.pfptPrimaryButtoncl0obg0:active {
background-color: #828e8e !important; }
html:root, html:root>body { all: revert !important; display: block !important;
visibility: visible !important; opacity: 1 !important; }
</style>
<!-- BaNnErBlUrFlE-HeAdEr-end -->
</head><body><pre style="font-family: sans-serif; font-size: 100%; white-space: pre-wrap; word-wrap: break-word">On 30 Oct 2026, Kris Van Hees told this:
> --- a/libdtrace/dt_btf.c
> +++ b/libdtrace/dt_btf.c
> @@ -100,8 +100,14 @@ static btf_type_t *
> dt_btf_real_type_by_id(const dt_btf_t *btf, int32_t id)
> {
> btf_type_t *type = dt_btf_type_by_id(btf, id);
> + uint64_t remaining = 1 + (uint64_t)btf->type_cnt;
>
> - while (type != NULL) {
> + if (btf->parent != NULL)
> + remaining += btf->parent->type_cnt;
> +
> + /* A longer chain must revisit a type, so reject cyclic BTF references. */
> + while (type != NULL && remaining > 0) {
> + remaining--;
> switch (BTF_INFO_KIND(type->info)) {
> case BTF_KIND_CONST:
> case BTF_KIND_FUNC:
That's a fun approach. Simple and entirely different from what I'm doing
in a yet-to-be-pushed libctf commit :) (which involves a counter which
starts at 1 and is reduced on every lookup, and whenever it hits 0 an
identity-check is done and the counter is reset with an increased
initial value: a tortoise-and-hare-in-O(1) space-and-time algorithm of
Hellman's. Like yours, it has the advantage of being basically free
unless things go wrong.)
Reviewed-by: Nick Alcock <nix@esperi.org.uk>
--
NULL && (void)
</pre></body></html>