google / mozc

Mozc - a Japanese Input Method Editor designed for multi-platform
Other
2.44k stars 361 forks source link

ibus-engine-mozc aborts when mozc_renderer dies #814

Closed akihikodaki closed 1 year ago

akihikodaki commented 1 year ago

Description

ibus-engine-mozc aborts when mozc_renderer dies.

Steps to reproduce

I have not figured out the exact reproduction procedure.

Expected behavior

ibus-engine-mozc should not abort.

Actual behavior

ibus-engine-mozc should aborts.

Screenshots

Not applicable

Version or commit-id

2.29.5200.102

Environment

Investigations

Additional context

Below is the backtrace:

#0  __pthread_kill_implementation (threadid=281470039683136, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1  0x0000fffedbfd27e4 in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
#2  0x0000fffedbf8b6fc in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3  0x0000fffedbf778b0 in __GI_abort () at abort.c:79
#4  0x0000fffedbfc633c in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0xfffedc0ab108 "*** %s ***: terminated\n") at ../sysdeps/posix/libc_fatal.c:155
#5  0x0000fffedc04a698 in __GI___fortify_fail (msg=msg@entry=0xfffedc0ab0a0 "buffer overflow detected") at fortify_fail.c:26
#6  0x0000fffedc048dc4 in __GI___chk_fail () at chk_fail.c:28
#7  0x0000fffedc04a5dc in __fdelt_chk (d=<optimized out>) at fdelt_chk.c:25
#8  0x0000aaab9cfe8c98 in mozc::(anonymous namespace)::IsWriteTimeout (timeout=..., socket=-1) at ipc/unix_ipc.cc:106
#9  mozc::(anonymous namespace)::SendMessage(int, std::string const&, absl::lts_20230125::Duration)
    (socket=-1, msg="\b\001\020\001\032\217\001\búτ\332ǖ߹\001\020\001\030\001*\024\b\001\023\030\001\"\003あ(\0012\003あ\024 \0002<\020\001\033 \000*\003あ:\016\032\fひらがなH\000\0340\000X\002`\000j\024\n\022Tabキーで選択\220\001\tj\006\b\001\020\001\030\001r\037\022\033\b\000\020\000\"\003あ*\016\032\fひらがな8\001\030\002\272\001\000\"\f\b\344\004\020\356\t\030\344\004 \207\n*\024\b\267\221\0010\004j\fSansSerif 11", timeout=...) at ipc/unix_ipc.cc:144
#10 0x0000aaab9cfea6c4 in mozc::IPCClient::Call(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, absl::lts_20230125::Duration)
    (this=0xfffec80012c0, request=<optimized out>, response=0xfffed9bae568, timeout=...) at ipc/unix_ipc.cc:307
