gettimeofday cause crash on Windows - Mailing list pgsql-bugs

From Asif Naeem
Subject gettimeofday cause crash on Windows
Date
Msg-id CAEB4t-NQ4gSnFC8GfDgAeLx-rKm4-LwtUQMp-TdC6u_xRZdv1A@mail.gmail.com
Whole thread Raw
Responses Re: gettimeofday cause crash on Windows  (Michael Paquier <michael.paquier@gmail.com>)
List pgsql-bugs
Hi,

PG95/pg_test_fsync utility (MSVC built) is crashing on Windows and It is caused by gettimeofday (src\port\gettimeofday.c) function. The following check-in raised this issue i.e.

commit 8001fe67a3d66c95861ce1f7075ef03953670d13
Author: Simon Riggs <simon@2ndQuadrant.com>
Date:   Mon Dec 8 23:36:06 2014 +0900
    Windows: use GetSystemTimePreciseAsFileTime if available
    PostgreSQL on Windows 8 or Windows Server 2012 will now
    get high-resolution timestamps by dynamically loading the
    GetSystemTimePreciseAsFileTime function. It'll fall back to
    to GetSystemTimeAsFileTime if the higher precision variant
    isn't found, so the same binaries without problems on older
    Windows releases.
    No attempt is made to detect the Windows version.  Only the
    presence or absence of the desired function is considered.
    Craig Ringer
 
It make PG gettimeofday() implementation depend on init_win32_gettimeofday() function call, otherwise gettimeofday() function is going to crash the related process because of NULL pg_get_system_time function pointer. PFA patch gettimeofday_win32_v1.patch, it enables necessary initialization in related utilities.

PFA patch gettimeofday_win32_suggestion_v1.patch, it suggest minor change to make it more versatile version of PG gettimeofday() function. It makes it more crash safe and by default it uses much faster or lesser CPU intensive GetSystemTimeAsFileTime function. If a pg utility do require high precision, it can call init_win32_precise_gettimeofday() to try to elevate the precision when available. Please do let me know if I missed something or more information is required. Thanks.

Regards,
Muhammad Asif Naeem
Attachment

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #12760: Lateral files with more than 2 laterals
Next
From: toruvinn@lain.pl
Date:
Subject: BUG #12763: Planner refuses to do index-only-scan on partial indexes despite having all the required data