On Sun, Apr 5, 2026, at 8:24 PM, Aaron Merey wrote:
>> @@ -84,8 +84,8 @@ generic_sample_sp_pc (const Dwarf_Word *regs, uint32_t
>> n_regs,
>> /* TODO: Register locations could be cached and rechecked on a
>> fastpath without needing to loop, though the overhead reduction
>> is minimal. */
>> - int j, need_sp = (sp != NULL), need_pc = (pc != NULL);
>> - for (j = 0; (need_sp || need_pc) && n_regs_mapping > (uint32_t)j; j++)
>> + int need_sp = (sp != NULL), need_pc = (pc != NULL);
>> + for (size_t j = 0; (need_sp || need_pc) && n_regs_mapping > j; j++)
>> {
>> if (n_regs < (uint32_t)j) break;
>
> This cast will truncate j when size_t is uint64_t, although having
> more than 2^32 registers is unlikely.
Agreed, don't see a better way to do this.
The comparison will be fixed to use <= in the revised patch (cf the discussion
on patch1),
so even in a deliberately-pathological case we would have j reach UINT32_MAX
and trigger this correctly.
- [PATCH 1/6] backends/: add aarch64 sample_regs support Serhei Makarov
- [PATCH 3/6] libebl/eblinitreg_sample.c: fix a potentia... Serhei Makarov
- [PATCH 5/6] backends/: add 32-bit ARM sample_regs supp... Serhei Makarov
- Re: [PATCH 5/6] backends/: add 32-bit ARM sample_r... Aaron Merey
- Re: [PATCH 5/6] backends/: add 32-bit ARM samp... Serhei Makarov
- Re: [PATCH 5/6] backends/: add 32-bit ARM ... Aaron Merey
- [PATCH 4/6] backends/: should use size_t n_regs_mappin... Serhei Makarov
- Re: [PATCH 4/6] backends/: should use size_t n_reg... Aaron Merey
- Re: [PATCH 4/6] backends/: should use size_t n... Serhei Makarov
- Re: [PATCH 4/6] backends/: should use size... Aaron Merey
- [PATCH 2/6] backends/: fixup x86 initreg_sample to sha... Serhei Makarov
- [PATCH 6/6] src/stacktrace.c: Enable ARM support Serhei Makarov
- Re: [PATCH 6/6] src/stacktrace.c: Enable ARM suppo... Aaron Merey
- Re: [PATCH 6/6] src/stacktrace.c: Enable ARM s... Serhei Makarov
- Re: [PATCH 6/6] src/stacktrace.c: Enable A... Aaron Merey
- Re: [PATCH 1/6] backends/: add aarch64 sample_regs sup... Aaron Merey
- Re: [PATCH 1/6] backends/: add aarch64 sample_regs... Serhei Makarov
