Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSI: Cannot launch worker process when a key with non-ASCII character exists just under SOFTWARE/Microsoft/Windows/CurrentVersion/Uninstall/ registry #616

Closed
tbs575 opened this issue Jun 14, 2023 · 11 comments · Fixed by #620
Labels
bug Something isn't working

Comments

@tbs575
Copy link

tbs575 commented Jun 14, 2023

Describe the bug

I am newbie. met error for log file with chinese character

To Reproduce

  • Installed td-agent 4.5
  • change config file
  • run command td-agent -c etc\td-agent\td-agent.conf
  • met error

sample log content:

[2023:06:13 00:00:00][INFO]请求:{"Parkcode":"510105037"}
[2023:06:13 00:00:00][INFO]返回:{"State":0,"Desc":"成功","Result":[{"num":"2032","garagecode":"1"}]}
[2023:06:13 00:00:00][INFO]开时校时...

Expected behavior

how to fixed?

Your Environment

- Fluentd version:
- TD Agent version: 4.5
- Operating system: Windows 10
- Kernel version:

Your Configuration

<source>
  @type tail
  path d:\test\logs\*.log
  tag apache.access
  encoding UTF-8
  from_encoding UTF-8
  <parse>
    @type apache2
  </parse>
  <storage>
    @type local
    persistent true
    path C:\opt\td-agent\winlog.json
  </storage>
</source>

<match winevt.raw>
  @type stdout
</match>

Your Error Log

2023-06-14 16:40:40 +0800 [info]: init supervisor logger path=nil rotate_age=nil rotate_size=nil
2023-06-14 16:40:40 +0800 [info]: parsing config file is succeeded path="etc\\td-agent\\td-agent.conf"
2023-06-14 16:40:40 +0800 [info]: gem 'fluent-plugin-calyptia-monitoring' version '0.1.3'
2023-06-14 16:40:40 +0800 [info]: gem 'fluent-plugin-elasticsearch' version '5.3.0'
2023-06-14 16:40:40 +0800 [info]: gem 'fluent-plugin-flowcounter-simple' version '0.1.0'
2023-06-14 16:40:40 +0800 [info]: gem 'fluent-plugin-kafka' version '0.19.0'
2023-06-14 16:40:40 +0800 [info]: gem 'fluent-plugin-metrics-cmetrics' version '0.1.2'
2023-06-14 16:40:40 +0800 [info]: gem 'fluent-plugin-opensearch' version '1.1.0'
2023-06-14 16:40:40 +0800 [info]: gem 'fluent-plugin-parser-winevt_xml' version '0.2.5'
2023-06-14 16:40:40 +0800 [info]: gem 'fluent-plugin-prometheus' version '2.0.3'
2023-06-14 16:40:40 +0800 [info]: gem 'fluent-plugin-prometheus_pushgateway' version '0.1.0'
2023-06-14 16:40:40 +0800 [info]: gem 'fluent-plugin-record-modifier' version '2.1.1'
2023-06-14 16:40:40 +0800 [info]: gem 'fluent-plugin-rewrite-tag-filter' version '2.4.0'
2023-06-14 16:40:40 +0800 [info]: gem 'fluent-plugin-s3' version '1.7.2'
2023-06-14 16:40:40 +0800 [info]: gem 'fluent-plugin-sd-dns' version '0.1.0'
2023-06-14 16:40:40 +0800 [info]: gem 'fluent-plugin-td' version '1.2.0'
2023-06-14 16:40:40 +0800 [info]: gem 'fluent-plugin-webhdfs' version '1.5.0'
2023-06-14 16:40:40 +0800 [info]: gem 'fluent-plugin-windows-eventlog' version '0.8.3'
2023-06-14 16:40:40 +0800 [info]: gem 'fluent-plugin-windows-exporter' version '1.0.0'
2023-06-14 16:40:40 +0800 [info]: gem 'fluentd' version '1.16.1'
2023-06-14 16:40:40 +0800 [warn]: 'pos_file PATH' parameter is not set to a 'tail' source.
2023-06-14 16:40:40 +0800 [warn]: this parameter is highly recommended to save the position to resume tailing.
2023-06-14 16:40:40 +0800 [warn]: 'encoding' and 'from_encoding' are same encoding. No effect
2023-06-14 16:40:40 +0800 [info]: using configuration file: <ROOT>
  <source>
    @type tail
    path "d:\\test\\logs\\*.log"
    tag "apache.access"
    encoding "UTF-8"
    from_encoding "UTF-8"
    <parse>
      @type "apache2"
      unmatched_lines
    </parse>
    <storage>
      @type local
      persistent true
      path C:\opt\td-agent\winlog.json
    </storage>
  </source>
  <match winevt.raw>
    @type stdout
  </match>
