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 fuzzy.dll functions on Win32 prebuilt binary #1

Open
1 of 7 tasks
a4lg opened this issue Sep 17, 2017 · 0 comments
Open
1 of 7 tasks

Fix fuzzy.dll functions on Win32 prebuilt binary #1

a4lg opened this issue Sep 17, 2017 · 0 comments
Assignees
Milestone

Comments

@a4lg
Copy link
Collaborator

a4lg commented Sep 17, 2017

On fuzzy.dll (in the prebuilt Win32 archive), fuzzy_hash_file and fuzzy_hash_stream functions will not work properly if you normally build the program which uses fuzzy.dll with Visual C++.

Cause

Because struct FILE is managed by separate instance of Microsoft CRT, mixing multiple CRTs (multiple versions or Debug/Release builds) causes problems. Internally, POSIX file descriptor is managed by __pioinfo and its entry (struct __crt_lowio_handle_data on UCRT) has corresponding Win32 handle and other information. Since every instance of Microsoft CRT has its own __pioinfo (note: on universal CRT [VS2015 or later], __pioinfo is no longer exported), mixing CRT can cause serious inconsistency problems:

  • File opened by fopen is not considered open.
  • Different file is referenced.

Potential Errors Passing CRT Objects Across DLL Boundaries: https://msdn.microsoft.com/en-us/library/ms235460.aspx

Possible Resolution

fuzzy.dll references msvcrt.dll and there's no problem if Win32 program also uses msvcrt.dll. However, this is very unlikely. Programs built on Visual C++ are normally linked against version-specific CRT and/or universal CRT.

Although it's possible to link against version-specific CRT (but not universal CRT; as of September 2017), it's much safer to build fuzzy.dll on Visual C++. At least, linking against universal CRT (new CRT for Windows; ucrtbase.dll and API sets) is required to resolve this issue because there will be no version-related issues anymore (there will be however, Debug/Release DLL issues).

  • Fix README for CRT object sharing (adding /MD or /MDd option; will be committed later)
  • Make fuzzy.c, edit_distn.c and find-file-size.c possible to compile on Visual C++
  • Make build pipeline to use “platform toolset” feature on Visual C++
  • Build fuzzy.dll with multiple platform toolsets (Debug build and Release build):
    • Visual Studio 2015 (v140) (mandatory; linked against universal CRT)
    • Visual Studio 2013 (v120) (optional)
    • Visual Studio 2012 (v110) (optional)

After these changes, Windows build pipeline may be separated from this repository.

@a4lg a4lg added this to the Version 2.15 milestone Sep 17, 2017
@a4lg a4lg changed the title Fix fuzzy.dll functions on Win32 prebuilt binaries Fix fuzzy.dll functions on Win32 prebuilt binary Sep 17, 2017
@a4lg a4lg self-assigned this Sep 17, 2017
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