Skip to content

CoreFX native PAL build break on FreeBSD due to "error: mutex 'lock' is not held on every path" #26241

@wfurt

Description

@wfurt

Attempt to build native parts on FreeBSD no longer works. This seems to be related to dotnet/corefx#26291

[furt@FreeBSD-11 ~/git/corefx]$ ./src/Native/build-native.sh -clang3.9
...
[ 44%] Building C object System.Native/CMakeFiles/System.Native-Static.dir/pal_signal.c.o
/usr/home/furt/git/corefx/src/Native/Unix/System.Native/pal_signal.c:151:17: error: mutex 'lock' is not held on every path through here [-Werror,-Wthread-safety-analysis]
if (callback != NULL)
^
/usr/home/furt/git/corefx/src/Native/Unix/System.Native/pal_signal.c:136:17: note: mutex acquired here
pthread_mutex_lock(&lock);
^
/usr/home/furt/git/corefx/src/Native/Unix/System.Native/pal_signal.c:85:1: note: Thread warning in function 'SignalHandlerLoop'
{

by quick looking at the code, there seems to be unbalanced pthread_mutex_lock()
Following change fixes the issue but I'm not sure if that was the intention:

--- a/src/Native/Unix/System.Native/pal_signal.c
+++ b/src/Native/Unix/System.Native/pal_signal.c
@@ -146,6 +146,7 @@ static void* SignalHandlerLoop(void* arg)
                         } while (pid > 0);
                     }
                 }
+                pthread_mutex_unlock(&lock);
             }

             if (callback != NULL)

cc: @tmds @janvorli @mateusrodrigues

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions