ctrl+c and destructors
Maxim Fomin
maxim at maxim-fomin.ru
Tue Oct 1 13:16:04 PDT 2013
On Tuesday, 1 October 2013 at 19:55:17 UTC, monarch_dodra wrote:
> On Tuesday, 1 October 2013 at 03:58:04 UTC, Nick Sabalausky
> wrote:
>> You know, this sounds like something that really should fall
>> squarely in
>> the category of "do the right thing by default". Is there any
>> reason
>> druntime can't be made to handle this better by default?
>
> Well, arguably, a segfault is a catastrophic error, even more
> serious than an assert.
In linux assert(0) causes a segfault. And the fact that detected
by OS memory error is sigfault at linux and exception on windows
really hurts portability.
> I'm not sure what "the right thing" would even be, apart from
> dying right there and then...?
>
> Even just throwing an error could be problematic (AFAIK).
Druntime can catch SIGINT and throw the exception. This means
that D runtime can be easily broken by silly C code which uses
its own signal handlers. I didn't tested, but believe this is
already the case with respect to SIGUSR1 and SIGUSR2 which are
used by druntime, so any simple code hijacking the signals can
break runtime. Linux signals handlers as error mechanism is a
complete disaster.
More information about the Digitalmars-d
mailing list