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

Fix #1077: Deprecate Mozc_tsf_ui.log #1078

Merged
merged 1 commit into from
Oct 15, 2024

Conversation

yukawa
Copy link
Collaborator

@yukawa yukawa commented Oct 14, 2024

Description

This is a quick fix for #1077.

While #1077 itself is not the root cause of #1076, merging this commit would also help debugging #1076 with debug builds.

Issue IDs

#1077

Steps to test new behaviors

A clear and concise description about how to verify new behaviors.

  • OS: Windows 11 23H2
  • Steps:
    1. Create and install a debug version of Mozc64.msi
    2. Build and launch the following app.
    3. Select Mozc
#include <windows.h>

int WINAPI wWinMain(HINSTANCE instance_handle, HINSTANCE prev_instance_handle,
                    PWSTR command_line, int command_show) {
  const wchar_t window_class_name[] = L"Test Window Class";
  {
    const WNDCLASS wc = {
        .lpfnWndProc = [](HWND window_handle, UINT message,
                          auto... params) -> LRESULT {
          if (message == WM_DESTROY) {
            ::PostQuitMessage(0);
            return 0;
          }
          return ::DefWindowProc(window_handle, message, params...);
        },
        .hInstance = instance_handle,
        .hbrBackground = (HBRUSH)(COLOR_WINDOW + 1),
        .lpszClassName = window_class_name,
    };
    ::RegisterClass(&wc);
  }

  const HWND window_handle = ::CreateWindowEx(
      0, window_class_name, L"Window Title", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
      CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, nullptr, nullptr,
      instance_handle, nullptr);

  if (window_handle == nullptr) {
    return 0;
  }

  ::ShowWindow(window_handle, command_show);

  while (true) {
    MSG message = {};
    if (::GetMessage(&message, nullptr, 0, 0) <= 0) {
      break;
    }
    ::TranslateMessage(&message);
    ::DispatchMessage(&message);
  }

  return 0;
}

Without this commit, the app crashes because of the same reason as #856.

This commit affects only mozc_tip{32,64}.dll build with debug mode.
There must be no behavior change in release build.

Currently 'Mozc_tsf_ui.log' is created only when NDEBUG is defined.
With this commit we stop creating it even when NDEBUG is defined.
This addresses a crash issue in debug builds discussed in google#1077.

See google#856 about why absl::LocalTimeZone cannot be used in Windows right
now.

Note that this commit may also help us diagnose google#1076, where
  Windows.Storage.OneCore.dll
looks to be intercepting certain Win32 file I/O API calls in
AppContainer processes then trigger RoInitialize as needed.
Creating 'Mozc_tsf_ui.log' only in debug builds can make our debugging
more complicated.
Copy link
Collaborator

@hiroyuki-komatsu hiroyuki-komatsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi yukawa,
Thank you for your PR!

@@ -511,8 +510,6 @@ class TipTextServiceImpl
StorePointerForCurrentThread(this);

HRESULT result = E_UNEXPECTED;
RegisterLogFileSink(
FileUtil::JoinPath(SystemUtil::GetLoggingDirectory(), kLogFileName));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about commenting out them with a note why the log is not stored into a file?

Copy link
Collaborator Author

@yukawa yukawa Oct 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm actually wondering if we can permanently deprecate the log file, as it's not reliable (we cannot write file from AppContainer process) and I suspect no one is checking it as it is only available in debug build. At least I in general do not rely on log files for debugging.

Are you still using *.log from other processes? I'm actually leaning towards deprecating other logging files, but it's a separate discussion after fixing this obvious crash bug.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine to permanently deprecate the log file.
I'd like to prevent anyone from creating the log file again in the future, since it may cause the crash issue again.

So adding a note instead of the comment out is also fine with me.

@hiroyuki-komatsu hiroyuki-komatsu merged commit 7be5a73 into google:master Oct 15, 2024
1 check passed
@yukawa yukawa deleted the issue_1077 branch October 15, 2024 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants