[bug fix] Produce a crash dump before main() on Windows

From: "Tsunakawa, Takayuki" <tsunakawa(dot)takay(at)jp(dot)fujitsu(dot)com>
To: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: [bug fix] Produce a crash dump before main() on Windows
Date: 2018-02-16 07:28:40
Message-ID: 0A3221C70F24FB45833433255569204D1F8B6944@G01JPEXMBYT05
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

postgres.exe on Windows doesn't output a crash dump when it crashes before main() is called. The attached patch fixes this. I'd like this to be back-patched. I'll add this to the next CF.

The original problem happened on our customer's production system. Their application sometimes failed to connect to the database. That was because postgres.exe crashed due to access violation (exception code C0000005). But there was no crash dump, so we had difficulty in finding the cause. The frequency was low -- about ten times during half a year.

What caused the access violation was Symantec's antivirus software. It seems that sysfer.dll of the software intercepts registry access, during C runtime library initialization, before main() is called. So, the direct cause of this problem is not PostgreSQL.

On the other hand, it's PostgreSQL's problem that we can't get the crash dump, which makes the investigation difficult. The cause is that postmaster calls SetErrorMode() to disable the outputing of crash dumps by WER (Windows Error Reporting). This error mode is inherited from postmaster to its children. If a crash happens before the child sets up the exception handler, no crash dump is produced.

Regards
Takayuki Tsunakawa

Attachment Content-Type Size
crash_dump_before_main.patch application/octet-stream 1.1 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2018-02-16 08:06:20 Re: [bug fix] Cascaded standby cannot start after a clean shutdown
Previous Message Michael Paquier 2018-02-16 07:19:00 Re: [bug fix] Cascaded standby cannot start after a clean shutdown