</ROOT>
2023-06-14 16:40:40 +0800 [info]: starting fluentd-1.16.1 pid=6432 ruby="2.7.8"
2023-06-14 16:40:40 +0800 [info]: spawn command to main:  cmdline=["C:/opt/td-agent/bin/ruby.exe", "-Eascii-8bit:ascii-8bit", "C:/opt/td-agent/bin/fluentd", "-c", "etc\\td-agent\\td-agent.conf", "--under-supervisor"]
Traceback (most recent call last):
        17: from <internal:gem_prelude>:1:in `<internal:gem_prelude>'
        16: from <internal:gem_prelude>:1:in `require'
        15: from C:/opt/td-agent/lib/ruby/2.7.0/rubygems.rb:1427:in `<top (required)>'
        14: from C:/opt/td-agent/lib/ruby/2.7.0/rubygems.rb:1427:in `require'
        13: from C:/opt/td-agent/lib/ruby/2.7.0/rubygems/defaults/operating_system.rb:24:in `<top (required)>'
        12: from C:/opt/td-agent/lib/ruby/site_ruby/2.7.0/ruby_installer/runtime/singleton.rb:27:in `enable_dll_search_paths'
        11: from C:/opt/td-agent/lib/ruby/site_ruby/2.7.0/ruby_installer/runtime/msys2_installation.rb:125:in `enable_dll_search_paths'
        10: from C:/opt/td-agent/lib/ruby/site_ruby/2.7.0/ruby_installer/runtime/msys2_installation.rb:115:in `mingw_bin_path'
         9: from C:/opt/td-agent/lib/ruby/site_ruby/2.7.0/ruby_installer/runtime/msys2_installation.rb:102:in `msys_path'
         8: from C:/opt/td-agent/lib/ruby/site_ruby/2.7.0/ruby_installer/runtime/msys2_installation.rb:68:in `iterate_msys_paths'
         7: from C:/opt/td-agent/lib/ruby/site_ruby/2.7.0/ruby_installer/runtime/msys2_installation.rb:68:in `each'
         6: from C:/opt/td-agent/lib/ruby/site_ruby/2.7.0/ruby_installer/runtime/msys2_installation.rb:70:in `block in iterate_msys_paths'
         5: from C:/opt/td-agent/lib/ruby/2.7.0/win32/registry.rb:542:in `open'
         4: from C:/opt/td-agent/lib/ruby/2.7.0/win32/registry.rb:435:in `open'
         3: from C:/opt/td-agent/lib/ruby/site_ruby/2.7.0/ruby_installer/runtime/msys2_installation.rb:71:in `block (2 levels) in iterate_msys_paths'
         2: from C:/opt/td-agent/lib/ruby/2.7.0/win32/registry.rb:611:in `each_key'
         1: from C:/opt/td-agent/lib/ruby/2.7.0/win32/registry.rb:910:in `export_string'
C:/opt/td-agent/lib/ruby/2.7.0/win32/registry.rb:910:in `encode': U+767E to ASCII-8BIT in conversion from UTF-16LE to UTF-8 to ASCII-8BIT (Encoding::UndefinedConversionError)
2023-06-14 16:40:41 +0800 [error]: Worker 0 exited unexpectedly with status 1
Traceback (most recent call last):
        17: from <internal:gem_prelude>:1:in `<internal:gem_prelude>'
        16: from <internal:gem_prelude>:1:in `require'
        15: from C:/opt/td-agent/lib/ruby/2.7.0/rubygems.rb:1427:in `<top (required)>'
        14: from C:/opt/td-agent/lib/ruby/2.7.0/rubygems.rb:1427:in `require'
        13: from C:/opt/td-agent/lib/ruby/2.7.0/rubygems/defaults/operating_system.rb:24:in `<top (required)>'
        12: from C:/opt/td-agent/lib/ruby/site_ruby/2.7.0/ruby_installer/runtime/singleton.rb:27:in `enable_dll_search_paths'
        11: from C:/opt/td-agent/lib/ruby/site_ruby/2.7.0/ruby_installer/runtime/msys2_installation.rb:125:in `enable_dll_search_paths'
        10: from C:/opt/td-agent/lib/ruby/site_ruby/2.7.0/ruby_installer/runtime/msys2_installation.rb:115:in `mingw_bin_path'
         9: from C:/opt/td-agent/lib/ruby/site_ruby/2.7.0/ruby_installer/runtime/msys2_installation.rb:102:in `msys_path'
         8: from C:/opt/td-agent/lib/ruby/site_ruby/2.7.0/ruby_installer/runtime/msys2_installation.rb:68:in `iterate_msys_paths'
         7: from C:/opt/td-agent/lib/ruby/site_ruby/2.7.0/ruby_installer/runtime/msys2_installation.rb:68:in `each'
         6: from C:/opt/td-agent/lib/ruby/site_ruby/2.7.0/ruby_installer/runtime/msys2_installation.rb:70:in `block in iterate_msys_paths'
         5: from C:/opt/td-agent/lib/ruby/2.7.0/win32/registry.rb:542:in `open'
         4: from C:/opt/td-agent/lib/ruby/2.7.0/win32/registry.rb:435:in `open'
         3: from C:/opt/td-agent/lib/ruby/site_ruby/2.7.0/ruby_installer/runtime/msys2_installation.rb:71:in `block (2 levels) in iterate_msys_paths'
         2: from C:/opt/td-agent/lib/ruby/2.7.0/win32/registry.rb:611:in `each_key'
         1: from C:/opt/td-agent/lib/ruby/2.7.0/win32/registry.rb:910:in `export_string'
C:/opt/td-agent/lib/ruby/2.7.0/win32/registry.rb:910:in `encode': U+767E to ASCII-8BIT in conversion from UTF-16LE to UTF-8 to ASCII-8BIT (Encoding::UndefinedConversionError)
2023-06-14 16:40:41 +0800 [error]: Worker 0 exited unexpectedly with status 1

Additional context

No response

@daipom
Copy link
Contributor

daipom commented Jun 14, 2023

Thanks for your report!

Hmm, does this always occur in a Chinese Windows environment?
From the error logs, it may be a problem that some dll have Chinese characters in their paths.

@ashie
Copy link
Member

ashie commented Jun 16, 2023

https://github.com/oneclick/rubyinstaller2/blob/1037499985fcaff2c471e88ed254a7b698e508f6/lib/ruby_installer/build/msys2_installation.rb#L61-L84
https://github.com/ruby/ruby/blob/364a6d56d776270da09604816d623047c66c5e32/ext/win32/lib/win32/registry.rb#L596C6-L616

Hmm, your registry includes a key with non-ASCII character under SOFTWARE/Microsoft/Windows/CurrentVersion/Uninstall/.
Typical keys under it is UUID but some applications seem register keys with it's application name (e.g. 7-zip).
So that it seems that we should assume non-ASCII characters are included under it.
But it doesn't seem work with current implementation because we use -Eascii-8bit:ascii-8bit at runtime.

@ashie ashie added the bug Something isn't working label Jun 16, 2023
@ashie
Copy link
Member

ashie commented Jun 16, 2023

Hmm, I've tried with a such sub key but I can't reproduce it.

@tbs575
Copy link
Author

tbs575 commented Jun 21, 2023

