Skip to content

Conversation

@bencoman
Copy link

@bencoman bencoman commented Jun 24, 2016

Following on from my mail list post...
    http://forum.world.st/Can-t-infer-base-LD-LIBRARY-PATH-td4896471.html

the `squeak` run script has LD_LIBRARY_PATH hardcoded for a dozen platforms,
but after reformatting the case statement a pattern was apparent...

    /lib/libc*)             
        SVMLLP="/lib                
           :/usr/lib";;

    /lib32/libc*)               
        SVMLLP="/lib32              
           :/usr/lib32";;

    /lib64/libc*)               
        SVMLLP="/lib64              
           :/usr/lib64";;

    /lib/tls/libc*)     
        SVMLLP="/lib/tls                        :    /lib
           :/usr/lib/tls                        :/usr/lib";;

    /lib/i386-linux-gnu/libc*)  \
        SVMLLP="/lib/i386-linux-gnu             :    /lib 
           :/usr/lib/i386-linux-gnu             :/usr/lib";;

    /lib/i386-linux-gnu/i686/cmov/libc*)    \
        SVMLLP="/lib/i386-linux-gnu/i686/cmov   :    /lib 
           :/usr/lib/i386-linux-gnu/i686/cmov   :/usr/lib";;

    /lib/386-linux-gnu/i686/cmov/libc*) \
        SVMLLP="/lib/386-linux-gnu/i686/cmov    :    /lib 
           :/usr/lib/386-linux-gnu/i686/cmov    :/usr/lib";;

    /lib/tls/i686/cmov/libc*)   \
        SVMLLP="/lib/tls/i686/cmov              :    /lib 
           :/usr/lib/tls/i686/cmov              :/usr/lib";;

    /lib/tls/i686/nosegneg/libc*)   \
        SVMLLP="/lib/i686/nosegneg/tls          :    /lib 
           :/usr/lib/i686/nosegneg/tls          :/usr/lib";;

    /lib/arm-linux-gnueabihf/libc*) \
        SVMLLP="/lib/arm-linux-gnueabihf        :    /lib 
           :/usr/lib/arm-linux-gnueabihf        :/usr/lib";;

    /lib/x86_64-linux-gnu/libc*)    \
        SVMLLP="/lib/x86_64-linux-gnu           :    /lib 
           :/usr/lib/x86_64-linux-gnu           :/usr/lib";;


that could be reduced to...
    PLATFORMLIBDIR=`expr "$LIBC_SO" : '\(.*\)/libc.*'`
    SVMLLP="$PLATFORMLIBDIR:/lib:/usr$PLATFORMLIBDIR:/usr/lib"


So this fixes my platform that the original was failing on, 
AND should work for most future platforms so users never see a failure 
for new platform that would otherwise need to another hard coded case.


Now one semantic has changed.  I couldn't determine how to run `cmd1 || cmd2` 
without it complaining about a missing cmd1 showing on the console.  
But the problem exists in original, which you can observe by swapping the
order of `/bin/uname` and `/usr/bin/uname`,  and then you get... 
     ./squeak: line 25: /usr/bin/uname: No such file or directory
So I just used plain `uname` .  Do we really care which one is used??  

@eliotmiranda eliotmiranda merged commit 12a3686 into OpenSmalltalk:Cog Jun 24, 2016
@bencoman bencoman deleted the generalise-LD_LIBRARY_PATH branch October 9, 2016 01:11
lukego added a commit to studio/opensmalltalk-vm that referenced this pull request Feb 25, 2019
frontend: More of the initial Pharo code...
nicolas-cellier-aka-nice added a commit that referenced this pull request Sep 21, 2019
Two things:
1) according to https://developer.apple.com/documentation/audiotoolbox/kaudioqueueproperty_isrunning
  the property is a UInt32, not  a sqInt (a sqInt can be 64 bits long, thus might be not entirely set)
2) nothing tells that the value is a valid boolean value, only that is running if != 0
  if I compile with -fsanitize=undefined, i get this:

>Process 5149 stopped
>* thread #9, name = 'com.apple.coreaudio.AQClient', stop reason = Invalid bool load
>    frame #0: 0x000000010090b230 libclang_rt.ubsan_osx_dynamic.dylib`__ubsan_on_report
> libclang_rt.ubsan_osx_dynamic.dylib`__ubsan_on_report:
> ->  0x10090b230 <+0>: pushq  %rbp
>    0x10090b231 <+1>: movq   %rsp, %rbp
>    0x10090b234 <+4>: popq   %rbp
>    0x10090b235 <+5>: retq
>Target 0: (Squeak) stopped.
>(lldb) bt
>* thread #9, name = 'com.apple.coreaudio.AQClient', stop reason = Invalid bool load
>  * frame #0: 0x000000010090b230 libclang_rt.ubsan_osx_dynamic.dylib`__ubsan_on_report
>    frame #1: 0x0000000100905f6c libclang_rt.ubsan_osx_dynamic.dylib`__ubsan::Diag::~Diag() + 140
>    frame #2: 0x0000000100909ab9 libclang_rt.ubsan_osx_dynamic.dylib`handleLoadInvalidValue(__ubsan::InvalidValueData*, unsigned long, __ubsan::ReportOptions) + 505
>    frame #3: 0x00000001009098b4 libclang_rt.ubsan_osx_dynamic.dylib`__ubsan_handle_load_invalid_value + 68
>    frame #4: 0x00000001004f36ef Squeak`-[sqSqueakSoundCoreAudio setOutputIsRunning:](self=0x00000001021183a0, _cmd="setOutputIsRunning:", outputIsRunning=110) at sqSqueakSoundCoreAudio.h:0
>    frame #5: 0x00000001004ecc6e Squeak`MyAudioQueuePropertyListener(inUserData=0x00000001021183a0, inAQ=0x000000000141d000, inID=1634824814) at sqSqueakSoundCoreAudio.m:90
 >   frame #6: 0x00007fff412ff0b2 AudioToolbox`ClientAudioQueue::PropertyChanged(unsigned int) + 518
 >   frame #7: 0x00007fff412fed65 AudioToolbox`AQClientCallbackMessageReader::DispatchCallbacks(void const*, unsigned long) + 195
 >   frame #8: 0x00007fff412e6ac5 AudioToolbox`ClientAudioQueue::FetchAndDeliverPendingCallbacks(unsigned int) + 291
 >   frame #9: 0x00007fff412e6921 AudioToolbox`AQCallbackReceiver_CallbackNotificationsAvailable + 121
 >   frame #10: 0x00007fff412e66a5 AudioToolbox`_XCallbackNotificationsAvailable + 33
 >   frame #11: 0x00007fff412e64b2 AudioToolbox`mshMIGPerform + 230
 >   frame #12: 0x00007fff42967f39 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 41
 >   frame #13: 0x00007fff42967e85 CoreFoundation`__CFRunLoopDoSource1 + 533
 >   frame #14: 0x00007fff4295fa40 CoreFoundation`__CFRunLoopRun + 2848
 >   frame #15: 0x00007fff4295ec93 CoreFoundation`CFRunLoopRunSpecific + 483
 >   frame #16: 0x00007fff412c340a AudioToolbox`GenericRunLoopThread::Entry(void*) + 158

I think it's benign, but let's not depend on UB...
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

Successfully merging this pull request may close these issues.

2 participants