pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Patches for UCRT/DLL memory corruption+libtirpc debugging, 2024-03-15
Posted by Anonymous on Fri 15th Mar 2024 16:40
raw | new post

  1. From 1a333b69cd275b74cc7efe32764894c024e4b08f Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Fri, 15 Mar 2024 14:17:33 +0100
  4. Subject: [PATCH 1/2] Link VC19 runtime dynamically to avoid inter-DLL memory
  5.  allocator corruptions
  6.  
  7. Link VC19 runtime dynamically to avoid inter-DLL memory allocator
  8. corruptions/crashes.
  9.  
  10. Users reported strange crashes with Linux v6.6 LTS as NFSv4.1 nfsd
  11. server (reproduced with Linux v6.6.20-rt25 nfsd) like this:
  12. -------- snip --------
  13. 19d4: callbody: rpcvers 2 cb_prog 9048 cb_vers 1 cb_proc 1
  14. 19d4: cb: replying to xid 787983544
  15. Debug Assertion Failed!
  16.  
  17. Program: ...ms-nfs41-client\destdir\cygdrive\c\cygwin64\sbin\libtirpc.dll
  18. File: minkernel\crts\ucrt\src\appcrt\heap\debug_heap.cpp
  19. Line: 996
  20.  
  21. Expression: __acrt_first_block == header
  22. -------- snip --------
  23.  
  24. Stack trace of the assertion looks like this:
  25. -------- snip --------
  26. 0:049> kp
  27. Call Site
  28. libtirpc!free_dbg_nolock(void * block = 0x000001cd`70fa5080, int block_use = 0n1)+0x6ef [minkernel\crts\ucrt\src\appcrt\heap\debug_heap.cpp @ 996]
  29. libtirpc!_free_dbg(void * block = 0x000001cd`70fa5080, int block_use = 0n1)+0x55 [minkernel\crts\ucrt\src\appcrt\heap\debug_heap.cpp @ 1030]
  30. libtirpc!xdr_array(struct __rpc_xdr * xdrs = 0x000001cd`708cab10, char ** addrp = 0x000001cd`70870f78, unsigned int * sizep = 0x000001cd`70870f80, unsigned int maxsize = 0x10, unsigned  int elsize = 0x960, <function> * elproc = 0x00007ff6`d9f598d0)+0x199 [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\libtirpc\src\xdr_array.c @ 123]
  31. nfsd!proc_cb_compound_res(struct __rpc_xdr * xdr = 0x000001cd`708cab10, struct cb_compound_res * res = 0x000001cd`70870f30)+0xd4 [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ ms-nfs41-client\daemon\callback_xdr.c @ 648]
  32. libtirpc!clnt_cb_thread(void * args = 0x000001cd`70891ef0)+0x52e [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\libtirpc\src\clnt_vc.c @ 300]
  33. libtirpc!thread_start<unsigned int (void * parameter = 0x000001cd`70881170)+0xb0 [minkernel\crts\ucrt\src\appcrt\startup\thread.cpp @ 97]
  34. KERNEL32!BaseThreadInitThunk+0x14
  35. ntdll!RtlUserThreadStart+0x21
  36. -------- snip --------
  37.  
  38. This causes because libtirpc tries to |free()| memory allocated
  39. by nfsd, both use statically linked ucrt-based allocators, but
  40. the allocation from nfsd is not recognised by libtirpc's allocator,
  41. hence triggering the assertion.
  42.  
  43. This was caused by commit #c6d07dd6386a46aa6d37e0509983befb69548db9
  44. ("Link VC19 runtime libraries statically"), so we back this
  45. commit out and just use the VC19 runtime as DLL - as result we
  46. have only one allocator, and not multiple per-DLL/*.exe allocators.
  47.  
  48. Reviewed-by: Dan Shelton <dan.f.shelton@gmail.com>
  49. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  50. ---
  51. build.vc19/libtirpc/libtirpc.vcxproj       | 4 ----
  52.  build.vc19/nfs41_np/nfs41_np.vcxproj       | 4 ----
  53.  build.vc19/nfs_install/nfs_install.vcxproj | 4 ----
  54.  build.vc19/nfs_mount/nfs_mount.vcxproj     | 4 ----
  55.  build.vc19/nfsd/nfsd.vcxproj               | 4 ----
  56.  cygwin/Makefile                            | 9 +++++++++
  57.  6 files changed, 9 insertions(+), 20 deletions(-)
  58.  
  59. diff --git a/build.vc19/libtirpc/libtirpc.vcxproj b/build.vc19/libtirpc/libtirpc.vcxproj
  60. index ed88d3e..da272de 100644
  61. --- a/build.vc19/libtirpc/libtirpc.vcxproj
  62. +++ b/build.vc19/libtirpc/libtirpc.vcxproj
  63. @@ -90,7 +90,6 @@
  64.        <PreprocessorDefinitions>FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;PORTMAP;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;UNICODE;_UNICODE;_DEBUG;_WINDOWS;_USRDLL;LIBTIRPC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  65.        <AdditionalIncludeDirectories>..\..\libtirpc\tirpc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
  66.        <LanguageStandard_C>stdc17</LanguageStandard_C>
  67. -      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
  68.        <StringPooling>true</StringPooling>
  69.        <BasicRuntimeChecks>Default</BasicRuntimeChecks>
  70.        <BufferSecurityCheck>false</BufferSecurityCheck>
  71. @@ -111,7 +110,6 @@
  72.        <PreprocessorDefinitions>FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;PORTMAP;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;UNICODE;_UNICODE;_DEBUG;_WINDOWS;_USRDLL;LIBTIRPC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  73.        <AdditionalIncludeDirectories>..\..\libtirpc\tirpc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
  74.        <LanguageStandard_C>stdc17</LanguageStandard_C>
  75. -      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
  76.        <StringPooling>true</StringPooling>
  77.        <BasicRuntimeChecks>Default</BasicRuntimeChecks>
  78.        <BufferSecurityCheck>false</BufferSecurityCheck>
  79. @@ -134,7 +132,6 @@
  80.        <PreprocessorDefinitions>FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;PORTMAP;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;UNICODE;_UNICODE;NDEBUG;_WINDOWS;_USRDLL;LIBTIRPC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  81.        <AdditionalIncludeDirectories>..\..\libtirpc\tirpc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
  82.        <LanguageStandard_C>stdc17</LanguageStandard_C>
  83. -      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
  84.        <StringPooling>true</StringPooling>
  85.        <BufferSecurityCheck>false</BufferSecurityCheck>
  86.      </ClCompile>
  87. @@ -158,7 +155,6 @@
  88.        <PreprocessorDefinitions>FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;PORTMAP;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;UNICODE;_UNICODE;NDEBUG;_WINDOWS;_USRDLL;LIBTIRPC_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  89.        <AdditionalIncludeDirectories>..\..\libtirpc\tirpc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
  90.        <LanguageStandard_C>stdc17</LanguageStandard_C>
  91. -      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
  92.        <StringPooling>true</StringPooling>
  93.        <BufferSecurityCheck>false</BufferSecurityCheck>
  94.      </ClCompile>
  95. diff --git a/build.vc19/nfs41_np/nfs41_np.vcxproj b/build.vc19/nfs41_np/nfs41_np.vcxproj
  96. index fb64eaa..eb515f0 100644
  97. --- a/build.vc19/nfs41_np/nfs41_np.vcxproj
  98. +++ b/build.vc19/nfs41_np/nfs41_np.vcxproj
  99. @@ -90,7 +90,6 @@
  100.        <PreprocessorDefinitions>WIN32;UNICODE;_UNICODE;_DEBUG;_WINDOWS;_USRDLL;NFS41_NP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  101.        <AdditionalIncludeDirectories>..\..\sys;..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
  102.        <LanguageStandard_C>stdc17</LanguageStandard_C>
  103. -      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
  104.      </ClCompile>
  105.      <Link>
  106.        <SubSystem>Windows</SubSystem>
  107. @@ -107,7 +106,6 @@
  108.        <PreprocessorDefinitions>WIN32;UNICODE;_UNICODE;_DEBUG;_WINDOWS;_USRDLL;NFS41_NP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  109.        <AdditionalIncludeDirectories>..\..\sys;..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
  110.        <LanguageStandard_C>stdc17</LanguageStandard_C>
  111. -      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
  112.      </ClCompile>
  113.      <Link>
  114.        <SubSystem>Windows</SubSystem>
  115. @@ -126,7 +124,6 @@
  116.        <PreprocessorDefinitions>WIN32;UNICODE;_UNICODE;NDEBUG;_WINDOWS;_USRDLL;NFS41_NP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  117.        <AdditionalIncludeDirectories>..\..\sys;..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
  118.        <LanguageStandard_C>stdc17</LanguageStandard_C>
  119. -      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
  120.      </ClCompile>
  121.      <Link>
  122.        <SubSystem>Windows</SubSystem>
  123. @@ -147,7 +144,6 @@
  124.        <PreprocessorDefinitions>WIN32;UNICODE;_UNICODE;NDEBUG;_WINDOWS;_USRDLL;NFS41_NP_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  125.        <AdditionalIncludeDirectories>..\..\sys;..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
  126.        <LanguageStandard_C>stdc17</LanguageStandard_C>
  127. -      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
  128.      </ClCompile>
  129.      <Link>
  130.        <SubSystem>Windows</SubSystem>
  131. diff --git a/build.vc19/nfs_install/nfs_install.vcxproj b/build.vc19/nfs_install/nfs_install.vcxproj
  132. index 17fa4ed..ce0b42a 100644
  133. --- a/build.vc19/nfs_install/nfs_install.vcxproj
  134. +++ b/build.vc19/nfs_install/nfs_install.vcxproj
  135. @@ -90,7 +90,6 @@
  136.        <PreprocessorDefinitions>WIN32;UNICODE;_UNICODE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  137.        <AdditionalIncludeDirectories>..\..\sys;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
  138.        <LanguageStandard_C>stdc17</LanguageStandard_C>
  139. -      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
  140.      </ClCompile>
  141.      <Link>
  142.        <SubSystem>Console</SubSystem>
  143. @@ -106,7 +105,6 @@
  144.        <PreprocessorDefinitions>WIN32;UNICODE;_UNICODE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  145.        <AdditionalIncludeDirectories>..\..\sys;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
  146.        <LanguageStandard_C>stdc17</LanguageStandard_C>
  147. -      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
  148.      </ClCompile>
  149.      <Link>
  150.        <SubSystem>Console</SubSystem>
  151. @@ -124,7 +122,6 @@
  152.        <PreprocessorDefinitions>WIN32;UNICODE;_UNICODE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  153.        <AdditionalIncludeDirectories>..\..\sys;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
  154.        <LanguageStandard_C>stdc17</LanguageStandard_C>
  155. -      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
  156.      </ClCompile>
  157.      <Link>
  158.        <SubSystem>Console</SubSystem>
  159. @@ -144,7 +141,6 @@
  160.        <PreprocessorDefinitions>WIN32;UNICODE;_UNICODE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  161.        <AdditionalIncludeDirectories>..\..\sys;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
  162.        <LanguageStandard_C>stdc17</LanguageStandard_C>
  163. -      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
  164.      </ClCompile>
  165.      <Link>
  166.        <SubSystem>Console</SubSystem>
  167. diff --git a/build.vc19/nfs_mount/nfs_mount.vcxproj b/build.vc19/nfs_mount/nfs_mount.vcxproj
  168. index 1da70a6..b3083da 100644
  169. --- a/build.vc19/nfs_mount/nfs_mount.vcxproj
  170. +++ b/build.vc19/nfs_mount/nfs_mount.vcxproj
  171. @@ -90,7 +90,6 @@
  172.        <PreprocessorDefinitions>WIN32;UNICODE;_UNICODE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  173.        <AdditionalIncludeDirectories>..\..\sys;..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
  174.        <LanguageStandard_C>stdc17</LanguageStandard_C>
  175. -      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
  176.      </ClCompile>
  177.      <Link>
  178.        <SubSystem>Console</SubSystem>
  179. @@ -107,7 +106,6 @@
  180.        <PreprocessorDefinitions>WIN32;UNICODE;_UNICODE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  181.        <AdditionalIncludeDirectories>..\..\sys;..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
  182.        <LanguageStandard_C>stdc17</LanguageStandard_C>
  183. -      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
  184.      </ClCompile>
  185.      <Link>
  186.        <SubSystem>Console</SubSystem>
  187. @@ -126,7 +124,6 @@
  188.        <PreprocessorDefinitions>WIN32;UNICODE;_UNICODE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  189.        <AdditionalIncludeDirectories>..\..\sys;..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
  190.        <LanguageStandard_C>stdc17</LanguageStandard_C>
  191. -      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
  192.      </ClCompile>
  193.      <Link>
  194.        <SubSystem>Console</SubSystem>
  195. @@ -147,7 +144,6 @@
  196.        <PreprocessorDefinitions>WIN32;UNICODE;_UNICODE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  197.        <AdditionalIncludeDirectories>..\..\sys;..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
  198.        <LanguageStandard_C>stdc17</LanguageStandard_C>
  199. -      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
  200.      </ClCompile>
  201.      <Link>
  202.        <SubSystem>Console</SubSystem>
  203. diff --git a/build.vc19/nfsd/nfsd.vcxproj b/build.vc19/nfsd/nfsd.vcxproj
  204. index aef30e9..ea755d1 100644
  205. --- a/build.vc19/nfsd/nfsd.vcxproj
  206. +++ b/build.vc19/nfsd/nfsd.vcxproj
  207. @@ -90,7 +90,6 @@
  208.        <PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;STANDALONE_NFSD;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;UNICODE;_UNICODE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  209.        <AdditionalIncludeDirectories>..\..\libtirpc\tirpc;..\..\sys;..\..\dll;..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
  210.        <LanguageStandard_C>stdc17</LanguageStandard_C>
  211. -      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
  212.        <BasicRuntimeChecks>Default</BasicRuntimeChecks>
  213.        <BufferSecurityCheck>false</BufferSecurityCheck>
  214.        <StringPooling>true</StringPooling>
  215. @@ -110,7 +109,6 @@
  216.        <PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;STANDALONE_NFSD;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;UNICODE;_UNICODE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  217.        <AdditionalIncludeDirectories>..\..\libtirpc\tirpc;..\..\sys;..\..\dll;..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
  218.        <LanguageStandard_C>stdc17</LanguageStandard_C>
  219. -      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
  220.        <BasicRuntimeChecks>Default</BasicRuntimeChecks>
  221.        <BufferSecurityCheck>false</BufferSecurityCheck>
  222.        <StringPooling>true</StringPooling>
  223. @@ -132,7 +130,6 @@
  224.        <PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;UNICODE;_UNICODE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  225.        <AdditionalIncludeDirectories>..\..\libtirpc\tirpc;..\..\sys;..\..\dll;..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
  226.        <LanguageStandard_C>stdc17</LanguageStandard_C>
  227. -      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
  228.        <BufferSecurityCheck>false</BufferSecurityCheck>
  229.        <StringPooling>true</StringPooling>
  230.      </ClCompile>
  231. @@ -155,7 +152,6 @@
  232.        <PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;FD_SETSIZE=1024;INET6;NO_CB_4_KRB5P;_CRT_SECURE_NO_WARNINGS;_WINSOCK_DEPRECATED_NO_WARNINGS;WIN32;UNICODE;_UNICODE;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  233.        <AdditionalIncludeDirectories>..\..\libtirpc\tirpc;..\..\sys;..\..\dll;..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
  234.        <LanguageStandard_C>stdc17</LanguageStandard_C>
  235. -      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
  236.        <BufferSecurityCheck>false</BufferSecurityCheck>
  237.        <StringPooling>true</StringPooling>
  238.      </ClCompile>
  239. diff --git a/cygwin/Makefile b/cygwin/Makefile
  240. index 4052c21..792d512 100644
  241. --- a/cygwin/Makefile
  242. +++ b/cygwin/Makefile
  243. @@ -98,6 +98,15 @@ installdest: $(VS_BUILD_DIR)/nfsd.exe \
  244.         @ printf "# Package ksh93&co (if available) since Cygwin does not ship with it yet\n"
  245.         [[ -x /usr/bin/ksh93.exe ]] && cp /usr/bin/ksh93.exe $(DESTDIR)/cygdrive/c/cygwin64/bin/ksh93.exe
  246.         [[ -x /usr/bin/shcomp.exe ]] && cp /usr/bin/shcomp.exe $(DESTDIR)/cygdrive/c/cygwin64/bin/shcomp.exe
  247. +       @ printf '# Packaging libs\n'
  248. +       ldd $$(find $(DESTDIR)/cygdrive/c/cygwin64/sbin/ -iname \*.exe -o -iname \*.dll) | \
  249. +               while read dummy1 dummy2 dllfile dummy3 ; do \
  250. +                       printf "%s\n" "$$dllfile" ; \
  251. +               done | \
  252. +               sort -f -u | grep -E -i '/cygdrive/c/Windows/.*(ucrt|vcrun)' | \
  253. +               while read i ; do \
  254. +                       cp "$$i" $(DESTDIR)/cygdrive/c/cygwin64/sbin/. ; \
  255. +               done
  256.         @ printf "# Set file flags\n"
  257.         (cd $(DESTDIR)/cygdrive/c/cygwin64/sbin/ && chmod a+x *.exe *.dll)
  258.         (cd $(DESTDIR)/cygdrive/c/cygwin64/lib/msnfs41client/ && chmod a+x *.dll)
  259. --
  260. 2.43.0
  261.  
  262. From 8071b366aad2ace49e72a730e201cd820c87eefa Mon Sep 17 00:00:00 2001
  263. From: Roland Mainz <roland.mainz@nrubsig.org>
  264. Date: Fri, 15 Mar 2024 14:21:19 +0100
  265. Subject: [PATCH 2/2] libtirpc: Improve debug messsages in |clnt_cb_thread()|
  266.  
  267. Improve debug messsages in |clnt_cb_thread()|
  268.  
  269. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  270. ---
  271. libtirpc/src/clnt_vc.c | 33 ++++++++++++++++++++++-----------
  272.  1 file changed, 22 insertions(+), 11 deletions(-)
  273.  
  274. diff --git a/libtirpc/src/clnt_vc.c b/libtirpc/src/clnt_vc.c
  275. index d2d4df0..17d900d 100644
  276. --- a/libtirpc/src/clnt_vc.c
  277. +++ b/libtirpc/src/clnt_vc.c
  278. @@ -209,7 +209,8 @@ static unsigned int WINAPI clnt_cb_thread(void *args)
  279.      struct rpc_msg reply_msg;
  280.      char cred_area[2 * MAX_AUTH_BYTES + RQCRED_SIZE];
  281.  
  282. -    fprintf(stderr/*stdout*/, "%04lx: Creating callback thread\n", (long)GetCurrentThreadId());
  283. +    (void)fprintf(stderr/*stdout*/,
  284. +        "%04lx: cb: Callback thread running\n", (long)GetCurrentThreadId());
  285.      while(1) {
  286.          cb_req header;
  287.          void *res = NULL;
  288. @@ -228,7 +229,9 @@ static unsigned int WINAPI clnt_cb_thread(void *args)
  289.         mutex_unlock(&clnt_fd_lock);
  290.  
  291.          if (cl->shutdown) {
  292. -            fprintf(stdout, "%04lx: callback received shutdown signal\n", (long)GetCurrentThreadId());
  293. +            (void)fprintf(stdout,
  294. +                "%04lx: cb: callback received shutdown signal\n",
  295. +                (long)GetCurrentThreadId());
  296.              release_fd_lock(ct->ct_fd, mask);
  297.              goto out;
  298.          }
  299. @@ -262,28 +265,33 @@ process_rpc_call:
  300.          ct->reply_msg.rm_call.cb_cred.oa_base = cred_area;
  301.          ct->reply_msg.rm_call.cb_verf.oa_base = &(cred_area[MAX_AUTH_BYTES]);
  302.          if (!xdr_getcallbody(xdrs, &ct->reply_msg)) {
  303. -            fprintf(stderr, "%04lx: xdr_getcallbody failed\n", (long)GetCurrentThreadId());
  304. +            (void)fprintf(stderr,
  305. +                "%04lx: cb: xdr_getcallbody failed\n",
  306. +                (long)GetCurrentThreadId());
  307.              goto skip_process;
  308.          } else
  309. -            fprintf(stdout, "%04lx: callbody: rpcvers %d cb_prog %d cb_vers %d cb_proc %d\n",
  310. +            (void)fprintf(stdout, "%04lx: cb: callbody: rpcvers=%d cb_prog=%d cb_vers=%d cb_proc=%d\n",
  311.                  (long)GetCurrentThreadId(),
  312. -                ct->reply_msg.rm_call.cb_rpcvers, ct->reply_msg.rm_call.cb_prog,
  313. -                ct->reply_msg.rm_call.cb_vers, ct->reply_msg.rm_call.cb_proc);
  314. +                (int)ct->reply_msg.rm_call.cb_rpcvers,
  315. +                (int)ct->reply_msg.rm_call.cb_prog,
  316. +                (int)ct->reply_msg.rm_call.cb_vers,
  317. +                (int)ct->reply_msg.rm_call.cb_proc);
  318.          header.rq_prog = ct->reply_msg.rm_call.cb_prog;
  319.          header.rq_vers = ct->reply_msg.rm_call.cb_vers;
  320.          header.rq_proc = ct->reply_msg.rm_call.cb_proc;
  321.          header.xdr = xdrs;
  322.          status = (*cl->cb_fn)(cl->cb_args, &header, &res);
  323.          if (status) {
  324. -            fprintf(stderr, "%04lx: callback function failed with %d\n",
  325. +            (void)fprintf(stderr, "%04lx: cb: callback function failed with %d\n",
  326.                  (long)GetCurrentThreadId(), status);
  327.          }
  328.  
  329.          xdrs->x_op = XDR_ENCODE;
  330.          __xdrrec_setblock(xdrs);
  331.          reply_msg.rm_xid = ct->reply_msg.rm_xid;
  332. -        fprintf(stdout, "%04lx: cb: replying to xid %d\n", (long)GetCurrentThreadId(),
  333. -            ct->reply_msg.rm_xid);
  334. +        (void)fprintf(stdout, "%04lx: cb: replying to xid=%x\n",
  335. +            (long)GetCurrentThreadId(),
  336. +            (int)ct->reply_msg.rm_xid);
  337.          ct->reply_msg.rm_xid = 0;
  338.          reply_msg.rm_direction = REPLY;
  339.          reply_msg.rm_reply.rp_stat = MSG_ACCEPTED;
  340. @@ -298,7 +306,8 @@ process_rpc_call:
  341.              (*cl->cb_xdr)(xdrs, res); /* free the results */
  342.          }
  343.          if (! xdrrec_endofrecord(xdrs, 1)) {
  344. -            fprintf(stderr, "%04lx: failed to send REPLY\n", (long)GetCurrentThreadId());
  345. +            (void)fprintf(stderr, "%04lx: cb: failed to send REPLY\n",
  346. +                (long)GetCurrentThreadId());
  347.          }
  348.  skip_process:
  349.          ct->reply_msg.rm_direction = -1;
  350. @@ -485,7 +494,9 @@ clnt_vc_create(fd, raddr, prog, vers, sendsz, recvsz, cb_xdr, cb_fn, cb_args)
  351.          cl->cb_thread = (HANDLE)_beginthreadex(NULL,
  352.              0, clnt_cb_thread, cl, 0, NULL);
  353.          if (cl->cb_thread == INVALID_HANDLE_VALUE) {
  354. -            fprintf(stderr, "_beginthreadex failed %d\n", GetLastError());
  355. +            (void)fprintf(stderr, "%04lx: _beginthreadex() failed %d\n",
  356. +                (long)GetCurrentThreadId(),
  357. +                GetLastError());
  358.              goto err;
  359.          } else
  360.              fprintf(stdout, "%04lx: started the callback thread %04lx\n",
  361. --
  362. 2.43.0

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at