Opened 14 years ago

Closed 14 years ago

Last modified 11 years ago

#264 closed defect (fixed)

timestamp conversion problem

Reported by: yuri@… Owned by: perry
Priority: critical Milestone:
Component: libtrace-library Version: 3.0
Keywords: Cc:


In function

uint64_t trace_get_erf_timestamp(const libtrace_packet_t *packet) {

I have these lines:

} else if (packet->trace->format->get_timeval) {

/* timeval -> timestamp */ ts = packet->trace->format->get_timeval(packet); timestamp = ((((uint64_t)ts.tv_sec) << 32) + \

(((uint64_t)ts.tv_usec * UINT_MAX)/1000000));

and these lines do not work. After the pre-processor they expand into:

timestamp = ((((uint64_t)ts.tv_sec) << 32) + (((uint64_t)ts.tv_usec *

(2147483647 * 2U + 1U))/1000000));

And the expression (2147483647 * 2U + 1U) evaluates into a signed integer -1 which produces wrong results:

(gdb) p ts

$89 = {tv_sec = 1159894600, tv_usec = 846404}

(gdb) p timestamp

$94 = 4981727820551075308

I'm using glibc-headers-2.7-2, gcc-4.1.2-33, kernel, libtrace-3.0.4.

I think this is pretty serious. I'm not sure why UINT_MAX gets expanded into a signed constant, which is probably a bug in itself, but using this constant here seems wrong anyway, because we know exactly how many bits we have. Besides, 1000000us should be equal to 1s, so I suggest changing this conversion to:

timestamp = ((((uint64_t)ts.tv_sec) << 32) + \

(((uint64_t)ts.tv_usec << 32) /1000000));

Change History (2)

comment:1 Changed 14 years ago by perry

  • Resolution set to fixed
  • Status changed from new to closed

Hrm, how odd. UINT_MAX on your machine appears to expand to (2147483647 * 2U + 1U) where as on our machines it expands to 4294967295U which is unsigned.

The original code was written that way to be consistent with the conversion from floating point seconds, where a bitshift of a floating point number doesn't work.

Your fix is commited in r1357.

comment:2 Changed 11 years ago by NicaTolcalt

For people prone to constipation, limiting foods that have little or no fiber, such as ice cream, cheese, meat, and processed foods, is also important. online weight loss clinic phentermine [ phentermine and memory loss - fp doctor information phentermine [ phentermine and nausea - proven reliable phentermine sites [ phentermine 37.5 overnight delivery - is phentermine phen phen [ phentermine does it work - phentermine hydroxide [ order phentermine with online diagnosis - phentermine no prescription required online consultation [ phentermine hcl trusted pharmacy catalog - buy scam phentermine [ no prescription phentermine cod - looking for diet pills called phentermines [ how can i buy phentermine - phentermine from mexican pharmacies [ phentermine mastercard no prescription - online phentermine prescriptions and pharmacies [ find doctor to prescribe phentermine - These changes increase the risk for dangerous ventricular arrhythmias and sudden cardiac arrest. tramadol and sexual dysfunction [ tramadol hci effects on brain - tramadol morphine dose equivalent [ counseling degree online tramadol - new tramadol tramadol ultram [ equivalents to tramadol xl - naproxen and tramadol [ what is tramadol with acetaminophen - tramadol hcl capsules [ discount tramadol for dogs - how strong is tramadol [ tramadol in mexican pharmacies - tramadol bruising [ tramadol pain pills - plugging tramadol [ tramadol fo dogs - tramadol adverse effects [ samoobrona warszawa pl tramadol - warfarin tramadol interaction [ tramadol and heroin - Clinical studies of TENORMIN did not include sufficient number of patients aged 65 and over to determine whether they respond differently from younger subjects. legal adipex [ adipex causing rapid heart beat - is adipex a prescription drug [ didrex adipex online - adipex online without prescription pharmacy online [ adipex next day shipping no prescription - adipex from us online pharmacy [ adipex vs adipex p - It seems to sensitize tissues to the action of acetylcholine. enhancing viagra [ viagra uk paypal - what does viagra do to females [ safety of viagra - viagra users reviews [ viagra and mexico - viagra france [ viagra cialis mix - Administering Verelan® PM in the morning increased the extent of absorption of verapamil and/or decreased the metabolism to norverapamil. cialis buy on line [ best buy cialis softtabs - aggression and cialis [ cialis buzzmachine by jeff jarvis - cialis online fda [ cialis dosage 20mg - sales cialis [ cialis panties - after effects of cialis [ jual cialis - viagra lavetra cialis [ how to write a prescription cialis - Concomitant administration of tramadol and cimetidine does not result in clinically significant changes in tramadol pharmacokinetics. soma carisoprodol tablets [ drug abuse soma - Some encephalopathies are preventable by positive lifestyle choices and others cannot be foreseen. xanax withour a prescription [ xanax brand name - xanax dosage g3720 [ xanax safe with z-pack - what are signs of xanax overdose [ what does xanax do to the brain - cephalexin nexium and xanax together [ alprazolam mg generic xanax - does xanax show up on a drug test [ dosages of xanax - xanax mexican drug class [ drug abuse of xanax - People traveling in areas endemic with Falciparum should take other medications prescribed by a doctor (not for pregnant women or children younger than 8 years). effects of valium and alcohol [ taking valium while pregnant - valium no prescription overnight [ valium for dental work - symptoms of valium withdrawal [ safe dose of valium - Examination of the jugular veins in the neck and swelling or fluid in the feet and ankles can be clues to the diagnosis of heart failure.

Note: See TracTickets for help on using tickets.