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

edb-postgres.exe has encountered a problem on windows

From
Rushabh Lathia
Date:
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, The Enterprise PostgreSQL company.

Attachment

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

From
Magnus Hagander
Date:
On Fri, Apr 1, 2011 at 15:14, Rushabh Lathia <rushabh.lathia@gmail.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/


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

From
Robert Haas
Date:
On Fri, Apr 1, 2011 at 9:14 AM, Rushabh Lathia <rushabh.lathia@gmail.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


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

From
Heikki Linnakangas
Date:
On 01.04.2011 16:56, Robert Haas wrote:
> On Fri, Apr 1, 2011 at 9:14 AM, Rushabh Lathia<rushabh.lathia@gmail.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


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

From
Rushabh Lathia
Date:


On Fri, Apr 1, 2011 at 7:26 PM, Robert Haas <robertmhaas@gmail.com> wrote:
On Fri, Apr 1, 2011 at 9:14 AM, Rushabh Lathia <rushabh.lathia@gmail.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