pgsql: Make pgwin32_putenv() follow DLL loading and unloading.

Поиск
Список
Период
Сортировка
От Noah Misch
Тема pgsql: Make pgwin32_putenv() follow DLL loading and unloading.
Дата
Msg-id E1cDHKr-0003hw-JG@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Make pgwin32_putenv() follow DLL loading and unloading.

Until now, the first putenv() call of a given postgres.exe process would
cache the set of loaded CRTs.  If a CRT unloaded after that call, the
next putenv() would crash.  That risk was largely theoretical, because
the first putenv() precedes all PostgreSQL-initiated module loading.
However, this might explain bad interactions with antivirus and other
software that injects threads asynchronously.  If an additional CRT
loaded after the first putenv(), pgwin32_putenv() would not discover it.
That CRT would have all environment changes predating its load, but it
would not receive later PostgreSQL-initiated changes.  An additional CRT
loading concurrently with the first putenv() might miss that change in
addition to missing later changes.  Fix all those problems.  This
removes the cache mechanism from pgwin32_putenv(); the cost, less than
100 μs per backend startup, is negligible.

No resulting misbehavior was known to be user-visible given the core
distribution alone, but one can readily construct an affected extension
module.  No back-patch given the lack of complaints and the potential
for behavior changes in non-PostgreSQL code running in the backend.

Christian Ullrich, reviewed by Michael Paquier.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/202dbdbe41e1b1085a4d69c96bca9a52e634b196

Modified Files
--------------
src/port/win32env.c | 160 ++++++++++++++++------------------------------------
1 file changed, 48 insertions(+), 112 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Noah Misch
Дата:
Сообщение: pgsql: Remove wrong CloseHandle() call.
Следующее
От: Noah Misch
Дата:
Сообщение: pgsql: Make pgwin32_putenv() probe every known CRT, regardless of compi