Bug 22986 – Phobos cannot be compiled with dip1008

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2022-04-04T11:28:50Z
Last change time
2024-12-13T19:22:01Z
Assigned to
No Owner
Creator
RazvanN
Moved to GitHub: dmd#20081 →

Comments

Comment #0 by razvan.nitu1305 — 2022-04-04T11:28:50Z
Phobos exceptions sometimes escape their catch block, however, dip1008 does not allow that. One example: https://github.com/dlang/phobos/blob/master/std/parallelism.d#L3770 . However, there are others, just try to compile phobos with dip1008. Although the DIP says that the exception can be cloned in this case, the problem is that the user then needs to manually manage the exception (free it). I don't think that this is a phobos problem, rather that dip1008 is too restrictive.
Comment #1 by destructionator — 2022-04-04T12:22:40Z
@nogc is too restrictive and all these hoops we jump through to enable it is reducing the overall quality of D. Would be better if it focused on avoiding leaks outside a function than avoiding all allocations, then as long as you pair your news with deletes, you'd be ok. Anyway, cloning an exception is not easy, you're liable to have random problems with that (remember exceptions are not necessarily allocated with `new` in any case... so if it was malloc'd and you didn't free it, you're in some trouble, but this perhaps rare enough to ignore). I guess you could check the RTTI and bit copy back out the GC upon escaping, and just hope it doesn't have any references to itself. A virtual clone function that can be overridden but whose default digs typeinfo out to work in the general case perhaps would let you escape. Might be worth experimenting with that.
Comment #2 by mail — 2022-04-06T14:07:11Z
(In reply to RazvanN from comment #0) > Phobos exceptions sometimes escape their catch block, however, dip1008 does > not allow that. One example: > https://github.com/dlang/phobos/blob/master/std/parallelism.d#L3770 . > However, there are others, just try to compile phobos with dip1008. This is not a phobos problem, in multithreaded application you will inevitably carry exceptions from one thread to another. DIP 1008 is flawed in that respect. There is also the problem that it is hard to detect statically allocated exceptions, so you end up cloning more than you strictly need to.
Comment #3 by dlang-bot — 2022-04-27T14:11:16Z
@chloekek updated dlang/phobos pull request #8440 "Mark ErrnoException.errno as scope" mentioning this issue: - Issue 22986: Mark ErrnoException.errno as scope This allows retrieval of the error number when compiling with -dip1008. https://github.com/dlang/phobos/pull/8440
Comment #4 by dlang-bot — 2022-04-27T18:55:57Z
dlang/phobos pull request #8440 "Issue 22986: Mark ErrnoException.errno as scope" was merged into master: - 5a36a8c6c97dcafe700ba12c5c2f8f8e4c4e34d2 by chloekek: Issue 22986: Mark ErrnoException.errno as scope This allows retrieval of the error number when compiling with -dip1008. https://github.com/dlang/phobos/pull/8440
Comment #5 by dlang-bot — 2022-05-23T15:35:07Z
@tchaloupka updated dlang/phobos pull request #8467 "Fix 23132 - Avoid ranges copy when compared for equality" mentioning this issue: - Issue 22986: Mark ErrnoException.errno as scope This allows retrieval of the error number when compiling with -dip1008. https://github.com/dlang/phobos/pull/8467
Comment #6 by dlang-bot — 2022-07-13T19:47:03Z
@pbackus updated dlang/phobos pull request #8507 "Fix 23245, 23246 - std.format regressions" mentioning this issue: - Issue 22986: Mark ErrnoException.errno as scope This allows retrieval of the error number when compiling with -dip1008. https://github.com/dlang/phobos/pull/8507
Comment #7 by dlang-bot — 2022-08-03T15:12:02Z
@RubyTheRoobster updated dlang/phobos pull request #8525 "fix issue 23140" mentioning this issue: - Issue 22986: Mark ErrnoException.errno as scope This allows retrieval of the error number when compiling with -dip1008. https://github.com/dlang/phobos/pull/8525
Comment #8 by robert.schadek — 2024-12-13T19:22:01Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20081 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB