Re: C signal() and abends not being signaled
On 23/10/2021 1:59 am, Seymour J Metz wrote: S0C1 and S0C4 are ABENDs and caught by SIGABND; what SIGSEGV catches are program checks via an (E)SPIE exit. I'm not sure whether it catches every relevant PIC or only 04. Nope. That's only true if you set the TRAP(ON,NOSPIE) LE runtime option in which case SIGABND signals are handled by LEs ESTAE condition handler. As a side issue, can you catch a data exception, fix the data in the handler and retry the way that you can in a PL/I ON unit? -- Shmuel (Seymour J.) Metz http://mason.gmu.edu/~smetz3 From: IBM Mainframe Discussion List [IBM-MAIN@LISTSERV.UA.EDU] on behalf of David Crayford [dcrayf...@gmail.com] Sent: Thursday, October 21, 2021 8:22 PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: C signal() and abends not being signaled You're using the wrong signal. SIGABND catches abends such as x37. If you want to catch machine checks use SIGSEGV (0C4), SIGILL (0C1) etc. On 19/10/2021 11:03 pm, Jantje. wrote: Esteemed listers, I have the situation that in the vast majority of cases the C program just works fine, but in an infinitesimal small number of cases, it gets a S0C4 abend. I could perhaps, through intricate testing and comparing of lots of things -- and burning huge amounts of CPU in doing so -- prevent the abend from happening, but I would rather avoid the cost of that testing and instead privilege the normal case. So, I thought to use the signal() function to take control in those very few cases where the abend occurs. However... signal or no signal, LE takes that CEEDUMP and the program stops, no matter what. What am I missing? I reduced my program to bare minimum to prove the point. Here is the code: #include #include #include #ifdef __cplusplus extern "C" void StrAbn(int); #else void StrAbn(int); #endif int main(int argc, char *argvݨ) { printf("Setting abend handler\n"); if (signal(SIGABND, StrAbn) == SIG_ERR) { perror("Could not signal user signal"); abort(); } else { printf("Abend handler set\n"); } printf("This must cause an abend\n"); strcpy(0,"Coucou"); printf("Continuing after abend\n"); return(0); } void StrAbn(int SIG_TYPE) { printf("Trapped a vicious abend\n"); signal(SIG_TYPE, SIG_IGN); printf("Exiting after the abend\n"); exit(0); } The output says: Setting abend handler Abend handler set This must cause an abend and it does cause an abend. But control does not come to my signal handling routine. The "Trapped a vicious abend" never appears. I have been reading up on LE condition handling and on the use of the signal() function, and I have searched the archives of this very list. All to no avail. For what it is worth: I do see the following LE options: ABPERC(NONE) ABTERMENC(ABEND) DEBUG POSIX(OFF) NOTEST(ALL,"*","PROMPT","INSPPREF") TRAP(ON,SPIE) So, what do I need to do to actually trap that abend and get control back in my program when it happens? Any and all suggestions are welcome. Thanks and very best regards, Jantje. -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: C signal() and abends not being signaled
S0C1 and S0C4 are ABENDs and caught by SIGABND; what SIGSEGV catches are program checks via an (E)SPIE exit. I'm not sure whether it catches every relevant PIC or only 04. As a side issue, can you catch a data exception, fix the data in the handler and retry the way that you can in a PL/I ON unit? -- Shmuel (Seymour J.) Metz http://mason.gmu.edu/~smetz3 From: IBM Mainframe Discussion List [IBM-MAIN@LISTSERV.UA.EDU] on behalf of David Crayford [dcrayf...@gmail.com] Sent: Thursday, October 21, 2021 8:22 PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: C signal() and abends not being signaled You're using the wrong signal. SIGABND catches abends such as x37. If you want to catch machine checks use SIGSEGV (0C4), SIGILL (0C1) etc. On 19/10/2021 11:03 pm, Jantje. wrote: > Esteemed listers, > > I have the situation that in the vast majority of cases the C program just > works fine, but in an infinitesimal small number of cases, it gets a S0C4 > abend. I could perhaps, through intricate testing and comparing of lots of > things -- and burning huge amounts of CPU in doing so -- prevent the abend > from happening, but I would rather avoid the cost of that testing and instead > privilege the normal case. > > So, I thought to use the signal() function to take control in those very few > cases where the abend occurs. > > However... > > signal or no signal, LE takes that CEEDUMP and the program stops, no matter > what. > > What am I missing? > > I reduced my program to bare minimum to prove the point. Here is the code: > > #include > #include > #include > #ifdef __cplusplus >extern "C" void StrAbn(int); > #else >void StrAbn(int); > #endif > int main(int argc, char *argvݨ) { >printf("Setting abend handler\n"); >if (signal(SIGABND, StrAbn) == SIG_ERR) { > perror("Could not signal user signal"); > abort(); >} else { > printf("Abend handler set\n"); >} >printf("This must cause an abend\n"); >strcpy(0,"Coucou"); >printf("Continuing after abend\n"); >return(0); > } > void StrAbn(int SIG_TYPE) { >printf("Trapped a vicious abend\n"); >signal(SIG_TYPE, SIG_IGN); >printf("Exiting after the abend\n"); >exit(0); > } > > The output says: > > Setting abend handler > Abend handler set > This must cause an abend > > and it does cause an abend. But control does not come to my signal handling > routine. The "Trapped a vicious abend" never appears. > I have been reading up on LE condition handling and on the use of the > signal() function, and I have searched the archives of this very list. All to > no avail. > > For what it is worth: I do see the following LE options: > > ABPERC(NONE) > ABTERMENC(ABEND) > DEBUG > POSIX(OFF) > NOTEST(ALL,"*","PROMPT","INSPPREF") > TRAP(ON,SPIE) > > So, what do I need to do to actually trap that abend and get control back in > my program when it happens? > > Any and all suggestions are welcome. > > Thanks and very best regards, > > Jantje. > > -- > For IBM-MAIN subscribe / signoff / archive access instructions, > send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: C signal() and abends not being signaled
On 22/10/2021 5:18 pm, Jantje. wrote: That said, as @Joe says, the C signal handling is not real conducive to "make note of the problem and continue on where you were" processing. O, and returning from the signal handler does indeed resume processing after the instruction that caused the abend. No need jumping through neither SPIE nor STAE hoops. Not a good idea. If your program fails with an 0C4 then it's broken and the output is not reliable. Best thing to do is print a message and shut down. But then if you don't have a dump you've thrown off the life jacket before you've set sail. -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: C signal() and abends not being signaled
On Tue, 19 Oct 2021 09:13:09 -0700, Charles Mills wrote: >I have a lot of experience with catching signals in a "conventional MVS" >started task written in C++. (Signal handling is a C function but also >available in C++.) In my experience the signal handler was perfect at catching >S0C4 type exceptions with SIGSEGV. > Catching the SIGSEGV does the job. *THANKS!* >That said, as @Joe says, the C signal handling is not real conducive to "make >note of the problem and continue on where you were" processing. > O, and returning from the signal handler does indeed resume processing after the instruction that caused the abend. No need jumping through neither SPIE nor STAE hoops. Cheers, Jantje. -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: C signal() and abends not being signaled
You will also want TRAP(OFF) in your LE options otherwise LE will always intercept any abend. Robin -Original Message- From: IBM Mainframe Discussion List On Behalf Of David Crayford Sent: 22 October 2021 07:23 To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: C signal() and abends not being signaled You're using the wrong signal. SIGABND catches abends such as x37. If you want to catch machine checks use SIGSEGV (0C4), SIGILL (0C1) etc. On 19/10/2021 11:03 pm, Jantje. wrote: > Esteemed listers, > > I have the situation that in the vast majority of cases the C program just > works fine, but in an infinitesimal small number of cases, it gets a S0C4 > abend. I could perhaps, through intricate testing and comparing of lots of > things -- and burning huge amounts of CPU in doing so -- prevent the abend > from happening, but I would rather avoid the cost of that testing and instead > privilege the normal case. > > So, I thought to use the signal() function to take control in those very few > cases where the abend occurs. > > However... > > signal or no signal, LE takes that CEEDUMP and the program stops, no matter > what. > > What am I missing? > > I reduced my program to bare minimum to prove the point. Here is the code: > > #include > #include > #include > #ifdef __cplusplus >extern "C" void StrAbn(int); > #else >void StrAbn(int); > #endif > int main(int argc, char *argvݨ) { >printf("Setting abend handler\n"); >if (signal(SIGABND, StrAbn) == SIG_ERR) { > perror("Could not signal user signal"); > abort(); >} else { > printf("Abend handler set\n"); >} >printf("This must cause an abend\n"); >strcpy(0,"Coucou"); >printf("Continuing after abend\n"); >return(0); > } > void StrAbn(int SIG_TYPE) { >printf("Trapped a vicious abend\n"); >signal(SIG_TYPE, SIG_IGN); >printf("Exiting after the abend\n"); >exit(0); > } > > The output says: > > Setting abend handler > Abend handler set > This must cause an abend > > and it does cause an abend. But control does not come to my signal handling > routine. The "Trapped a vicious abend" never appears. > I have been reading up on LE condition handling and on the use of the > signal() function, and I have searched the archives of this very list. All to > no avail. > > For what it is worth: I do see the following LE options: > > ABPERC(NONE) > ABTERMENC(ABEND) > DEBUG > POSIX(OFF) > NOTEST(ALL,"*","PROMPT","INSPPREF") > TRAP(ON,SPIE) > > So, what do I need to do to actually trap that abend and get control back in > my program when it happens? > > Any and all suggestions are welcome. > > Thanks and very best regards, > > Jantje. > > -- > For IBM-MAIN subscribe / signoff / archive access instructions, send > email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: C signal() and abends not being signaled
You're using the wrong signal. SIGABND catches abends such as x37. If you want to catch machine checks use SIGSEGV (0C4), SIGILL (0C1) etc. On 19/10/2021 11:03 pm, Jantje. wrote: Esteemed listers, I have the situation that in the vast majority of cases the C program just works fine, but in an infinitesimal small number of cases, it gets a S0C4 abend. I could perhaps, through intricate testing and comparing of lots of things -- and burning huge amounts of CPU in doing so -- prevent the abend from happening, but I would rather avoid the cost of that testing and instead privilege the normal case. So, I thought to use the signal() function to take control in those very few cases where the abend occurs. However... signal or no signal, LE takes that CEEDUMP and the program stops, no matter what. What am I missing? I reduced my program to bare minimum to prove the point. Here is the code: #include #include #include #ifdef __cplusplus extern "C" void StrAbn(int); #else void StrAbn(int); #endif int main(int argc, char *argvݨ) { printf("Setting abend handler\n"); if (signal(SIGABND, StrAbn) == SIG_ERR) { perror("Could not signal user signal"); abort(); } else { printf("Abend handler set\n"); } printf("This must cause an abend\n"); strcpy(0,"Coucou"); printf("Continuing after abend\n"); return(0); } void StrAbn(int SIG_TYPE) { printf("Trapped a vicious abend\n"); signal(SIG_TYPE, SIG_IGN); printf("Exiting after the abend\n"); exit(0); } The output says: Setting abend handler Abend handler set This must cause an abend and it does cause an abend. But control does not come to my signal handling routine. The "Trapped a vicious abend" never appears. I have been reading up on LE condition handling and on the use of the signal() function, and I have searched the archives of this very list. All to no avail. For what it is worth: I do see the following LE options: ABPERC(NONE) ABTERMENC(ABEND) DEBUG POSIX(OFF) NOTEST(ALL,"*","PROMPT","INSPPREF") TRAP(ON,SPIE) So, what do I need to do to actually trap that abend and get control back in my program when it happens? Any and all suggestions are welcome. Thanks and very best regards, Jantje. -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: C signal() and abends not being signaled
I have a lot of experience with catching signals in a "conventional MVS" started task written in C++. (Signal handling is a C function but also available in C++.) In my experience the signal handler was perfect at catching S0C4 type exceptions with SIGSEGV. That said, as @Joe says, the C signal handling is not real conducive to "make note of the problem and continue on where you were" processing. If you want to do that I think you are either going to have to figure out how to make it happen with longjmp() (with which I have no experience: I think perhaps it is not a C++ thing) or else hack your way through TRAP(NOSPIE) and writing your on ESPIE invocation and handler in assembler. The latter is more or less what I did, but for the more complex situation of ESTAEX. I no longer "own" the code I wrote to do that and so I am not at liberty to share it. Charles -Original Message- From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf Of Jantje. Sent: Tuesday, October 19, 2021 8:04 AM To: IBM-MAIN@LISTSERV.UA.EDU Subject: C signal() and abends not being signaled Esteemed listers, I have the situation that in the vast majority of cases the C program just works fine, but in an infinitesimal small number of cases, it gets a S0C4 abend. I could perhaps, through intricate testing and comparing of lots of things -- and burning huge amounts of CPU in doing so -- prevent the abend from happening, but I would rather avoid the cost of that testing and instead privilege the normal case. So, I thought to use the signal() function to take control in those very few cases where the abend occurs. However... signal or no signal, LE takes that CEEDUMP and the program stops, no matter what. What am I missing? -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
Re: C signal() and abends not being signaled
"When the SIGABND signal is registered with an address of a C handler using the signal() function, control cannot resume at the instruction following the abend or the invocation of raise() with SIGABND. If the C signal handler is returned, the abend is percolated and the default behavior occurs. The longjmp() or exit() function can be invoked from the handler to control the behavior. "If SIG_IGN is the specified action for SIGABND and an abend occurs (or SIGABND was raised), the abend will not be ignored because a resume cannot occur. The abend will percolate and the default action will occur. https://www.ibm.com/docs/en/zos/2.3.0?topic=SSLTBW_2.3.0/com.ibm.zos.v2r3.cbcpx01/cbc1p2321.htm Joe On Tue, Oct 19, 2021 at 10:03 AM Jantje. < 033acf17e42f-dmarc-requ...@listserv.ua.edu> wrote: > Esteemed listers, > > I have the situation that in the vast majority of cases the C program just > works fine, but in an infinitesimal small number of cases, it gets a S0C4 > abend. I could perhaps, through intricate testing and comparing of lots of > things -- and burning huge amounts of CPU in doing so -- prevent the abend > from happening, but I would rather avoid the cost of that testing and > instead privilege the normal case. > > So, I thought to use the signal() function to take control in those very > few cases where the abend occurs. > > However... > > signal or no signal, LE takes that CEEDUMP and the program stops, no > matter what. > > What am I missing? > > I reduced my program to bare minimum to prove the point. Here is the code: > > #include > #include > #include > #ifdef __cplusplus > extern "C" void StrAbn(int); > #else > void StrAbn(int); > #endif > int main(int argc, char *argvݨ) { > printf("Setting abend handler\n"); > if (signal(SIGABND, StrAbn) == SIG_ERR) { > perror("Could not signal user signal"); > abort(); > } else { > printf("Abend handler set\n"); > } > printf("This must cause an abend\n"); > strcpy(0,"Coucou"); > printf("Continuing after abend\n"); > return(0); > } > void StrAbn(int SIG_TYPE) { > printf("Trapped a vicious abend\n"); > signal(SIG_TYPE, SIG_IGN); > printf("Exiting after the abend\n"); > exit(0); > } > > The output says: > > Setting abend handler > Abend handler set > This must cause an abend > > and it does cause an abend. But control does not come to my signal > handling routine. The "Trapped a vicious abend" never appears. > I have been reading up on LE condition handling and on the use of the > signal() function, and I have searched the archives of this very list. All > to no avail. > > For what it is worth: I do see the following LE options: > > ABPERC(NONE) > ABTERMENC(ABEND) > DEBUG > POSIX(OFF) > NOTEST(ALL,"*","PROMPT","INSPPREF") > TRAP(ON,SPIE) > > So, what do I need to do to actually trap that abend and get control back > in my program when it happens? > > Any and all suggestions are welcome. > > Thanks and very best regards, > > Jantje. > > -- > For IBM-MAIN subscribe / signoff / archive access instructions, > send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN > -- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN