8000 Don't call pgwin32_message_to_UTF16() without CurrentMemoryContext. · koderP/postgres@30e99ef · GitHub
[go: up one dir, main page]

Skip to content

Commit 30e99ef

Browse files
committed
Don't call pgwin32_message_to_UTF16() without CurrentMemoryContext.
PostgreSQL running as a Windows service crashed upon calling write_stderr() before MemoryContextInit(). This fix completes work started in 5735efe. Messages this early contain only ASCII bytes; if we removed the CurrentMemoryContext requirement, the ensuing conversions would have no effect. Back-patch to 9.3 (all supported versions). Takayuki Tsunakawa, reviewed by Michael Paquier. Discussion: https://postgr.es/m/0A3221C70F24FB45833433255569204D1F80CC73@G01JPEXMBYT05
1 parent 4cd5d8a commit 30e99ef

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/backend/utils/error/elog.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1910,11 +1910,16 @@ write_eventlog(int level, const char *line, int len)
19101910
* Convert message to UTF16 text and write it with ReportEventW, but
19111911
* fall-back into ReportEventA if conversion failed.
19121912
*
1913+
* Since we palloc the structure required for conversion, also fall
1914+
* through to writing unconverted if we have not yet set up
1915+
* CurrentMemoryContext.
1916+
*
19131917
* Also verify that we are not on our way into error recursion trouble due
19141918
* to error messages thrown deep inside pgwin32_toUTF16().
19151919
*/
19161920
if (GetDatabaseEncoding() != GetPlatformEncoding() &&
1917-
!in_error_recursion_trouble())
1921+
!in_error_recursion_trouble() &&
1922+
CurrentMemoryContext != NULL)
19181923
{
19191924
utf16 = pgwin32_toUTF16(line, len, NULL);
19201925
if (utf16)

0 commit comments

Comments
 (0)
0