#11 0x0000aaab9cfe088c in mozc::renderer::(anonymous namespace)::CallCommand(mozc::IPCClientInterface*, mozc::commands::RendererCommand const&) (client=0xfffec80012c0, command=...) at renderer/renderer_client.cc:81
#12 0x0000aaab9cfe1fe0 in mozc::renderer::RendererLauncher::FlushPendingCommand() (this=this@entry=0xaaabd925b300) at /usr/lib/gcc/aarch64-unknown-linux-gnu/12.1.0/../../../../include/c++/12.1.0/optional:306
#13 0x0000aaab9cfe22cc in mozc::renderer::RendererLauncher::ThreadMain() (this=0xaaabd925b300) at renderer/renderer_client.cc:279
#14 0x0000aaab9cfe2ec8 in mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}::operator()() const (__closure=0xaaabd92b5468) at renderer/renderer_client.cc:116
#15 std::__invoke_impl<void, mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}>(std::__invoke_other, mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}&&) (__f=...) at /usr/lib/gcc/aarch64-unknown-linux-gnu/12.1.0/../../../../include/c++/12.1.0/bits/invoke.h:61
#16 std::__invoke<mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}>(mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}&&) (__fn=...) at /usr/lib/gcc/aarch64-unknown-linux-gnu/12.1.0/../../../../include/c++/12.1.0/bits/invoke.h:96
#17 std::invoke<mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}>(mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}&&) (__fn=...) at /usr/lib/gcc/aarch64-unknown-linux-gnu/12.1.0/../../../../include/c++/12.1.0/functional:110
#18 absl::lts_20230125::functional_internal::Apply<void, absl::lts_20230125::container_internal::CompressedTuple<mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}>, 0ul>(absl::lts_20230125::container_internal::CompressedTuple<mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}>&&, absl::lts_20230125::integer_sequence<unsigned long, 0ul>) (bound=...) at external/com_google_absl/absl/functional/internal/front_binder.h:36
#19 absl::lts_20230125::functional_internal::FrontBinder<mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}>::operator()<, void>() && (this=0xaaabd92b5468) at external/com_google_absl/absl/functional/internal/front_binder.h:73
#20 std::__invoke_impl<void, absl::lts_20230125::functional_internal::FrontBinder<mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}>>(std::__invoke_other, absl::lts_20230125::functional_internal::FrontBinder<mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}>&&) (__f=...)
    at /usr/lib/gcc/aarch64-unknown-linux-gnu/12.1.0/../../../../include/c++/12.1.0/bits/invoke.h:61
#21 std::__invoke<absl::lts_20230125::functional_internal::FrontBinder<mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}>>(absl::lts_20230125::functional_internal::FrontBinder<mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}>&&) (__fn=...)
    at /usr/lib/gcc/aarch64-unknown-linux-gnu/12.1.0/../../../../include/c++/12.1.0/bits/invoke.h:96
#22 std::invoke<absl::lts_20230125::functional_internal::FrontBinder<mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}>>(absl::lts_20230125::functional_internal::FrontBinder<mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}>&&) (__fn=...)
    at /usr/lib/gcc/aarch64-unknown-linux-gnu/12.1.0/../../../../include/c++/12.1.0/functional:110
#23 mozc::BackgroundFuture<void>::BackgroundFuture<mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}>(mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}&&)::{lambda()#1}::operator()() (__closure=0xaaabd92b5460) at ./base/thread2.h:264
#24 std::__invoke_impl<void, mozc::BackgroundFuture<void>::BackgroundFuture<mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}>(mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}&&)::{lambda()#1}>(std::__invoke_other, mozc::BackgroundFuture<void>::BackgroundFuture<mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}>(mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}&&)::{lambda()#1}&&) (__f=...) at /usr/lib/gcc/aarch64-unknown-linux-gnu/12.1.0/../../../../include/c++/12.1.0/bits/invoke.h:61
#25 std::__invoke<mozc::BackgroundFuture<void>::BackgroundFuture<mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}>(mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}&&)::{lambda()#1}>(mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}&&) (__fn=...)
--Type <RET> for more, q to quit, c to continue without paging--c
    at /usr/lib/gcc/aarch64-unknown-linux-gnu/12.1.0/../../../../include/c++/12.1.0/bits/invoke.h:96
#26 std::invoke<mozc::BackgroundFuture<void>::BackgroundFuture<mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}>(mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}&&)::{lambda()#1}>(mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}&&) (__fn=...)
    at /usr/lib/gcc/aarch64-unknown-linux-gnu/12.1.0/../../../../include/c++/12.1.0/functional:110
#27 absl::lts_20230125::functional_internal::Apply<void, absl::lts_20230125::container_internal::CompressedTuple<mozc::BackgroundFuture<void>::BackgroundFuture<mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}>(mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}&&)::{lambda()#1}>, 0ul>(absl::lts_20230125::container_internal::CompressedTuple<mozc::BackgroundFuture<void>::BackgroundFuture<mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}>(mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}&&)::{lambda()#1}>&&, absl::lts_20230125::integer_sequence<unsigned long, 0ul>) (bound=...)
    at external/com_google_absl/absl/functional/internal/front_binder.h:36
