DavidBrainard / RenderToolbox3

Matlab toolbox for managing graphics rendering for psychophysics
MIT License
11 stars 4 forks source link

MakeMultichannelEXR build fails in OS X 10.9. #55

Closed benjamin-heasly closed 9 years ago

benjamin-heasly commented 10 years ago

MakeMultichannelEXR used to build find under OS X 10.7 and 10.8. The build succeeds in OS X 10.9, but the resulting mex-function is broken, causing a segmentation fault.

This may be related to recent changes in OS X 10.9 and XCode 5. Apple has moved away from gcc for building C and C++ programs, and now favors llvm. It may take time for Matlab to issue patches for previous Matlab versions.

This Matlab issue may be related, although the reported symptoms are different: http://www.mathworks.com/matlabcentral/answers/103904-can-i-use-xcode-5-as-my-c-or-c-compiler-in-matlab-8-1-r2013a-or-matlab-8-2-r2013b


System details where the broken build occurred:

npcottaris commented 10 years ago

In OSX 10.9.3, with Matlab R2013b, I had the same issue. I was able to solve it as follows:

(1) Install Xcode 5.1 (2) Install command line dev tools for mavericks (march 2014) (3) edit the mexopts.sh file in Matlabroot and modify the maci64 section as shown at the end of this post (4) run mex -setup

    maci64)

----------------------------------------------------------------------------

    #PATCH: MacOSX10.9
    CC='llvm-gcc'
    CXX='llvm-g++'
    SDKROOT='/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/'   
        MACOSX_DEPLOYMENT_TARGET='10.9'
        ARCHS='x86_64'

        # StorageVersion: 1.0
        # CkeyName: GNU C
        # CkeyManufacturer: GNU
        # CkeyLanguage: C
        # CkeyVersion:
        CFLAGS="-fno-common -no-cpp-precomp -arch $ARCHS -isysroot $SDKROOT -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET"
        CFLAGS="$CFLAGS  -fexceptions"
        CLIBS="$MLIBS"
        COPTIMFLAGS='-O2 -DNDEBUG'
        CDEBUGFLAGS='-g'

# CLIBS="$CLIBS -lstdc++"

C++keyName: GNU C++

        # C++keyManufacturer: GNU
        # C++keyLanguage: C++
        # C++keyVersion: 
        CXXFLAGS="-fno-common -no-cpp-precomp -fexceptions -arch $ARCHS -isysroot $SDKROOT -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET"
        CXXLIBS="$MLIBS -lstdc++"
        CXXOPTIMFLAGS='-O2 -DNDEBUG'
        CXXDEBUGFLAGS='-g'

#

FortrankeyName: GNU Fortran

        # FortrankeyManufacturer: GNU
        # FortrankeyLanguage: Fortran
        # FortrankeyVersion: 
        FC='gfortran'
        FFLAGS='-fexceptions -m64 -fbackslash'
        FC_LIBDIR=`$FC -print-file-name=libgfortran.dylib 2>&1 | sed -n '1s/\/*libgfortran\.dylib//p'`
        FC_LIBDIR2=`$FC -print-file-name=libgfortranbegin.a 2>&1 | sed -n '1s/\/*libgfortranbegin\.a//p'`
        FLIBS="$MLIBS -L$FC_LIBDIR -lgfortran -L$FC_LIBDIR2 -lgfortranbegin"
        FOPTIMFLAGS='-O'
        FDEBUGFLAGS='-g'

# LD="$CC" LDEXTENSION='.mexmaci64' LDFLAGS="-Wl,-twolevel_namespace -undefined error -arch $ARCHS -Wl,-syslibroot,$SDKROOT -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET" LDFLAGS="$LDFLAGS -bundle -Wl,-exported_symbols_list,$TMW_ROOT/extern/lib/$Arch/$MAPFILE" LDOPTIMFLAGS='-O' LDDEBUGFLAGS='-g' # POSTLINK_CMDS=':'

----------------------------------------------------------------------------

        ;;
benjamin-heasly commented 10 years ago

I tried again with the pre-release version of Matlab 2014b, OS X 10.9.4, and XCode 5.1.1.

I was able to build MakeMultichannelEXR just fine. I didn't have to make any changes to the Matlab configuration.

So this issue might be resolving itself over time.

papagiannakis commented 10 years ago

I can also confirm that with Matlab2014a, OSX 10.9.4 and Xcode5.1.1 it still crashes, with or without the fix from Nicholas. Please advice on possible solution as otherwise RenderToolbox works only with PBRT

