gettimeofday cause crash on Windows

From: Asif Naeem <anaeem(dot)it(at)gmail(dot)com>
To: "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: gettimeofday cause crash on Windows
Date: 2015-02-11 12:11:34
Message-ID: CAEB4t-NQ4gSnFC8GfDgAeLx-rKm4-LwtUQMp-TdC6u_xRZdv1A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)2ndQuadrant(dot)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 Content-Type Size
gettimeofday_win32_suggestion_v1.patch application/octet-stream 1.8 KB
gettimeofday_win32_v1.patch application/octet-stream 1.7 KB

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message toruvinn 2015-02-11 21:28:48 BUG #12763: Planner refuses to do index-only-scan on partial indexes despite having all the required data
Previous Message Tom Lane 2015-02-11 00:04:33 Re: BUG #12760: Lateral files with more than 2 laterals