Ticket #327 (closed defect: fixed)

Opened 3 years ago

Last modified 2 years ago

signed/unsigned bug in StatBag leads to wrap-around issues with counters

Reported by: anon Owned by: ahu
Priority: normal Milestone:
Component: auth Version:
Severity: normal Keywords:
Cc:

Description

Just ran into an issue with our graphing of the query-cache:

# /usr/bin/pdns_control show '*' corrupt-packets=59131310,deferred-cache-inserts=44998069,deferred-cache-lookup=24040315,latency=0,packetcache-hit=725969193,packetcache-miss=1347724754,packetcache-size=136632,qsize-q=1,query-cache-hit=2209510287,query-cache-miss=2196442457,recursing-answers=0,recursing-questions=0,servfail-packets=80,tcp-answers=126456,tcp-queries=444324,timedout-packets=0,udp-answers=2082640507,udp-queries=2098925279,udp4-answers=2082640475,udp4-queries=2082641650,udp6-answers=0,udp6-queries=0,

# /usr/bin/pdns_control show query-cache-hit -2084941632

Looking at the code, the SHOW * command works because you just deref the pointer which is defined as an unsigned int. However the SHOW <item> code doesn't work because it uses StatBag::read() which is defined as returning a signed int. I believe the attached patch will fix the issues but there may still be some other places in the StatBag? code where it would be better to explicitly specify unsigned int.

Perhaps in the future the counter should be given with a typedef to prevent this from occuring again and specified as a long to ensure that we can get the full 64 bits on a 64-bit arch? (I believe an int on x86_64 arch is still only 32 bit)

Mark

Attachments

pdns-fix-unsigned-signed-issues.patch Download (2.2 KB) - added by anon 3 years ago.

Change History

Changed 3 years ago by anon

Changed 2 years ago by ahu

  • status changed from new to closed
  • resolution set to fixed

Fixed slightly differently in commit 2019, thanks!

Note: See TracTickets for help on using tickets.