npcottaris commented 10 years ago

Details on how it crashes please !

Nicolas

On Jul 30, 2014, at 3:26 PM, papagiannakis notifications@github.com wrote:

I can also confirm that with Matlab2014a, OSX 10.9.4 and Xcode5.1.1 it still crashes, with or without the fix from Nicholas. Please advice on possible solution as otherwise RenderToolbox works only with PBRT

— Reply to this email directly or view it on GitHub.

papagiannakis commented 10 years ago

Attached below the Matlab crash report (apologies for the long post):

MATLAB crash file:/Users/Giwrgakis/matlab_crash_dump.9085-1:


   Segmentation violation detected at Wed Jul 30 22:30:35 2014

Configuration: Crash Decoding : Disabled Current Visual : Quartz Default Encoding : ISO-8859-7 MATLAB Architecture: maci64 MATLAB Root : /Applications/MATLAB_R2014a.app MATLAB Version : 8.3.0.532 (R2014a) Operating System : Darwin 13.3.0 Darwin Kernel Version 13.3.0: Tue Jun 3 21:27:35 PDT 2014; root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64 Processor ID : x86 Family 6 Model 58 Stepping 9, GenuineIntel Virtual Machine : Java 1.7.0_11-b21 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode Window System : Quartz

Fault Count: 1

Abnormal termination: Segmentation violation

Register State (from fault): RAX = 0000000000000000 RBX = 0000000000000000 RCX = 00007f9cc0900000 RDX = 0000000100000006 RSP = 00007f9cc098c960 RBP = e9008ab43397ab93 RSI = 0000000000000000 RDI = 0000000000003c00

R8 = 000000011332aef0 R9 = 0000000000000002 R10 = 00000000000003bf R11 = 0000000000000001 R12 = 000000011332a800 R13 = 00000001356eb382 R14 = 000000011332aa40 R15 = 0000000110b4824c

RIP = 0000000000000000 RFL = 0000000000000000

CS = 0000000000000000 FS = 0000000000000000 GS = 0000000000000000

