[MDEV-27092] Windows - services that have non-ASCII characters do not work with activeCodePage=UTF8 Created: 2021-11-19  Updated: 2022-01-18  Resolved: 2022-01-18

Status: Closed
Project: MariaDB Server
Component/s: Character Sets, Platform Windows
Affects Version/s: N/A
Fix Version/s: 10.8.1

Type: Bug Priority: Major
Reporter: Vladislav Vaintroub Assignee: Vladislav Vaintroub
Resolution: Fixed Votes: 0
Labels: None

Attachments: Zip Archive repro-1.zip    
Issue Links:
PartOf
is part of MDEV-26713 Windows - improve i18n support Closed

 Description   

That's a Windows bug for which I could not find a reference anywhere else.
Service functions, e.g CreateService/OpenService, do not handle activeCodePage=UTF8 correctly
i.e if either service name, or the command line contain non-ASCIIs, it would produce a mojibake.

It affects us since we actually want to use activeCodePage=UTF8 , and need to ensure that as much as possible would work here, too

To reproduce, one will need reasonably new Windows (10 1903+).
1. Unpack the repro zip in the attachment
2. build the test executable
3. Call path\to\service_test.exe <string_with_non-ASCII_character>. It should create service with that name, but it does not happen, as we see later-
4. call "sc query <string_from_>" to see that service was not created, see below for demonstration

The fix/workaround we can do , is not to use those functions directly, but write a wrapper that actually does what is expected (convert string parameters from ANSI to wide, call wide function)

C:\work\repro\xxx\Debug>service_test.exe sörvis
 
C:\work\repro\xxx\Debug>sc query sörvis
[SC] EnumQueryServicesStatus:OpenService FAILED 1060:
 
The specified service does not exist as an installed service.
 
C:\work\repro\xxx\Debug> sc query sörvis
 
SERVICE_NAME: sörvis
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 1  STOPPED
        WIN32_EXIT_CODE    : 1077  (0x435)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0
 
C:\work\repro\xxx\Debug> sc delete sörvis
[SC] DeleteService SUCCESS


Generated at Thu Feb 08 09:50:16 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.