[Bug 48620] libmdbx (memory-mapped DB) needs ntdll.NtExtendSection stub

WineHQ Bugzilla wine-bugs at winehq.org
Tue Feb 18 01:15:46 CST 2020


https://bugs.winehq.org/show_bug.cgi?id=48620

Anastasius Focht <focht at gmx.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|libmdbx (memory-mapped DB)  |libmdbx (memory-mapped DB)
                   |fail on Wine                |needs ntdll.NtExtendSection
                   |                            |stub
            Version|unspecified                 |5.1
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
                 CC|                            |focht at gmx.net

--- Comment #7 from Anastasius Focht <focht at gmx.net> ---
Hello folks,

filling some fields and confirming.

https://github.com/erthink/libmdbx/blob/5adbc75b3890c6cb8fc8b872c2f8d96eb83039cd/src/elements/lck-windows.c#L776

https://github.com/erthink/libmdbx/blob/5adbc75b3890c6cb8fc8b872c2f8d96eb83039cd/src/elements/osal.c#L1390

--- snip ---
MDBX_INTERNAL_FUNC int mdbx_mresize(int flags, mdbx_mmap_t *map, size_t size,
                                    size_t limit) {
  assert(size <= limit);
#if defined(_WIN32) || defined(_WIN64)
  assert(size != map->current || limit != map->limit || size < map->filesize);

  NTSTATUS status;
  LARGE_INTEGER SectionSize;
  int err, rc = MDBX_SUCCESS;

  if (!(flags & MDBX_RDONLY) && limit == map->limit && size > map->current) {
    /* growth rw-section */
    if (!mdbx_NtExtendSection)
      return ERROR_CALL_NOT_IMPLEMENTED /* workaround for Wine */;
    SectionSize.QuadPart = size;
    status = mdbx_NtExtendSection(map->section, &SectionSize);
    if (!NT_SUCCESS(status))
      return ntstatus2errcode(status);
    map->current = size;
    if (map->filesize < size)
      map->filesize = size;
    return MDBX_SUCCESS;
  }
...
--- snip ---

https://source.winehq.org/git/wine.git/blob/be2b0b1cec5843f0145f376316d6c28507559910:/dlls/ntdll/ntdll.spec#l209

--- snip ---
 209 @ stub NtExtendSection
--- snip ---

This results in auto-generated stub ('GetProcAddress' will return non-NULL).
Any call of the function pointer will result in a crash, accompanied with
infamous 'unimplemented function foobar' message.

https://undocumented.ntinternals.net/index.html?page=UserMode%2FUndocumented%20Functions%2FNT%20Objects%2FSection%2FNtExtendSection.html

The technique to extend shared memory mappings via 'NtExtendSection' is also
described here:

https://stackoverflow.com/questions/44101966/adding-new-bytes-to-memory-mapped-file

Just do as you already proposed: add a stub 'NtExtendSection' that returns
STATUS_NOT_IMPLEMENTED.

Regards

-- 
Do not reply to this email, post in Bugzilla using the
above URL to reply.
You are receiving this mail because:
You are watching all bug changes.



More information about the wine-bugs mailing list