#28 absl::lts_20230125::functional_internal::FrontBinder<mozc::BackgroundFuture<void>::BackgroundFuture<mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}>(mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}&&)::{lambda()#1}>::operator()<, void>() && (this=0xaaabd92b5460)
    at external/com_google_absl/absl/functional/internal/front_binder.h:73
#29 std::__invoke_impl<void, absl::lts_20230125::functional_internal::FrontBinder<mozc::BackgroundFuture<void>::BackgroundFuture<mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}>(mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}&&)::{lambda()#1}>>(std::__invoke_other, absl::lts_20230125::functional_internal::FrontBinder<mozc::BackgroundFuture<void>::BackgroundFuture<mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}>(mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}&&)::{lambda()#1}>&&) (__f=...) at /usr/lib/gcc/aarch64-unknown-linux-gnu/12.1.0/../../../../include/c++/12.1.0/bits/invoke.h:61
#30 std::__invoke<absl::lts_20230125::functional_internal::FrontBinder<mozc::BackgroundFuture<void>::BackgroundFuture<mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}>(mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}&&)::{lambda()#1}>>(mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}&&) (__fn=...)
    at /usr/lib/gcc/aarch64-unknown-linux-gnu/12.1.0/../../../../include/c++/12.1.0/bits/invoke.h:96
#31 std::invoke<absl::lts_20230125::functional_internal::FrontBinder<mozc::BackgroundFuture<void>::BackgroundFuture<mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}>(mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}&&)::{lambda()#1}>>(mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}&&) (__fn=...)
    at /usr/lib/gcc/aarch64-unknown-linux-gnu/12.1.0/../../../../include/c++/12.1.0/functional:110
#32 mozc::internal::FunctorThread<absl::lts_20230125::functional_internal::FrontBinder<mozc::BackgroundFuture<void>::BackgroundFuture<mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}>(mozc::renderer::RendererLauncher::StartRenderer(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, mozc::IPCClientFactoryInterface*)::{lambda()#1}&&)::{lambda()#1}> >::Run() (this=0xaaabd92b5450)
    at ./base/thread2.h:183
#33 0x0000aaab9cff0670 in mozc::Thread::WrapperForPOSIX(void*) (ptr=<optimized out>) at base/thread.cc:227
#34 0x0000fffedbfd0aec in start_thread (arg=0xffffc9f6529f) at pthread_create.c:442
#35 0x0000fffedc03a5dc in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:79

It seems FlushPendingCommand() forgets to check client.Connected().

yukawa commented 1 year ago

Looks like this is better to be handled in unix_ipc.cc. Unlike win32_ipc.cc and mach_ipc.cc, IPCClient::Call() implemented in unix_ipc.cc doesn't look to be able to gracefully return a failure when socket_ == kInvalidSocket.

https://github.com/google/mozc/blob/4de804ded35aff6c3bd7947fe3a6fd51d116c8dc/src/ipc/unix_ipc.cc#L304-L311

https://github.com/google/mozc/blob/4de804ded35aff6c3bd7947fe3a6fd51d116c8dc/src/ipc/unix_ipc.cc#L140-L160

https://github.com/google/mozc/blob/4de804ded35aff6c3bd7947fe3a6fd51d116c8dc/src/ipc/unix_ipc.cc#L99-L117

Here are what win32_ipc.cc and mach_ipc.cc are doing.

https://github.com/google/mozc/blob/4de804ded35aff6c3bd7947fe3a6fd51d116c8dc/src/ipc/win32_ipc.cc#L758-L765

https://github.com/google/mozc/blob/4de804ded35aff6c3bd7947fe3a6fd51d116c8dc/src/ipc/mach_ipc.cc#L249-L274