Bug 11216 – Make synchronized statement `nothrow`

Status
REOPENED
Severity
enhancement
Priority
P5
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-10-10T06:09:20Z
Last change time
2024-12-07T13:32:57Z
Assigned to
No Owner
Creator
Denis Shelomovskii
Blocks
13561
Moved to GitHub: dmd#17261 →

Comments

Comment #0 by verylonglogin.reg — 2013-10-10T06:09:20Z
Currently this code fails to compile because `_d_criticalenter` and `_d_criticalexit` are not `nothrow`: --- void f() nothrow { synchronized { } } --- This is because user supplied monitor can throw as `lock`/`unlock` methods of `Object.Monitor` are not `nothrow`. Dependent druntime functions like `rt_attachDisposeEvent` and `rt_detachDisposeEvent` are thus not `nothrow` too. The proposal is to mark user supplied monitor `lock`/`unlock` methods also `nothrow`. In the case it will be rejected documentation note about the fact synchronized statement is not `nothrow` should be added.
Comment #1 by verylonglogin.reg — 2013-10-10T06:14:31Z
Also in the case in the description are there any possibilities to supply a user monitor? If not, this subcase is clearly a "rejects-valid" bug.
Comment #2 by code — 2014-10-01T08:18:28Z
I'm in favor of doing this. Is there a migration path for requiring nothrow on the Monitor Interface without breaking code?
Comment #3 by bugzilla — 2014-11-08T04:40:20Z
Comment #4 by github-bugzilla — 2014-11-08T22:40:17Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/47c679964003ca75290e3174df85b0641eb5d282 fix Issue 11216 - Make synchronized statement `nothrow` - mark _d_monitorenter/exit as nothrow https://github.com/D-Programming-Language/dmd/commit/dc118391e51ddb69093780c157b1ca41e26add90 Merge pull request #4115 from MartinNowak/fix11216 fix Issue 11216 - Make synchronized statement `nothrow`
Comment #5 by github-bugzilla — 2014-12-12T15:42:04Z
Commits pushed to master at https://github.com/D-Programming-Language/druntime https://github.com/D-Programming-Language/druntime/commit/05b15ab05279a70b30f4a580c705526e70e09155 fix Issue 11216 - Make synchronized statement `nothrow` - require Object.Monitor lock and unlock functions to be nothrow - change methods of all core.sync classes to nothrow https://github.com/D-Programming-Language/druntime/commit/46061e646ae547d297aeae448eb246e251118344 Merge pull request #1013 from MartinNowak/fix11216 fix Issue 11216 - Make synchronized statement `nothrow`
Comment #6 by github-bugzilla — 2015-02-18T03:38:26Z
Comment #7 by github-bugzilla — 2015-02-18T03:39:19Z
Comment #8 by pro.mathias.lang — 2015-10-18T09:28:15Z
Well, since it was reverted, it should have been reopened. Revert in DMD: https://github.com/D-Programming-Language/dmd/pull/4459 Revert in Druntime: https://github.com/D-Programming-Language/druntime/pull/1188
Comment #9 by mathias.lang — 2016-05-10T17:27:26Z
*** Issue 16009 has been marked as a duplicate of this issue. ***
Comment #10 by default_357-line — 2018-02-23T16:14:19Z
Still an issue in 2018.
Comment #11 by default_357-line — 2018-02-23T16:19:53Z
Istm a possible approach would be: * Define SimpleMonitor : Monitor with nothrow * change DMD to use nothrow when locking SimpleMonitors * subclass druntime's Mutex with SimpleMutex : Mutex, SimpleMonitor * use SimpleMutex as the mutex implementation for class monitors Then synchronized(this) should be nothrow without breaking existing code that depends on Mutex/Monitor. It would only break if you were assigning to _monitor, and that's easily fixed by using a separate member. I don't know how to implement this on the DMD side though.
Comment #12 by robert.schadek — 2024-12-07T13:32:57Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17261 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB