Skip to content

Fix types in trace - #9119

Merged
hvlad merged 5 commits into
FirebirdSQL:masterfrom
craftmaster1231:fix_types_in_trace
Aug 10, 2026
Merged

Fix types in trace#9119
hvlad merged 5 commits into
FirebirdSQL:masterfrom
craftmaster1231:fix_types_in_trace

Conversation

@Foxpunk

@Foxpunk Foxpunk commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Problem

  • A loop variable used MetaId (USHORT), a type not intended for
    holding counts, to iterate up to m_info.pin_count (type size_t),
    risking narrowing and a potential infinite loop.
  • MessageSet used int for message codes that are always within a
    small fixed range, wider than necessary.

Fix

  • Changed the loop variable type to FB_SIZE_T to match the type of
    m_info.pin_count it's compared against, avoiding narrowing.
  • Changed MessageSet fields to USHORT.

Notes

  • Changing pin_count's type isn't an option since PerformanceInfo is
    a public struct used outside this file — that would be an API change.
    Casting pin_count at the comparison would just hide the mismatch
    rather than fix it: i is used as an array index into
    m_tableCounters, not as a MetaId, so MetaId was the wrong type
    here regardless of pin_count's type. Widening the loop variable to
    FB_SIZE_T fixes the actual type mismatch and removes the risk of
    overflow/infinite loop if pin_count ever grows beyond USHORT range.
  • MessageSet fields were changed to USHORT. All current usages
    (MAIN_USAGE, EXAMPLES) are initialized with message codes in range
    3..42, e.g. MAIN_USAGE{{3, 21}, {41}}, EXAMPLES{{22, 27}, {42}}
    well within USHORT (0..65535). If new codes are added in the future,
    make sure they still fit into USHORT.

@hvlad hvlad left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea why MetaId appeared here

@hvlad hvlad self-assigned this Aug 10, 2026
@hvlad
hvlad merged commit afaab74 into FirebirdSQL:master Aug 10, 2026
19 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants