Bug 563289 - Titan Logger timestamp problem after 2038
Summary: Titan Logger timestamp problem after 2038
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: titan.core (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-05-18 08:47 EDT by G??bor Szalai CLA
Modified: 2021-04-23 10:42 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description G??bor Szalai CLA 2020-05-18 08:47:01 EDT
Using the Titan for test with setting the system time after 2038 Jan 12, produces a faulty time stamp in the log file:

Instead of
2038/Mar/26 07:23:23.111835 TTCN-3 Parallel Test Component started on gtcloud0740. 

The following time stamp is printed into the log file:
1902/Mar/26 07:23:23.111835 TTCN-3 Parallel Test Component started on gtcloud0740. 

There are at least two fault in the time stamp handling of the Logger

1. Storing the event time stamp:
void LoggerPluginManager::fill_common_fields(API::TitanLogEvent& event,
                                             const TTCN_Logger::Severity& severity)
{
...
  struct timeval tv;
  if (gettimeofday(&tv, NULL) < 0)
    TTCN_Logger::fatal_error("The gettimeofday() system call failed.");
  event.timestamp__() = API::TimestampType(tv.tv_sec, tv.tv_usec);

The tv.tv_sec contains the correct value (64 bit signed), but interpreted as int (32 bit signed) and overflows, negative value

Correct way:
event.timestamp__().seconds().set_long_long_val(tv.tv_sec);
event.timestamp__().microSeconds()=tv.tv_usec;

2nd bug: Reading the timestamp:
LegacyLogger.cc:
char *event_to_str(const TitanLoggerApi::TitanLogEvent& event,
                                 boolean without_header)
{
  char *ret_val = NULL;
  if (!without_header) {
    struct timeval timestamp = { (time_t)event.timestamp__().seconds(),
      (suseconds_t)event.timestamp__().microSeconds() };

The field seconds contains value which can't be represented in int -> Dynamic test case error: Invalid conversion of a large integer value

Correct code:
struct timeval timestamp = { (time_t)event.timestamp__().seconds().get_long_long_val(),
      (suseconds_t)event.timestamp__().microSeconds() };
Comment 1 Kristof Szabados CLA 2020-05-22 04:12:19 EDT
TTCN_Communication::send_log will also need to be updated.
Which means updating the protocal between the HC and MC.
Comment 2 Denis Roy CLA 2021-04-23 10:42:59 EDT
This bug was migrated to GitLab: https://gitlab.eclipse.org/eclipse/titan/titan.core/-/issues