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

DrMemory 2.6.0 WinSock |recv()|/|send()| reports false-positive "UNINITIALIZED READ" errors #2488

Open
gisburn opened this issue Oct 30, 2023 · 2 comments

Comments

@gisburn
Copy link

gisburn commented Oct 30, 2023

Describe the bug
WinSock2 |recv()| (WS2_32.dll!recv) reports false-positive "UNINITIALIZED READ" errors. Same happens with WinSock2 |send()|

To Reproduce
See https://www.binarytides.com/receive-full-data-with-recv-socket-function-in-c/ for a minimised |recv()| example code. Compile with MinGW or VC19.

Expected behavior
DrMemory should not report "UNINITIALIZED READ"

Versions

@gisburn
Copy link
Author

gisburn commented Oct 30, 2023

DrMemory reports TWO different syscalls for |recv()|:

  1. NtDeviceIoControlFile AFD_RECV_INFO
  2. NtDeviceIoControlFile AFD_RECV_INFO.BufferArray

Example from our test system:
---- snip ----

~~6068~~ Error #266: UNINITIALIZED READ: reading 4 byte(s)
~~6068~~ # 0 system call NtDeviceIoControlFile AFD_RECV_INFO
~~6068~~ # 1 MSWSOCK.dll!NSPStartup                                       +0x55d    (0x00007ffe6526c5fe <MSWSOCK.dll+0xc5fe>)
~~6068~~ # 2 WS2_32.dll!recv                                              +0xc0     (0x00007ffe66ac1e51 <WS2_32.dll+0x11e51>)
~~6068~~ # 3 libtirpc.dll!read_vc                                          [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\libtirpc\src\clnt_vc.c:1005]
~~6068~~ # 4 libtirpc.dll!__xdrrec_getrec                                  [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\libtirpc\src\xdr_rec.c:625]
~~6068~~ # 5 libtirpc.dll!xdrrec_skiprecord                                [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\libtirpc\src\xdr_rec.c:503]
~~6068~~ # 6 libtirpc.dll!clnt_vc_call                                     [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\libtirpc\src\clnt_vc.c:613]
~~6068~~ # 7 nfs41_send_compound                                           [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\daemon\nfs41_rpc.c:350]
~~6068~~ # 8 compound_encode_send_decode                                   [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\daemon\nfs41_compound.c:153]
~~6068~~ # 9 nfs41_delegreturn                                             [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\daemon\nfs41_ops.c:1722]
~~6068~~ #10 delegation_return                                             [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\daemon\delegation.c:319]
~~6068~~ #11 nfs41_client_delegation_return_lru                            [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\daemon\delegation.c:935]
~~6068~~ #12 open_update_cache                                             [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\daemon\nfs41_ops.c:353]
~~6068~~ #13 nfs41_open                                                    [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\daemon\nfs41_ops.c:524]
~~6068~~ #14 do_open                                                       [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\daemon\open.c:227]
~~6068~~ #15 open_or_delegate                                              [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\daemon\open.c:268]
~~6068~~ #16 handle_open                                                   [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\daemon\open.c:849]
~~6068~~ #17 upcall_handle                                                 [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\daemon\upcall.c:150]
~~6068~~ #18 thread_main                                                   [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\daemon\nfs41_daemon.c:134]
~~6068~~ #19 ucrtbased.dll!set_app_type                                   +0x1642   (0x00007ffe34e38ed3 <ucrtbased.dll+0x58ed3>)
~~6068~~
~~6068~~ Error #267: UNINITIALIZED READ: reading 4 byte(s)
~~6068~~ # 0 system call NtDeviceIoControlFile AFD_RECV_INFO.BufferArray
~~6068~~ # 1 MSWSOCK.dll!NSPStartup                                                   +0x55d    (0x00007ffe6526c5fe <MSWSOCK.dll+0xc5fe>)
~~6068~~ # 2 WS2_32.dll!recv                                                          +0xc0     (0x00007ffe66ac1e51 <WS2_32.dll+0x11e51>)
~~6068~~ # 3 libtirpc.dll!read_vc                                                      [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\libtirpc\src\clnt_vc.c:1005]
~~6068~~ # 4 libtirpc.dll!__xdrrec_getrec                                              [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\libtirpc\src\xdr_rec.c:625]
~~6068~~ # 5 libtirpc.dll!xdrrec_skiprecord                                            [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\libtirpc\src\xdr_rec.c:503]
~~6068~~ # 6 libtirpc.dll!clnt_vc_call                                                 [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\libtirpc\src\clnt_vc.c:613]
~~6068~~ # 7 nfs41_send_compound                                                       [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\daemon\nfs41_rpc.c:350]
~~6068~~ # 8 compound_encode_send_decode                                               [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\daemon\nfs41_compound.c:153]
~~6068~~ # 9 nfs41_delegreturn                                                         [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\daemon\nfs41_ops.c:1722]
~~6068~~ #10 delegation_return                                                         [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\daemon\delegation.c:319]
~~6068~~ #11 nfs41_client_delegation_return_lru                                        [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\daemon\delegation.c:935]
~~6068~~ #12 open_update_cache                                                         [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\daemon\nfs41_ops.c:353]
~~6068~~ #13 nfs41_open                                                                [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\daemon\nfs41_ops.c:524]
~~6068~~ #14 do_open                                                                   [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\daemon\open.c:227]
~~6068~~ #15 open_or_delegate                                                          [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\daemon\open.c:268]
~~6068~~ #16 handle_open                                                               [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\daemon\open.c:849]
~~6068~~ #17 upcall_handle                                                             [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\daemon\upcall.c:150]
~~6068~~ #18 thread_main                                                               [C:\cygwin64\home\roland_mainz\work\msnfs41_uidmapping\ms-nfs41-client\daemon\nfs41_daemon.c:134]
~~6068~~ #19 ucrtbased.dll!set_app_type                                               +0x1642   (0x00007ffe34e38ed3 <ucrtbased.dll+0x58ed3>)

---- snip ----

@gisburn
Copy link
Author

gisburn commented Oct 30, 2023

Possible workaround:
$ drmemory -lib_blocklist_frames 1 -check_uninit_blocklist 'MSWSOCK,WS2_32' <...more...args...>

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

No branches or pull requests

1 participant