[Issue 18504] New: Assert in synchronized crashes with SIGILL on exit

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Feb 23 12:53:02 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=18504

          Issue ID: 18504
           Summary: Assert in synchronized crashes with SIGILL on exit
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: default_357-line at yahoo.de

Testcase:

void main() { synchronized assert(0); }

Expected: Error printed, program exits with error code.

Actual: Error printed, program exits with Illegal Instruction.

What happens:

In 9327d158d457093f5fc064a844f3400515558112 (emit better code for try-finally
when function does not throw) for v2.078.0, Walter added an optimization that
finally blocks can be handled more efficiently if the function does not throw
exceptions.

AssertError is not an exception.

As a result, the mutex of the synchronized{} block is never unlocked.

On program exit, the runtime tries to clean up mutexes at program end.
(_d_critical_term -> destroyMutex -> pthread_mutex_destroy)

pthread_mutex_destroy errors if the mutex is still locked. This triggers the
assert(0), which shows (in release mode) as a ud2: illegal instruction.

--


More information about the Digitalmars-d-bugs mailing list