We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3241 - sdl2_ttf.dll Looks for missing InterlockedCompareExchange in libfreetype6.dll
Summary: sdl2_ttf.dll Looks for missing InterlockedCompareExchange in libfreetype6.dll
Status: RESOLVED FIXED
Alias: None
Product: SDL_ttf
Classification: Unclassified
Component: misc (show other bugs)
Version: 2.0.13
Hardware: x86 Windows 7
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-17 00:01 UTC by moiein2000
Modified: 2017-09-10 06:27 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description moiein2000 2016-01-17 00:01:54 UTC
Hi,

We have run into a dll loading issue, which I believe is due to the usage of an older version of mingw-w64 used to build sdl2_ttf.dll. At least that's what it seemed to me.

Using objdump on sdl2_ttf.dll I get the following:


sdl2_ttf.dll:     file format pei-i386

Characteristics 0x230e
	executable
	line numbers stripped
	symbols stripped
	32 bit words
	debugging information removed
	DLL

...

There is an import table in .idata at 0x7100f000

The Import Tables (interpreted .idata section contents)
 vma:            Hint    Time      Forward  DLL       First
                 Table   Stamp     Chain    Name      Thunk
 0000f000	0000f064 00000000 00000000 0000f900 0000f1c4

	DLL Name: libfreetype-6.dll
	vma:  Hint/Ord Member-Name Bound-To
	f324	   34  FT_Done_Face
	f334	   35  FT_Done_FreeType
	f348	   36  FT_Done_Glyph
	f358	   58  FT_Get_Char_Index
	f36c	   63  FT_Get_Glyph
	f37c	   65  FT_Get_Kerning
	f390	  103  FT_Glyph_Stroke
	f3a4	  105  FT_Glyph_To_Bitmap
	f3bc	  109  FT_Init_FreeType
	f3d0	  121  FT_Load_Glyph
	f3e0	  140  FT_Open_Face
	f3f0	  158  FT_Outline_Transform
	f408	  168  FT_Render_Glyph
	f41c	  176  FT_Set_Char_Size
	f430	  177  FT_Set_Charmap
	f444	  181  FT_Set_Pixel_Sizes
	f45c	  223  FT_Stroker_Done
	f470	  230  FT_Stroker_New
	f484	  233  FT_Stroker_Set
	f498	  246  InterlockedCompareExchange@12

The key point is that it's looking for InterlockedCompareExchange in libfreetype-6.dll. This is due to a bug in mingw-w64 that was fixed a long time ago: http://sourceforge.net/p/mingw-w64/mailman/message/30894964/.

Normally it's not a problem because you also distribute libfreetype-6.dll which exports it since it was built with the same version. The problem is when the system already has loaded a different, later version of libfreetype-6.dll, which has fixed this issue and doesn't export InterlockedCompareExchange. In that case the sdl2_ttf dll fails to be loaded.

Is it possible to distribute sdl2_ttf.dll using later version of mingw-w64?
Comment 1 Sam Lantinga 2017-09-10 06:27:46 UTC
Yes, the next release will use a new version of mingw-w64