Quantcast
Channel: Visual COBOL - Forum - Recent Threads
Viewing all articles
Browse latest Browse all 4356

Call to WINAPI "memcmp" gives exception

$
0
0

Hi,

In one of our Cobol programs (compiled for .NET) we have a call to the WINAPI memcmp function. This call is working properly and gives the correct results.

As we are now experimenting with multi-threading our application, we ran into a problem with this call. The second thread that executes throws an exception on the WINAPI "memcmp" call:

System.ArgumentException: Duplicate dynamic module name within an assembly.
ERROR 2017-03-06 13:45:54 - D01WN00-1      :    at System.Reflection.Emit.AssemblyBuilderData.CheckNameConflict(String strNewModuleName)
ERROR 2017-03-06 13:45:54 - D01WN00-1      :    at System.Reflection.Emit.AssemblyBuilder.DefineDynamicModuleInternalNoLock(String name, Boolean emitSymbolInfo, StackCrawlMark& stackMark)
ERROR 2017-03-06 13:45:54 - D01WN00-1      :    at System.Reflection.Emit.AssemblyBuilder.DefineDynamicModuleInternal(String name, Boolean emitSymbolInfo, StackCrawlMark& stackMark)
ERROR 2017-03-06 13:45:54 - D01WN00-1      :    at System.Reflection.Emit.AssemblyBuilder.DefineDynamicModule(String name)
ERROR 2017-03-06 13:45:54 - D01WN00-1      :    at MicroFocus.COBOL.Program.Win32.NativeProcedurePointer.GetMethodInfo(CobolCallConvention callConvention, Object[] parms)
ERROR 2017-03-06 13:45:54 - D01WN00-1      :    at MicroFocus.COBOL.Program.ProcedurePointer.call(UInt32 callConvention, Object[] parms)
ERROR 2017-03-06 13:45:54 - D01WN00-1      :    at MicroFocus.COBOL.Program.Control.CallReturningObject(UInt32 callConvention, String program, Object[] parameters, IObjectControl pgInstance)
ERROR 2017-03-06 13:45:54 - D01WN00-1      :    at MicroFocus.COBOL.Program.Control.Call(UInt32 callConvention, String program, Object[] parameters, IObjectControl pgInstance)
ERROR 2017-03-06 13:45:54 - D01WN00-1      :    at MEMCMP-SALSTRK.MEMCMP_SALSTRK(Reference SALSTRKGEG, Reference SALSTRKGEG-BEWAAR, Reference MEMCMP-RETURNCODE) in D:\Workspace2012\Gemal\ENGINE\1_ONTWIKKEL_R11\source\Cobol\MEMCMP-SALSTRK.cbl:line 29
ERROR 2017-03-06 13:45:54 - D01WN00-1      :    at (Object , Object[] )
ERROR 2017-03-06 13:45:54 - D01WN00-1      :    at MicroFocus.COBOL.Program.ProcedurePointer.call(UInt32 callConvention, Object[] parms)
ERROR 2017-03-06 13:45:54 - D01WN00-1      :    at MicroFocus.COBOL.Program.Control.CallReturningObject(UInt32 callConvention, String program, Object[] parameters, IObjectControl pgInstance)
ERROR 2017-03-06 13:45:54 - D01WN00-1      :    at MicroFocus.COBOL.Program.Control.Call(UInt32 callConvention, String program, Object[] parameters, IObjectControl pgInstance)
ERROR 2017-03-06 13:45:54 - D01WN00-1      :    at D01M4095._MF_PERFORM_4_1(_MF_LCTYPE_1& _MF_LCDATA) in D:\Workspace2012\Gemal\ENGINE\1_ONTWIKKEL_R11\source\Cobol\D01M4095.cbl:line 521
ERROR 2017-03-06 13:45:54 - D01WN00-1      :    at D01M4095.D01M4095(Reference REC-1, Reference LBCOP03, Reference INSTGEG-IG, Reference RESULTTAB-RE, Reference NFTAB-NF, Reference UVPER-TAB, Reference SALSTRKGEG, Reference SOCIALEVERZVLDN-SV, Reference INSTGEG-PERIODE-IG, Reference WERKNEMER-INVOERTOTAALTABEL-P, Reference

 

The call to memcmp is in a separate module:

IDENTIFICATIONDIVISION.

$set ilpinvoke"msvcrt"

PROGRAM-ID. MEMCMP-SALSTRK.

AUTHOR. MARK DE VOS.

DATE-WRITTEN. MAART 2017.

*********************************************************************************************

* MODULE MEMCMP-SALSTRK: COMPAREN VAN DE GROEPSVELDEN SALSTRKRESTAB-RS EN SALSTRKGEG-BEWAAR

* VIA EEN CALL NAAR DE WINAPI METHODE memcmp

*********************************************************************************************

ENVIRONMENTDIVISION.

CONFIGURATIONSECTION.

SPECIAL-NAMES.

CALL-CONVENTION 74 IS WINAPI.

DATADIVISION.

WORKING-STORAGESECTION.

LINKAGESECTION.

COPY D01CP117.

COPY D01028CP.

01 MEMCMP-RETURNCODE PIC 9(9).

PROCEDUREDIVISIONUSING SALSTRKGEG

SALSTRKGEG-BEWAAR

MEMCMP-RETURNCODE.

HOOFD SECTION.

HOOFD-01.

CALL"cob32api.dll".

*

MOVEZEROTO MEMCMP-RETURNCODE.

*

CALL WINAPI "memcmp"USING SALSTRKRESTAB-RS

SALSTRKGEG-BEWAAR

LENGTH-OF-SALSTRKRESTAB-RS

RETURNING MEMCMP-RETURNCODE.

*

INVOKEtypeLogger::Info(string::Format("MEMCMP-RETURNCODE: {0}", MEMCMP-RETURNCODE)).

HOOFD-99.

EXITPROGRAM.

 

By the way, the reason that we are using memcmp is that the regular Cobol comparison of two very large groupfields is performing very, very slow in .Net.


Viewing all articles
Browse latest Browse all 4356

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>