Stack Trace (from fault): [ 0] 0x0000000107ed8874 /Applications/MATLAB_R2014a.app/bin/maci64/libmwfl.dylib+00030836 _ZN2fl4diag15stacktrace_base7captureERKNS0_14thread_contextEm+00000052 [ 1] 0x0000000107edc2aa /Applications/MATLAB_R2014a.app/bin/maci64/libmwfl.dylib+00045738 _ZN2fl4test17terminate_handledEv+00000906 [ 2] 0x0000000107edbcf5 /Applications/MATLAB_R2014a.app/bin/maci64/libmwfl.dylib+00044277 _ZN2fl4diag13terminate_logEPKcPK17darwin_ucontext+00000117 [ 3] 0x0000000107a42d07 /Applications/MATLAB_R2014a.app/bin/maci64/libmwmcr.dylib+00269575 _Z32mnRunPathDependentInitializationv+00003127 [ 4] 0x0000000107a42ff8 /Applications/MATLAB_R2014a.app/bin/maci64/libmwmcr.dylib+00270328 _Z32mnRunPathDependentInitializationv+00003880 [ 5] 0x0000000107a4081a /Applications/MATLAB_R2014a.app/bin/maci64/libmwmcr.dylib+00260122 mnFatalSignalHandler+00000298 [ 6] 0x00007fff86a235aa /usr/lib/system/libsystem_platform.dylib+00013738 _sigtramp+00000026 [ 7] 0x00000001356f1d44 /opt/local/lib/libIlmImf.6.dylib+00081220 _ZNKSt316treeINS_4pairIN3Imf4NameEPNS2_9AttributeEEENS_19map_value_compareIS3_S5_NS_4lessIS3_EELb1EEENS_9allocatorIS6_EEE13__lower_boundIS3_EENS_21tree_const_iteratorIS6_PKNS_11tree_nodeIS6_PvEElEERKT_SKSK+00000036 [ 8] 0x0000000110b4824c /Users/Giwrgakis/MyProjects/pathTracing/RenderToolbox3/Utilities/ReadMultispectralEXR/ReadMultichannelEXR.mexmaci64+00004684 mexFunction+00000284 [ 9] 0x000000010b8fd0b5 /Applications/MATLAB_R2014a.app/bin/maci64/libmex.dylib+00057525 mexRunMexFile+00000085 [ 10] 0x000000010b8f9101 /Applications/MATLAB_R2014a.app/bin/maci64/libmex.dylib+00041217 _ZN7Mfh_mex30runMexFileWithSignalProtectionEiPP11mxArraytagiS2+00000113 [ 11] 0x000000010b8f92e0 /Applications/MATLAB_R2014a.app/bin/maci64/libmex.dylib+00041696 _ZN7Mfh_mex13dispatch_fileEiPP11mxArraytagiS2+00000288 [ 12] 0x000000010b96ea9a /Applications/MATLAB_R2014a.app/bin/maci64/libmwm_dispatcher.dylib+00334490 _ZN8Mfh_file11dispatch_fhEiPP11mxArraytagiS2+00000602 [ 13] 0x000000010c019b62 /Applications/MATLAB_R2014a.app/bin/maci64/libmwm_interpreter.dylib+00990050 _Z19inDispatchFromStackiPKcii+00001522 [ 14] 0x000000010bfd0777 /Applications/MATLAB_R2014a.app/bin/maci64/libmwm_interpreter.dylib+00690039 inPcodeWalker+00016519 [ 15] 0x000000010bfcef28 /Applications/MATLAB_R2014a.app/bin/maci64/libmwm_interpreter.dylib+00683816 inPcodeWalker+00010296 [ 16] 0x000000010bfca097 /Applications/MATLAB_R2014a.app/bin/maci64/libmwm_interpreter.dylib+00663703 inInterPcode+00000871 [ 17] 0x000000010bfcb310 /Applications/MATLAB_R2014a.app/bin/maci64/libmwm_interpreter.dylib+00668432 _Z26inExecuteMFunctionOrScriptP6Mfh_mpb+00000896 [ 18] 0x000000010c03ff9b /Applications/MATLAB_R2014a.app/bin/maci64/libmwm_interpreter.dylib+01146779 _Z10inRunMfileiPP11mxArray_tagiS1_P6Mfh_mpP15inWorkSpace_tag+00003163 [ 19] 0x000000010b96ea9a /Applications/MATLAB_R2014a.app/bin/maci64/libmwm_dispatcher.dylib+00334490 _ZN8Mfh_file11dispatch_fhEiPP11mxArraytagiS2+00000602 [ 20] 0x000000010c019b62 /Applications/MATLAB_R2014a.app/bin/maci64/libmwm_interpreter.dylib+00990050 _Z19inDispatchFromStackiPKcii+00001522 [ 21] 0x000000010bfa4a90 /Applications/MATLAB_R2014a.app/bin/maci64/libmwm_interpreter.dylib+00510608 inCallFcnFromReference+00000768 [ 22] 0x000000010bfce291 /Applications/MATLAB_R2014a.app/bin/maci64/libmwm_interpreter.dylib+00680593 inPcodeWalker+00007073 [ 23] 0x000000010bfca097 /Applications/MATLAB_R2014a.app/bin/maci64/libmwm_interpreter.dylib+00663703 inInterPcode+00000871 [ 24] 0x000000010bfcb310 /Applications/MATLAB_R2014a.app/bin/maci64/libmwm_interpreter.dylib+00668432 _Z26inExecuteMFunctionOrScriptP6Mfh_mpb+00000896 [ 25] 0x000000010c03ff9b /Applications/MATLAB_R2014a.app/bin/maci64/libmwm_interpreter.dylib+01146779 _Z10inRunMfileiPP11mxArray_tagiS1_P6Mfh_mpP15inWorkSpace_tag+00003163 [ 26] 0x000000010b96eac7 /Applications/MATLAB_R2014a.app/bin/maci64/libmwm_dispatcher.dylib+00334535 _ZN8Mfh_file11dispatch_fhEiPP11mxArraytagiS2+00000647 [ 27] 0x000000010c00695c /Applications/MATLAB_R2014a.app/bin/maci64/libmwm_interpreter.dylib+00911708 _Z23inEvalPcodeHeaderToWordP15_memory_contextiPP11mxArray_tagP12_pcodeheaderP6Mfh_mpj+00000220 [ 28] 0x000000010bfc55bb /Applications/MATLAB_R2014a.app/bin/maci64/libmwm_interpreter.dylib+00644539 _Z25in_local_call_with_setjmpIN5boost3_bi6bind_tIvPFvP15_memory_contextPiPP11mxArray_tagP12_pcodeheaderjENS1_5list5INS1_5valueIS4_EENS0_3argILi1EEENSG_ILi2EEENSE_ISA_EENSE_IiEEEEEEEN6mlutil14cmddistributor17inExecutionStatusET_S5_S8_b+00000171 [ 29] 0x000000010bfc09d9 /Applications/MATLAB_R2014a.app/bin/maci64/libmwm_interpreter.dylib+00625113 _Z12inEvalStringP15_memory_contextRKSbItSt11char_traitsItESaItEE8EvalTypeiPP11mxArray_tag12inDebugCheckP12_pcodeheaderPib+00002713 [ 30] 0x000000010bfc0f5d /Applications/MATLAB_R2014a.app/bin/maci64/libmwm_interpreter.dylib+00626525 _ZN12InterpBridge22EvalCmdWithLocalReturnERKSbItSt11char_traitsItESaItEEPibb+00000141 [ 31] 0x000000010b8b48ad /Applications/MATLAB_R2014a.app/bin/maci64/libmwbridge.dylib+00051373 _Z28evalCommandWithLongjmpSafetyRKSbItSt11char_traitsItESaItEE+00000093 [ 32] 0x000000010b8b4f5d /Applications/MATLAB_R2014a.app/bin/maci64/libmwbridge.dylib+00053085 _Z8mnParserv+00000717 [ 33] 0x0000000107a2ed22 /Applications/MATLAB_R2014a.app/bin/maci64/libmwmcr.dylib+00187682 _ZN11mcrInstance30mnParser_on_interpreter_threadEv+00000034 [ 34] 0x0000000107a095ba /Applications/MATLAB_R2014a.app/bin/maci64/libmwmcr.dylib+00034234 _ZN3mcr7runtime17InterpreterThread4Impl26invocation_request_handlerEl+00000058 [ 35] 0x00000001075f8395 /Applications/MATLAB_R2014a.app/bin/maci64/libmwservices.dylib+00127893 _ZN10eventqueue18UserEventQueueImpl5flushEv+00001269 [ 36] 0x000000010c8222d5 /Applications/MATLAB_R2014a.app/bin/maci64/libmwuix.dylib+00037589 _Z25isHandleUserEventCallbackPFvPvE+00000485 [ 37] 0x000000010769a565 /Applications/MATLAB_R2014a.app/bin/maci64/libmwservices.dylib+00791909 _Z21svWS_ProcessCallbacksv+00016261 [ 38] 0x0000000107695e42 /Applications/MATLAB_R2014a.app/bin/maci64/libmwservices.dylib+00773698 _Z25svWS_ProcessPendingEventsiib+00000834 [ 39] 0x0000000107695b4e /Applications/MATLAB_R2014a.app/bin/maci64/libmwservices.dylib+00772942 _Z25svWS_ProcessPendingEventsiib+00000078 [ 40] 0x0000000107a097ff /Applications/MATLAB_R2014a.app/bin/maci64/libmwmcr.dylib+00034815 _ZN3mcr7runtime17InterpreterThread4Impl14process_eventsERKN5boost10shared_ptrIS2_EE+00000095 [ 41] 0x0000000107a09b03 /Applications/MATLAB_R2014a.app/bin/maci64/libmwmcr.dylib+00035587 _ZN3mcr7runtime17InterpreterThread4Impl3runERKN5boost10shared_ptrIS2_EEPNS2_12init_contextE+00000323 [ 42] 0x0000000107a04b68 /Applications/MATLAB_R2014a.app/bin/maci64/libmwmcr.dylib+00015208 _Z26run_init_and_handle_eventsPv+00000056 [ 43] 0x00007fff86a28899 /usr/lib/system/libsystem_pthread.dylib+00006297 _pthread_body+00000138 [ 44] 0x00007fff86a2872a /usr/lib/system/libsystem_pthread.dylib+00005930 _pthread_struct_init+00000000 [ 45] 0x00007fff86a2cfc9 /usr/lib/system/libsystem_pthread.dylib+00024521 thread_start+00000013

This error was detected while a MEX-file was running. If the MEX-file is not an official MathWorks function, please examine its source code for errors. Please consult the External Interfaces Guide for information on debugging MEX-files.

If this problem is reproducible, please submit a Service Request via: http://www.mathworks.com/support/contact_us/

A technical support engineer might contact you with further information.

Thank you for your help.

benjamin-heasly commented 9 years ago

I was able to run MakeReadMultichannelEXR() successfully today. I have

I had to re-install the OpenEXR library. I used Homebrew instead of MacPorts and documented my process: https://github.com/DavidBrainard/RenderToolbox3/wiki/Getting-OpenEXR-in-OS-X

If anyone else can confirm this works, I think we can close this issue.