Re: [Oorexx-devel] Strange observation, RFC
On 01.06.2022 12:20, Rick McGuire wrote: On Wed, Jun 1, 2022 at 6:11 AM Rony G. Flatscher wrote: While debugging orexxole.cpp I am using the existing function pszDbgVarType(vt) which returns a pointer to a zero terminated string which gets defined for the entire program as CHAR szDbg[255]. The same buffer is used by pszDbgInvKind(), pszDbgTypekind(), pszDbgParmFlags() and pszDbVariant(). With the exception of pszDbgVarType() these debug functions are there but not used AFAICT. It allows to get a human readable string of the type 'vt' represents, e.g. "VT_ARRAY VT_VARIANT", "VT_R8" and the like. The strange observation is using pszDbgVarType() multiple times in a single debug statement like: if (*pDestVt & VT_ARRAY)// an array in hand { VARTYPE tmpVt = *pDestVt & VT_TYPEMASK; *fprintf(stderr, "orexxole.cpp # %d %s: --- b) VT_ARRAY: type=[%s] *pDestVt=[%s][d=%d][x%08x] %s tmpVt=[%s][d=%d][x%08x] | VT_ARRAY=[%s][d=%d][x%08x], VT_R8=[%s][d=%d][x%08x] \n\n",__LINE__, __FUNCTION__,"VT_ARRAY",pszDbgVarType( *pDestVt ), *pDestVt , *pDestVt," /\\ ",pszDbgVarType( tmpVt ), tmpVt , tmpVt,pszDbgVarType(VT_ARRAY), VT_ARRAY, VT_ARRAY,pszDbgVarType(VT_R8), VT_R8, VT_R8);*** } So there are four invocations of pszDbgVarType() with four different variables. The ouput is surprisingly: ... cut ... oorexxole.cpp # 419 pszDbgVarType, vt: d=[5] [x0005] -> szDbg=[VT_R8] (return value) oorexxole.cpp # 419 pszDbgVarType, vt: d=[0] [x] -> szDbg=[VT_ARRAY VT_EMPTY] (return value) oorexxole.cpp # 419 pszDbgVarType, vt: d=[5] [x0005] -> szDbg=[VT_R8] (return value) oorexxole.cpp # 419 pszDbgVarType, vt: d=[5] [x0005] -> szDbg=[VT_ARRAY VT_R8] (return value) (added linebreaks for better legibility): *orexxole.cpp # 4359 checkForOverride: --- b) VT_ARRAY: type=[VT_ARRAY] *pDestVt=[VT_ARRAY VT_R8][d=8197][x2005] /\ tmpVt=[VT_ARRAYVT_R8][d=5][x0005] | VT_ARRAY=[VT_ARRAY VT_R8][d=8192][x2000], VT_R8=[VT_ARRAY VT_R8][d=5][x0005]*** Line # 419 above is a debug statement in pszDbgVarType() displaying the value it returns. It uses strcat() with the szDbg buffer which upon entry in this function sets element 0 to 0. VT_ARRAY has the decimal value 8192 (x2000), VT_R8 the decimal value 5 (x0005), hence the following should be shown: pszDbgVarType(*pDestVt): "VT_ARRAY VT_R8" pszDbgVarType(tmpVt) : "VT_R8" (VT_TYPEMASK is defined as xFFF) pszDbgVarType(VT_ARRAY): "VT_ARRAY" pszDbgVarType(VT_R8) : "VT_R8" It is as if for some of those invocations of pszDbvVarType the wrong buffer gets returned, hence displaying wrong information. Well, if the buffer gets reused, then each invocation is going to overlay the information from the previous call, so fprintf() will be using the information from the last call when it formats. Ah, I see, that explains it, thank you very much! Of course, having spent an enormeous amount of time debugging I might have arrived at a point where I overlook the obvious, hence this posting requesting comments. ---rony P.S.: Contemplating to change the pszDbg...() functions to force a buffer to be supplied rather than using a single global buffer, noticing that at least pszDbgVarType() gets also used by orexxole.cpp. This way no wrong optimizations should be applicable and also multithreaded usage of oorexxole.cpp would be improved. Just make sure the allocated buffer gets released afterwards. This change is likely to be an incredible pain to accomplish. Will make sure that that happens (this will take some time as the next slot to work on this is about to close and reopens this weekend due to my currently quite high workload). ---rony ___ Oorexx-devel mailing list Oorexx-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/oorexx-devel
Re: [Oorexx-devel] Strange observation, RFC
On Wed, Jun 1, 2022 at 6:11 AM Rony G. Flatscher wrote: > While debugging orexxole.cpp I am using the existing function > pszDbgVarType(vt) which returns a pointer to a zero terminated string which > gets defined for the entire program as CHAR szDbg[255]. The same buffer is > used by pszDbgInvKind(), pszDbgTypekind(), pszDbgParmFlags() and > pszDbVariant(). With the exception of pszDbgVarType() these debug functions > are there but not used AFAICT. > > It allows to get a human readable string of the type 'vt' represents, e.g. > "VT_ARRAY VT_VARIANT", "VT_R8" and the like. > > The strange observation is using pszDbgVarType() multiple times in a > single debug statement like: > > if (*pDestVt & VT_ARRAY)// an array in hand > { > VARTYPE tmpVt = *pDestVt & VT_TYPEMASK; > *fprintf(stderr, "orexxole.cpp # %d %s: --- b) VT_ARRAY: type=[%s] > *pDestVt=[%s][d=%d][x%08x] %s tmpVt=[%s][d=%d][x%08x] | > VT_ARRAY=[%s][d=%d][x%08x], VT_R8=[%s][d=%d][x%08x] \n\n",**__LINE__, > __FUNCTION__,**"VT_ARRAY",**pszDbgVarType( *pDestVt ), > *pDestVt , *pDestVt,**" /\\ ",**pszDbgVarType( tmpVt ), > tmpVt , tmpVt,**pszDbgVarType(VT_ARRAY), VT_ARRAY, VT_ARRAY,** > pszDbgVarType(VT_R8), VT_R8, VT_R8**);*} > > So there are four invocations of pszDbgVarType() with four different > variables. The ouput is surprisingly: > > ... cut ... > oorexxole.cpp # 419 pszDbgVarType, vt: d=[5] [x0005] -> szDbg=[VT_R8] > (return value) > oorexxole.cpp # 419 pszDbgVarType, vt: d=[0] [x] -> szDbg=[VT_ARRAY > VT_EMPTY] (return value) > oorexxole.cpp # 419 pszDbgVarType, vt: d=[5] [x0005] -> szDbg=[VT_R8] > (return value) > oorexxole.cpp # 419 pszDbgVarType, vt: d=[5] [x0005] -> szDbg=[VT_ARRAY > VT_R8] (return value) >(added linebreaks for better legibility):*orexxole.cpp # 4359 > checkForOverride: --- b) VT_ARRAY: type=[VT_ARRAY] >*pDestVt=[VT_ARRAY VT_R8][d=8197][x2005] /\ > tmpVt=[VT_ARRAY* *VT_R8][d=5][x0005] | >VT_ARRAY=[VT_ARRAY VT_R8][d=8192][x2000], > VT_R8=[VT_ARRAY VT_R8][d=5][x0005]* > > Line # 419 above is a debug statement in pszDbgVarType() displaying the > value it returns. It uses strcat() with the szDbg buffer which upon entry > in this function sets element 0 to 0. > > VT_ARRAY has the decimal value 8192 (x2000), VT_R8 the decimal value 5 > (x0005), hence the following should be shown: > > pszDbgVarType(*pDestVt): "VT_ARRAY VT_R8" > pszDbgVarType(tmpVt) : "VT_R8" (VT_TYPEMASK is defined as xFFF) > pszDbgVarType(VT_ARRAY): "VT_ARRAY" > pszDbgVarType(VT_R8) : "VT_R8" > > It is as if for some of those invocations of pszDbvVarType the wrong > buffer gets returned, hence displaying wrong information. > Well, if the buffer gets reused, then each invocation is going to overlay the information from the previous call, so fprintf() will be using the information from the last call when it formats. Of course, having spent an enormeous amount of time debugging I might have > arrived at a point where I overlook the obvious, hence this posting > requesting comments. > > ---rony > > P.S.: Contemplating to change the pszDbg...() functions to force a buffer > to be supplied rather than using a single global buffer, noticing that at > least pszDbgVarType() gets also used by orexxole.cpp. This way no wrong > optimizations should be applicable and also multithreaded usage of > oorexxole.cpp would be improved. > Just make sure the allocated buffer gets released afterwards. This change is likely to be an incredible pain to accomplish. Rick > > ___ > Oorexx-devel mailing list > Oorexx-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/oorexx-devel > ___ Oorexx-devel mailing list Oorexx-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/oorexx-devel
[Oorexx-devel] Strange observation, RFC
While debugging orexxole.cpp I am using the existing function pszDbgVarType(vt) which returns a pointer to a zero terminated string which gets defined for the entire program as CHAR szDbg[255]. The same buffer is used by pszDbgInvKind(), pszDbgTypekind(), pszDbgParmFlags() and pszDbVariant(). With the exception of pszDbgVarType() these debug functions are there but not used AFAICT. It allows to get a human readable string of the type 'vt' represents, e.g. "VT_ARRAY VT_VARIANT", "VT_R8" and the like. The strange observation is using pszDbgVarType() multiple times in a single debug statement like: if (*pDestVt & VT_ARRAY)// an array in hand { VARTYPE tmpVt = *pDestVt & VT_TYPEMASK; *fprintf(stderr, "orexxole.cpp # %d %s: --- b) VT_ARRAY: type=[%s] *pDestVt=[%s][d=%d][x%08x] %s tmpVt=[%s][d=%d][x%08x] | VT_ARRAY=[%s][d=%d][x%08x], VT_R8=[%s][d=%d][x%08x] \n\n",__LINE__, __FUNCTION__,"VT_ARRAY",pszDbgVarType( *pDestVt ), *pDestVt , *pDestVt," /\\ ",pszDbgVarType( tmpVt ), tmpVt , tmpVt,pszDbgVarType(VT_ARRAY), VT_ARRAY, VT_ARRAY,pszDbgVarType(VT_R8), VT_R8, VT_R8);*** } So there are four invocations of pszDbgVarType() with four different variables. The ouput is surprisingly: ... cut ... oorexxole.cpp # 419 pszDbgVarType, vt: d=[5] [x0005] -> szDbg=[VT_R8] (return value) oorexxole.cpp # 419 pszDbgVarType, vt: d=[0] [x] -> szDbg=[VT_ARRAY VT_EMPTY] (return value) oorexxole.cpp # 419 pszDbgVarType, vt: d=[5] [x0005] -> szDbg=[VT_R8] (return value) oorexxole.cpp # 419 pszDbgVarType, vt: d=[5] [x0005] -> szDbg=[VT_ARRAY VT_R8] (return value) (added linebreaks for better legibility): *orexxole.cpp # 4359 checkForOverride: --- b) VT_ARRAY: type=[VT_ARRAY] *pDestVt=[VT_ARRAY VT_R8][d=8197][x2005] /\ tmpVt=[VT_ARRAYVT_R8][d=5][x0005] | VT_ARRAY=[VT_ARRAY VT_R8][d=8192][x2000], VT_R8=[VT_ARRAY VT_R8][d=5][x0005]*** Line # 419 above is a debug statement in pszDbgVarType() displaying the value it returns. It uses strcat() with the szDbg buffer which upon entry in this function sets element 0 to 0. VT_ARRAY has the decimal value 8192 (x2000), VT_R8 the decimal value 5 (x0005), hence the following should be shown: pszDbgVarType(*pDestVt): "VT_ARRAY VT_R8" pszDbgVarType(tmpVt) : "VT_R8" (VT_TYPEMASK is defined as xFFF) pszDbgVarType(VT_ARRAY): "VT_ARRAY" pszDbgVarType(VT_R8) : "VT_R8" It is as if for some of those invocations of pszDbvVarType the wrong buffer gets returned, hence displaying wrong information. Of course, having spent an enormeous amount of time debugging I might have arrived at a point where I overlook the obvious, hence this posting requesting comments. ---rony P.S.: Contemplating to change the pszDbg...() functions to force a buffer to be supplied rather than using a single global buffer, noticing that at least pszDbgVarType() gets also used by orexxole.cpp. This way no wrong optimizations should be applicable and also multithreaded usage of oorexxole.cpp would be improved. ___ Oorexx-devel mailing list Oorexx-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/oorexx-devel