Re: edb-postgres.exe has encountered a problem on windows

Lists: pgsql-hackers
From: Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Rushabh Lathia <rushabh(dot)lathia(at)enterprisedb(dot)com>, Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Subject: edb-postgres.exe has encountered a problem on windows
Date: 2011-04-01 13:14:33
Message-ID: AANLkTi=NatGM-Q+=4Fe5M2auYoWyhacxwvgx2ttjkqwJ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Problem:
========

On windows when we run edb-postgres.exe without any command line args, its
getting crash or its showing error into Application logs of Event Viewer.

Analysis:
==========

For any stderr we call the write_stderr() and write_stderr() calls the
write_console() for stderr. Now here write_console() using the palloc()
internally, which require the CurrentMemoryContext.

At the startup CurrentMemoryContext will be NULL, so palloc again calling
write_stderr(). So recursion has been started and its ending up with
exception.

Call stack for palloc() is:

main() -> check_root() -> write_stderr() -> write_console() ->
pgwin32_toUTF16() -> palloc()

Fix:
=====

Earlier we used to call vfprintf() for windows stderr, which is now
replaced with write_console().
So to avoid the exception now, I added condition for CurrentMemoryContext
into write_stderr().

PFA patch to fix the same.

Regards,
Rushabh Lathia
EnterpriseDB <http://www.enterprisedb.com/>, The Enterprise
PostgreSQL<http://www.enterprisedb.com/>
company.

Attachment Content-Type Size
win_crash_fix.patch text/x-diff 955 bytes

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, Rushabh Lathia <rushabh(dot)lathia(at)enterprisedb(dot)com>, Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Subject: Re: edb-postgres.exe has encountered a problem on windows
Date: 2011-04-01 13:21:07
Message-ID: AANLkTin-xOjexQikNeL8sJga0Epp8a=Zf2y10PvzkuHc@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Apr 1, 2011 at 15:14, Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com> wrote:
> Problem:
> ========
>
> On windows when we run edb-postgres.exe without any command line args, its
> getting crash or its showing error into Application logs of Event Viewer.
>
> Analysis:
> ==========
>
> For any stderr we call the write_stderr() and write_stderr() calls the
> write_console() for stderr. Now here write_console() using the palloc()
> internally, which require the CurrentMemoryContext.
>
> At the startup CurrentMemoryContext will be NULL, so palloc again calling
> write_stderr(). So recursion has been started and its ending up with
> exception.
>
> Call stack for palloc() is:
>
> main() -> check_root() -> write_stderr() -> write_console() ->
> pgwin32_toUTF16() -> palloc()
>
> Fix:
> =====
>
> Earlier  we used to call vfprintf() for windows stderr, which is now
> replaced with write_console().
> So to avoid the exception now, I added condition for CurrentMemoryContext
> into write_stderr().
>
> PFA patch to fix the same.

What about the cases where we directly call write_console()? Do we
know we are good there, or should the check perhaps be made inside
write_console() instead of in the caller?

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, Rushabh Lathia <rushabh(dot)lathia(at)enterprisedb(dot)com>, Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Subject: Re: edb-postgres.exe has encountered a problem on windows
Date: 2011-04-01 13:56:39
Message-ID: AANLkTinXMpiygtFc1c2oRn8ifFYKvaJGbA19wtXvQQY4@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Apr 1, 2011 at 9:14 AM, Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com> wrote:
> On windows when we run edb-postgres.exe ...

Did you intend to send this to an EDB-internal mailing list?

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org, Rushabh Lathia <rushabh(dot)lathia(at)enterprisedb(dot)com>, Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Subject: Re: edb-postgres.exe has encountered a problem on windows
Date: 2011-04-01 14:00:49
Message-ID: 4D95DA91.9020800@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 01.04.2011 16:56, Robert Haas wrote:
> On Fri, Apr 1, 2011 at 9:14 AM, Rushabh Lathia<rushabh(dot)lathia(at)gmail(dot)com> wrote:
>> On windows when we run edb-postgres.exe ...
>
> Did you intend to send this to an EDB-internal mailing list?

I think he just forgot to search & replace edb-postgres.exe to
postgres.exe ;-). The issue was found originally on Advanced Server, but
there is nothing EDB-specific there and the same bug is in community
PostgreSQL.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com


From: Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, Rushabh Lathia <rushabh(dot)lathia(at)enterprisedb(dot)com>, Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Subject: Re: edb-postgres.exe has encountered a problem on windows
Date: 2011-04-01 14:01:10
Message-ID: AANLkTi=iDduTFKkQJmVUQpb9kScHkYTE14pF=jcTqH4z@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Apr 1, 2011 at 7:26 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:

> On Fri, Apr 1, 2011 at 9:14 AM, Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com>
> wrote:
> > On windows when we run edb-postgres.exe ...
>
> Did you intend to send this to an EDB-internal mailing list?
>

Oops sorry, initially we found this bug with EDB.

But after looking into issue more I found that its also present into
postgreSQL.

Need to replace edb-postgres.exe with postgres.exe ..

Regards,
Rushabh Lathia
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company