Skip to content

/FreeImage.NET/MacOS/libfreeimage.dylib contains Intel AVX instructions, causing SIGILL signal #61

@wjlandryiii

Description

@wjlandryiii

When I try building my content using Pipeline.app, I receive this error:

Build started 9/26/2015 9:16:58 AM

/Users/wjl/Projects/testfna/testfna/Content/icon.bmp
/Users/wjl/Projects/testfna/testfna/Content/icon.bmp: error: Importer 'TextureImporter' had unexpected failure!
System.ExecutionEngineException: SIGILL
  at Microsoft.Xna.Framework.Content.Pipeline.ContentImporter`1[Microsoft.Xna.Framework.Content.Pipeline.Graphics.TextureContent].Microsoft.Xna.Framework.Content.Pipeline.IContentImporter.Import (System.String filename, Microsoft.Xna.Framework.Content.Pipeline.ContentImporterContext context) [0x00000] in <filename unknown>:0 
  at MonoGame.Framework.Content.Pipeline.Builder.PipelineManager.ProcessContent (MonoGame.Framework.Content.Pipeline.Builder.PipelineBuildEvent pipelineEvent) [0x00000] in <filename unknown>:0 
Build 0 succeeded, 1 failed.

Time elapsed 00:00:00.25.

When debugging with lldb, I found that the illegal instruction was located in libfreeimage.dylib:

$ lldb mono
(lldb) target create "mono"
Current executable set to 'mono' (i386).
(lldb) process launch /Users/wjl/Projects/MonoGame/Tools/MGCB/bin/MacOS/AnyCPU/Debug/MGCB.exe /@:/Users/wjl/Projects/testfna/testfna/Content/Content.mgcb
Process 9666 launched: '/usr/local/bin/mono' (i386)
warning: (i386) /Library/Frameworks/Mono.framework/Versions/4.0.4/lib/mono/4.5/mscorlib.dll.dylib empty dSYM file detected, dSYM was created with an executable with no debug info.
Build started 9/26/2015 9:30:15 AM

/Users/wjl/Projects/testfna/testfna/Content/icon.bmp
Process 9666 stopped
* thread #1: tid = 0xc5d7ae, 0x03148297 libfreeimage.dylib`TagLib::TagLib() + 21, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
    frame #0: 0x03148297 libfreeimage.dylib`TagLib::TagLib() + 21
libfreeimage.dylib`TagLib::TagLib() + 21:
-> 0x3148297:  vxorps %xmm0, %xmm0, %xmm0
   0x314829b:  vmovups %xmm0, 0x4(%esi)
   0x31482a0:  movl   $0x0, 0x14(%esi)
   0x31482a7:  movl   %eax, 0xc(%esi)
(lldb)

The vxorps instruction is an Intel AVX instruction that is not supported on older chips. According to wikipedia, the AVX extension was introduced in 2011, so any chip older than that doesn't support the extension.

To work around this problem, I used homebrew to compile libfreeimage.dylib from source and replaced the dylib in the .app with the freshly compiled homebrew version:

$ brew install freeimage --build-from-source --universal
==> Downloading https://downloads.sourceforge.net/project/freeimage/Source%20Distribution/3.17.0/FreeImage3170.zip
==> Downloading from http://iweb.dl.sourceforge.net/project/freeimage/Source%20Distribution/3.17.0/FreeImage3170.zip
######################################################################## 100.0%
==> Patching
patching file Makefile.fip
Hunk #4 succeeded at 69 with fuzz 2.
patching file Makefile.gnu
==> make -f Makefile.gnu
==> make -f Makefile.gnu install PREFIX=/usr/local/Cellar/freeimage/3.17.0
==> make -f Makefile.fip
==> make -f Makefile.fip install PREFIX=/usr/local/Cellar/freeimage/3.17.0
🍺  /usr/local/Cellar/freeimage/3.17.0: 7 files, 65M, built in 4.2 minutes
$

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions