[Lldb-commits] [lldb] r237230 - Darwin - fix intermitent crashes in import crashinfo

Ilia K ki.stfu at gmail.com
Wed May 13 09:45:49 PDT 2015


After your changes the ./dotest.py leaves crashinfo.lock file in test dir.
Could you fix it?

Thanks,
Ilia

On Wed, May 13, 2015 at 8:00 AM, Vince Harron <vince at nethacker.com> wrote:

> Author: vharron
> Date: Wed May 13 00:00:23 2015
> New Revision: 237230
>
> URL: http://llvm.org/viewvc/llvm-project?rev=237230&view=rev
> Log:
> Darwin - fix intermitent crashes in import crashinfo
>
> Summary:
> "import crashinfo" was probably failing because multiple dotest invocations
> are all trying to compile crashinfo.so at the same time.
>
> I've put a mutex around the compile step to prevent this.
>
> Reviewers: clayborg, chying
>
> Subscribers: lldb-commits
>
> Differential Revision: http://reviews.llvm.org/D9732
>
>
> Added:
>     lldb/trunk/test/lock.py
> Modified:
>     lldb/trunk/test/dotest.py
>
> Modified: lldb/trunk/test/dotest.py
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=237230&r1=237229&r2=237230&view=diff
>
> ==============================================================================
> --- lldb/trunk/test/dotest.py (original)
> +++ lldb/trunk/test/dotest.py Wed May 13 00:00:23 2015
> @@ -23,6 +23,7 @@ for available options.
>  import commands
>  import os
>  import errno
> +import lock
>  import platform
>  import progress
>  import signal
> @@ -441,11 +442,23 @@ def setupCrashInfoHook():
>          test_dir = os.environ['LLDB_TEST']
>          if not test_dir or not os.path.exists(test_dir):
>              return
> +        dylib_lock = os.path.join(test_dir,"crashinfo.lock")
>          dylib_src = os.path.join(test_dir,"crashinfo.c")
>          dylib_dst = os.path.join(test_dir,"crashinfo.so")
> -        cmd = "SDKROOT= xcrun clang %s -o %s -framework Python -Xlinker
> -dylib -iframework /System/Library/Frameworks/ -Xlinker -F
> /System/Library/Frameworks/" % (dylib_src,dylib_dst)
> -        if subprocess.call(cmd,shell=True) == 0 and
> os.path.exists(dylib_dst):
> -            setCrashInfoHook = setCrashInfoHook_Mac
> +        try:
> +            compile_lock = lock.Lock(dylib_lock)
> +            compile_lock.acquire()
> +            if not os.path.isfile(dylib_dst) or
> os.path.getmtime(dylib_dst) < os.path.getmtime(dylib_src):
> +                # we need to compile
> +                cmd = "SDKROOT= xcrun clang %s -o %s -framework Python
> -Xlinker -dylib -iframework /System/Library/Frameworks/ -Xlinker -F
> /System/Library/Frameworks/" % (dylib_src,dylib_dst)
> +                if subprocess.call(cmd,shell=True) != 0 or not
> os.path.isfile(dylib_dst):
> +                    raise Exception('command failed: "{}"'.format(cmd))
> +        finally:
> +            compile_lock.release()
> +            del compile_lock
> +
> +        setCrashInfoHook = setCrashInfoHook_Mac
> +
>      else:
>          pass
>
>
> Added: lldb/trunk/test/lock.py
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lock.py?rev=237230&view=auto
>
> ==============================================================================
> --- lldb/trunk/test/lock.py (added)
> +++ lldb/trunk/test/lock.py Wed May 13 00:00:23 2015
> @@ -0,0 +1,23 @@
> +"""
> +Interprocess mutex based on file locks
> +"""
> +
> +import fcntl
> +import os
> +
> +class Lock:
> +
> +    def __init__(self, filename):
> +        self.filename = filename
> +        # This will create it if it does not exist already
> +        self.handle = open(filename, 'w')
> +
> +    # Bitwise OR fcntl.LOCK_NB if you need a non-blocking lock
> +    def acquire(self):
> +        fcntl.flock(self.handle, fcntl.LOCK_EX)
> +
> +    def release(self):
> +        fcntl.flock(self.handle, fcntl.LOCK_UN)
> +
> +    def __del__(self):
> +        self.handle.close()
>
>
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150513/82905331/attachment.html>


More information about the lldb-commits mailing list