digitalmars.D.learn - Access Vialotation
- Qian Xu (23/23) Feb 27 2009 Hi All,
- Qian Xu (1/1) Feb 27 2009 UPDATE: I am using gdc compiler in Linux
- Jarrett Billingsley (8/29) Feb 27 2009 a
- BCS (3/15) Feb 27 2009 you can have a posix signal handler throw an exception (I have done it a...
- Jarrett Billingsley (4/6) Feb 27 2009 Yeah, that seems dubious to me. I don't know what kinds of
- downs (2/21) Feb 28 2009 In my experience, that works exactly once.
- Christopher Wright (3/23) Feb 28 2009 So you can use the signal handler to print a stack trace and maybe some
- BCS (7/13) Feb 28 2009 That would match with what I needed: poor man's stack tracing
- Qian Xu (6/28) Mar 03 2009 it does not work with gdc.
Hi All, Is there any way to keep program alive, when an AV takes place? -- demo ------------------------------- module NullPointerExceptionTest; class Foo { void bar() {} } void main() { Foo foo; // foo is still NULL try { foo.bar(); // A NullPointerException will be thrown } catch (Exception E) { // Can I catch this NullPointerException? } } ---------------------------------------- The program will crash, when the line "foo.bar()" is executed, even when a try-catch-block is added. So far as I know, Java and Delphi can prevent such kind of crashes from happening with a try-catch-block. Is it possible in D? Best regards --Qian
Feb 27 2009
On Fri, Feb 27, 2009 at 9:01 AM, Qian Xu <quian.xu stud.tu-ilmenau.de> wrot= e:Hi All, Is there any way to keep program alive, when an AV takes place? -- demo ------------------------------- module NullPointerExceptionTest; class Foo { =A0void bar() {} } void main() { =A0Foo foo; // foo is still NULL =A0try { =A0 =A0foo.bar(); // A NullPointerException will be thrown =A0} =A0catch (Exception E) { =A0 =A0// Can I catch this NullPointerException? =A0} } ---------------------------------------- The program will crash, when the line "foo.bar()" is executed, even when =atry-catch-block is added. So far as I know, Java and Delphi can prevent such kind of crashes from happening with a try-catch-block. Is it possibl=ein D?It's possible on Windows in D, but that's because Windows reports segfaults with the same mechanism that D uses for exceptions. Since Linux (and many other Posix systems) uses signals, it's probably very tricky to implement in a cross-platform manner.
Feb 27 2009
Reply to Jarrett,On Fri, Feb 27, 2009 at 9:01 AM, Qian Xu <quian.xu stud.tu-ilmenau.de> wrote:you can have a posix signal handler throw an exception (I have done it and had it work) but I have no idea if it is supported.Hi All, Is there any way to keep program alive, when an AV takes place?It's possible on Windows in D, but that's because Windows reports segfaults with the same mechanism that D uses for exceptions. Since Linux (and many other Posix systems) uses signals, it's probably very tricky to implement in a cross-platform manner.
Feb 27 2009
On Fri, Feb 27, 2009 at 2:31 PM, BCS <ao pathlink.com> wrote:you can have a posix signal handler throw an exception (I have done it and had it work) but I have no idea if it is supported.Yeah, that seems dubious to me. I don't know what kinds of guarantees, if any, the signal handler has as to what thread it's called in (if any) etc.
Feb 27 2009
BCS wrote:Reply to Jarrett,In my experience, that works exactly once.On Fri, Feb 27, 2009 at 9:01 AM, Qian Xu <quian.xu stud.tu-ilmenau.de> wrote:you can have a posix signal handler throw an exception (I have done it and had it work) but I have no idea if it is supported.Hi All, Is there any way to keep program alive, when an AV takes place?It's possible on Windows in D, but that's because Windows reports segfaults with the same mechanism that D uses for exceptions. Since Linux (and many other Posix systems) uses signals, it's probably very tricky to implement in a cross-platform manner.
Feb 28 2009
downs wrote:BCS wrote:So you can use the signal handler to print a stack trace and maybe some context, but throwing an exception that you then catch is dangerous.Reply to Jarrett,In my experience, that works exactly once.On Fri, Feb 27, 2009 at 9:01 AM, Qian Xu <quian.xu stud.tu-ilmenau.de> wrote:you can have a posix signal handler throw an exception (I have done it and had it work) but I have no idea if it is supported.Hi All, Is there any way to keep program alive, when an AV takes place?It's possible on Windows in D, but that's because Windows reports segfaults with the same mechanism that D uses for exceptions. Since Linux (and many other Posix systems) uses signals, it's probably very tricky to implement in a cross-platform manner.
Feb 28 2009
Hello downs,BCS:That would match with what I needed: poor man's stack tracing int EveryFunction() { scope(failure) writef("%s:%s\n",__FILE__,__LINE__); ... }you can have a posix signal handler throw an exception (I have done it and had it work) but I have no idea if it is supported.In my experience, that works exactly once.
Feb 28 2009
BCS wrote:Hello downs,it does not work with gdc. d2.0 does not have problem with NullPointerException at all. -- Xu, Qian (stanleyxu) http://stanleyxu2005.blogspot.comBCS:That would match with what I needed: poor man's stack tracing int EveryFunction() { scope(failure) writef("%s:%s\n",__FILE__,__LINE__); ... }you can have a posix signal handler throw an exception (I have done it and had it work) but I have no idea if it is supported.In my experience, that works exactly once.
Mar 03 2009