digitalmars.D.bugs - [Issue 18504] New: Assert in synchronized crashes with SIGILL on exit
- d-bugmail puremagic.com (29/29) Feb 23 2018 https://issues.dlang.org/show_bug.cgi?id=18504
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 puremagic.com Reporter: default_357-line 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. --
Feb 23 2018