I am calling an external DLL from my PL/I module. The DLL takes a pointer to an array as an input and returns another pointer to an output array, alongwith an error message and a return code.
I have done suitable error handling (in my PL/I module) based on the return code I get back from the DLL. But since there is usage of pointer to arrays, there might be chances that I can get a S0C4 (i.e. memory/pointer execptions) within the DLL CSECTs itself. Unfortunately, I do not have the source code for the DLL (as we have to treat it like a black box due to IP rights), that I can guarantee if exception handlings have been done within the DLL itself. So currently if I get an exception inside the DLL, the error is straightaway captured by my ON ERROR block of my main module and the batch issues a PLIDUMP/CEEDUMP.
I wish to change my error handling in such a manner that I can simply ignore the records for which I get memory issues inside the DLL then write some error messages out and simply continue with the rest of the records, instead of issuing a PLIDUMP or a CEEDUMP.
If I remove the call to PLIDUMP from my ON ERROR block then I would not get the PLIDUMP for other issues (say like a data mismatch i.e. S0C7) from my PL/I code.
So my questions is:
Accessing the TCB from my PL/I module can there be a way that I can determine from which CSECT I am getting my error?
Else I think I will write some C++ wrapper over my DLL like below:
#include "dllexp.h"
#pragma export(CARSDLL)
int DLLEXPORT CARSDLL(
double *dpInputVector, int iInputVectorLength,
double *dpOutputVector, int iOutputVectorLength,
char *szMsgBuffer, int iMsgBufferLength)
{
return risks_msg(dpInputVector, iInputVectorLength,
dpOutputVector, iOutputVectorLength,
szMsgBuffer, iMsgBufferLength);
}
and then use a a catch(std::bad_alloc)
to handle memory exceptions.