Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite02571b

Browse files
committed
Don't call pgwin32_message_to_UTF16() without CurrentMemoryContext.
PostgreSQL running as a Windows service crashed upon callingwrite_stderr() before MemoryContextInit(). This fix completes workstarted in5735efe. Messages thisearly contain only ASCII bytes; if we removed the CurrentMemoryContextrequirement, the ensuing conversions would have no effect. Back-patchto 9.3 (all supported versions).Takayuki Tsunakawa, reviewed by Michael Paquier.Discussion:https://postgr.es/m/0A3221C70F24FB45833433255569204D1F80CC73@G01JPEXMBYT05
1 parent0b7e76e commite02571b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

‎src/backend/utils/error/elog.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2117,10 +2117,15 @@ write_eventlog(int level, const char *line, int len)
21172117
* try to convert the message to UTF16 and write it with ReportEventW().
21182118
* Fall back on ReportEventA() if conversion failed.
21192119
*
2120+
* Since we palloc the structure required for conversion, also fall
2121+
* through to writing unconverted if we have not yet set up
2122+
* CurrentMemoryContext.
2123+
*
21202124
* Also verify that we are not on our way into error recursion trouble due
21212125
* to error messages thrown deep inside pgwin32_message_to_UTF16().
21222126
*/
21232127
if (!in_error_recursion_trouble()&&
2128+
CurrentMemoryContext!=NULL&&
21242129
GetMessageEncoding()!=GetACPEncoding())
21252130
{
21262131
utf16=pgwin32_message_to_UTF16(line,len,NULL);

‎src/backend/utils/mb/mbutils.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,8 +1038,10 @@ GetMessageEncoding(void)
10381038

10391039
#ifdefWIN32
10401040
/*
1041-
* Result is palloc'ed null-terminated utf16 string. The character length
1042-
* is also passed to utf16len if not null. Returns NULL iff failed.
1041+
* Convert from MessageEncoding to a palloc'ed, null-terminated utf16
1042+
* string. The character length is also passed to utf16len if not
1043+
* null. Returns NULL iff failed. Before MessageEncoding initialization, "str"
1044+
* should be ASCII-only; this will function as though MessageEncoding is UTF8.
10431045
*/
10441046
WCHAR*
10451047
pgwin32_message_to_UTF16(constchar*str,intlen,int*utf16len)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp