Обсуждение: AW: FW: Postgresql on win32

Поиск
Список
Период
Сортировка

AW: FW: Postgresql on win32

От
Zeugswetter Andreas SB
Дата:
> > The problem is that there are strings being allocated from 
> > libpq.dll using PQExpBuffers (for example, initPQExpBuffer() 
> > on line 92 of input.c). These are being allocated using the 
> > malloc function used by libpq.dll. This function *may* be 
> > different from the malloc function used by psql.exe - only 
> > the resulting pointer must be valid. And with the default 
> > linking methods, it *WILL* be different. Later, psql.exe 
> > tries to free() this string, at which point it crashes 
> > because the free() function can't find the allocated block 
> > (it's on the allocated blocks list used by the runtime lib of 
> > libpq.dll).

It is possible to make the above work (at least on MSVC).
The switch is /MD that needs to be used for both the psql.exe and 
libpq.dll. This forces the use of Multithreaded DLL runtime libraries.
The problem at hand is, that it uses different runtime libs for dll and exe
per default, if both use the same runtime libs it is possible to malloc in 
the dll and free in the exe.

Andreas


Re: AW: FW: Postgresql on win32

От
Tom Lane
Дата:
Zeugswetter Andreas SB  <ZeugswetterA@wien.spardat.at> writes:
> It is possible to make the above work (at least on MSVC).
> The switch is /MD that needs to be used for both the psql.exe and 
> libpq.dll. This forces the use of Multithreaded DLL runtime libraries.

I like this answer.  We should be trying to make the Win32 environment
more like Unix, rather than catering to its gratuitous differences.

The malloc/free problem that Magnus discovered is certainly not the only
one, anyway.  Notify processing comes to mind immediately, and who's to
say what else there may be, today or in the future?  Let's solve the
problem at a systemic level, not try to patch our way to working code.
        regards, tom lane


RE: AW: FW: Postgresql on win32

От
Magnus Hagander
Дата:
> Zeugswetter Andreas SB  <ZeugswetterA@wien.spardat.at> writes:
> > It is possible to make the above work (at least on MSVC).
> > The switch is /MD that needs to be used for both the psql.exe and 
> > libpq.dll. This forces the use of Multithreaded DLL runtime 
> libraries.
> 
> I like this answer.  We should be trying to make the Win32 environment
> more like Unix, rather than catering to its gratuitous differences.

Definitly, me too. I'll try this as soon as I get time on it, and update my
patch with it. Unless somebody beats me to it, that is.

//Magnus


7.1 question

От
Bruce Momjian
Дата:
Magnus, is this done?

> > Zeugswetter Andreas SB  <ZeugswetterA@wien.spardat.at> writes:
> > > It is possible to make the above work (at least on MSVC).
> > > The switch is /MD that needs to be used for both the psql.exe and
> > > libpq.dll. This forces the use of Multithreaded DLL runtime
> > libraries.
> >
> > I like this answer.  We should be trying to make the Win32 environment
> > more like Unix, rather than catering to its gratuitous differences.
>
> Definitly, me too. I'll try this as soon as I get time on it, and update my
> patch with it. Unless somebody beats me to it, that is.
>
> //Magnus
>


-- Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 



7.1 question

От
Bruce Momjian
Дата:
Magnus, is this done?

> > Zeugswetter Andreas SB  <ZeugswetterA@wien.spardat.at> writes:
> > > It is possible to make the above work (at least on MSVC).
> > > The switch is /MD that needs to be used for both the psql.exe and
> > > libpq.dll. This forces the use of Multithreaded DLL runtime
> > libraries.
> >
> > I like this answer.  We should be trying to make the Win32 environment
> > more like Unix, rather than catering to its gratuitous differences.
>
> Definitly, me too. I'll try this as soon as I get time on it, and update my
> patch with it. Unless somebody beats me to it, that is.
>
> //Magnus
>


-- Bruce Momjian                        |  http://candle.pha.pa.us pgman@candle.pha.pa.us               |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026