4.5 bug on chinese windows

As tested, met this issue on version 4.5 without any logs operation.
In chinese windows, install version 4.5, and just startup td-agent directly, met error as first comment

met new issue

On version 4.4.2, can startup without any issue, but try to handle logs with chinese character, met error

2023-06-21 09:45:38 +0800 [warn]: #0 fluent/log.rb:351:warn: invalid line found file="D:/test/cars/2023-06-19-car.info.log" line="[2023:06:19 23:59:58][INFO]\xE5\xB1\x8F[172.16.69.10[\xE5\xB1\x8F]]\xE6\x95\xB0\xE6\x8D\xAE[16]\xE5\x8F\x91\xE9\x80\x81\xE6\x88\x90\xE5\x8A\x9F" error="incompatible encoding regexp match (UTF-8 regexp with ASCII-8BIT string)"
  2023-06-21 09:45:38 +0800 [debug]: #0 plugin/in_tail.rb:651:each: suppressed same stacktrace

log file encode

2023-06-19-car.info.log: Unicode text, UTF-8 (with BOM) text, with CRLF line terminators

my config

<source>
  @type tail
  path D:/test/cars/*.log
  tag yibo
  pos_file d:/test/1.log
  read_from_head true
  <parse>
    @type regexp
    expression /^\[(?<logtime>[^\]]*)\]\[INFO\]源数据上报\[(?<data_json>[^\]]*\]).*$/
  </parse>
</source>

<match yibo>
  @type stdout
</match>

how to fix it,thanks

@hzilex
Copy link

hzilex commented Aug 1, 2023

I faced a similar issue on the chinese Windows. It was resolved by manually installing the MSYS2 to the default path (c:/msys64 or c:/msys32)

@batabatabatabata
Copy link

I also met the same issue on Japanese Windows.
Since it is caused by a Microsoft product, it seems that the code needs to be fixed as a bug in multilingual support.

@ashie
Copy link
Member

ashie commented Feb 9, 2024

Hmm, I've tried with a such sub key but I can't reproduce it.

I've got the reason.
It can't be reproduced when another MSYS2 is installed in default path (c:\msys64).
https://github.com/oneclick/rubyinstaller2/blob/1037499985fcaff2c471e88ed254a7b698e508f6/lib/ruby_installer/build/msys2_installation.rb#L48-L108

Now I've confirmed this bug.

@ashie
Copy link
Member

ashie commented Feb 9, 2024

You can avoid this bug by creating a following empty file:

  • td-agent: c:\opt\td-agent\msys64\usr\bin\msys-2.0.dll
  • fluent-package: c:\opt\fluent\msys64\usr\bin\msys-2.0.dll

@ashie
Copy link
Member

ashie commented Feb 13, 2024

I confirmed that all td-agent v4 & fluent-package v5 are affected, because it's reproduced with vanilla RubyInstaller 2.7.0 & 3.2.2 (& 3.3.0) too:

C:\Users\aho\Downloads\rubyinstaller-2.7.0-1-x64\bin>echo "require 'rubygems'" | ruby -Eascii-8bit:ascii-8bit
Traceback (most recent call last):
        15: from <internal:gem_prelude>:1:in `<internal:gem_prelude>'
        14: from <internal:gem_prelude>:1:in `require'
        13: from C:/Users/aho/Downloads/rubyinstaller-2.7.0-1-x64/lib/ruby/2.7.0/rubygems.rb:1397:in `<top (required)>'
        12: from C:/Users/aho/Downloads/rubyinstaller-2.7.0-1-x64/lib/ruby/2.7.0/rubygems.rb:1397:in `require'
        11: from C:/Users/aho/Downloads/rubyinstaller-2.7.0-1-x64/lib/ruby/2.7.0/rubygems/defaults/operating_system.rb:3:in `<top (required)>'
        10: from C:/Users/aho/Downloads/rubyinstaller-2.7.0-1-x64/lib/ruby/site_ruby/2.7.0/ruby_installer/runtime/singleton.rb:27:in `enable_dll_search_paths'
         9: from C:/Users/aho/Downloads/rubyinstaller-2.7.0-1-x64/lib/ruby/site_ruby/2.7.0/ruby_installer/runtime/msys2_installation.rb:99:in `enable_dll_search_paths'
         8: from C:/Users/aho/Downloads/rubyinstaller-2.7.0-1-x64/lib/ruby/site_ruby/2.7.0/ruby_installer/runtime/msys2_installation.rb:89:in `mingw_bin_path'
         7: from C:/Users/aho/Downloads/rubyinstaller-2.7.0-1-x64/lib/ruby/site_ruby/2.7.0/ruby_installer/runtime/msys2_installation.rb:76:in `msys_path'
         6: from C:/Users/aho/Downloads/rubyinstaller-2.7.0-1-x64/lib/ruby/site_ruby/2.7.0/ruby_installer/runtime/msys2_installation.rb:48:in `iterate_msys_paths'
         5: from C:/Users/aho/Downloads/rubyinstaller-2.7.0-1-x64/lib/ruby/2.7.0/win32/registry.rb:542:in `open'
         4: from C:/Users/aho/Downloads/rubyinstaller-2.7.0-1-x64/lib/ruby/2.7.0/win32/registry.rb:435:in `open'
         3: from C:/Users/aho/Downloads/rubyinstaller-2.7.0-1-x64/lib/ruby/site_ruby/2.7.0/ruby_installer/runtime/msys2_installation.rb:49:in `block in iterate_msys_paths'
         2: from C:/Users/aho/Downloads/rubyinstaller-2.7.0-1-x64/lib/ruby/2.7.0/win32/registry.rb:611:in `each_key'
         1: from C:/Users/aho/Downloads/rubyinstaller-2.7.0-1-x64/lib/ruby/2.7.0/win32/registry.rb:910:in `export_string'
C:/Users/aho/Downloads/rubyinstaller-2.7.0-1-x64/lib/ruby/2.7.0/win32/registry.rb:910:in `encode': U+3042 to ASCII-8BIT in conversion from UTF-16LE to UTF-8 to ASCII-8BIT (Encoding::UndefinedConversionError)

@ashie
Copy link
Member

ashie commented Feb 13, 2024

This should be treated in fluent-pakckage-builder project.

@ashie ashie transferred this issue from fluent/fluentd Feb 13, 2024
@ashie ashie changed the title met error with chinese char’s log file MSI: Cannot run worker process when a key with non-ASCII character existi in SOFTWARE/Microsoft/Windows/CurrentVersion/Uninstall/ Registry Feb 13, 2024
@ashie ashie changed the title MSI: Cannot run worker process when a key with non-ASCII character existi in SOFTWARE/Microsoft/Windows/CurrentVersion/Uninstall/ Registry MSI: Cannot launch worker process when a key with non-ASCII character exists in SOFTWARE/Microsoft/Windows/CurrentVersion/Uninstall/ Registry Feb 13, 2024
@ashie ashie changed the title MSI: Cannot launch worker process when a key with non-ASCII character exists in SOFTWARE/Microsoft/Windows/CurrentVersion/Uninstall/ Registry MSI: Cannot launch worker process when a key with non-ASCII character exists just under SOFTWARE/Microsoft/Windows/CurrentVersion/Uninstall/ registry Feb 13, 2024
@ashie
Copy link
Member

ashie commented Feb 13, 2024

I want to fix it in upstream, but I'm not sure where to report it yet.

The codes which causes this issue:

RubyInstaller2:

Ruby:

In addition, we should add work around for this issue until it's addressed in upstream.
Probably we can apply a patch to RubyInstaller by the following code:

# Patch files are assumed to be for Ruby's source tree, then applied to
# lib/ruby/x.y.0 in RubyInstaller. So that "-p2" options will be passed
# to patch command.
BUNDLED_RUBY_INSTALLER_PATCHES = [
# An example entry:
# ["ruby-3.0/0001-ruby-resolv-Fix-confusion-of-received-response-messa.patch", ["= 3.0.1"]],
]

It would be better to treat only MSYS2 which is installed under C:\opt\fluent, it can be realized easily by adding return here.

ashie added a commit that referenced this issue Feb 16, 2024
When a non-ASCII key exists under the registry key
`SOFTWARE/Microsoft/Windows/CurrentVersion/Uninstall/`, Fluentd fails to
start workers due to `Encoding::UndefinedConversionError`.
This patch avoid this issue.

Fix #616

Signed-off-by: Takuro Ashie <ashie@clear-code.com>
ashie added a commit that referenced this issue Feb 16, 2024
When a non-ASCII key exists under the registry key
`SOFTWARE/Microsoft/Windows/CurrentVersion/Uninstall/`, Fluentd fails to
start workers due to `Encoding::UndefinedConversionError`.
This patch avoid this issue.

Fix #616

Signed-off-by: Takuro Ashie <ashie@clear-code.com>
ashie added a commit that referenced this issue Feb 16, 2024
When a non-ASCII key exists under the registry key
`SOFTWARE/Microsoft/Windows/CurrentVersion/Uninstall/`, Fluentd fails to
start workers due to `Encoding::UndefinedConversionError`.
This patch avoid this issue.

Fix #616

Signed-off-by: Takuro Ashie <ashie@clear-code.com>
ashie added a commit that referenced this issue Feb 16, 2024
When a non-ASCII key exists under the registry key
`SOFTWARE/Microsoft/Windows/CurrentVersion/Uninstall/`, Fluentd fails to
start workers due to `Encoding::UndefinedConversionError`.
This patch avoid this issue.

Fix #616

Signed-off-by: Takuro Ashie <ashie@clear-code.com>
ashie added a commit that referenced this issue Feb 16, 2024
When a non-ASCII key exists under the registry key
`SOFTWARE/Microsoft/Windows/CurrentVersion/Uninstall/`, Fluentd fails to
start workers due to `Encoding::UndefinedConversionError`.
This patch avoid this issue.

Fix #616

Signed-off-by: Takuro Ashie <ashie@clear-code.com>
ashie added a commit that referenced this issue Feb 16, 2024
When a non-ASCII key exists under the registry key
`SOFTWARE/Microsoft/Windows/CurrentVersion/Uninstall/`, Fluentd fails to
start workers due to `Encoding::UndefinedConversionError`.
This patch avoid this issue.

Fix #616

Signed-off-by: Takuro Ashie <ashie@clear-code.com>
ashie added a commit that referenced this issue Feb 16, 2024
When a non-ASCII key exists under the registry key
`SOFTWARE/Microsoft/Windows/CurrentVersion/Uninstall/`, Fluentd fails to
start workers due to `Encoding::UndefinedConversionError`.
This patch avoid this issue.

Fix #616

Signed-off-by: Takuro Ashie <ashie@clear-code.com>
ashie added a commit that referenced this issue Feb 20, 2024
When a non-ASCII key exists under the registry key
`SOFTWARE/Microsoft/Windows/CurrentVersion/Uninstall/`, Fluentd fails to
start workers due to `Encoding::UndefinedConversionError`.
This patch avoid this issue.

Fix #616

Signed-off-by: Takuro Ashie <ashie@clear-code.com>
ashie added a commit that referenced this issue Feb 22, 2024
When a non-ASCII key exists under the registry key
`SOFTWARE/Microsoft/Windows/CurrentVersion/Uninstall/`, Fluentd fails to
start workers due to `Encoding::UndefinedConversionError`.
This patch avoid this issue.

Fix #616

Signed-off-by: Takuro Ashie <ashie@clear-code.com>
kenhys pushed a commit that referenced this issue Feb 22, 2024
When a non-ASCII key exists under the registry key
`SOFTWARE/Microsoft/Windows/CurrentVersion/Uninstall/`, Fluentd fails to
start workers due to `Encoding::UndefinedConversionError`. This patch
avoid this issue.

Fix #616

Signed-off-by: Takuro Ashie <ashie@clear-code.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants