Consultor Eletrônico



Kbase P136272: Calling DLL function with struct parameter crashes the session if C struct contains double datatype
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/21/2008
Status: Unverified

SYMPTOM(s):

Calling DLL function with struct parameter crashes the session if C struct contains double datatype

C struct definition contains values of the "double" datatype among other datatypes

Passing a MEMPTR to the DLL function containing the raw data

MEMPTR is populated using PUT-* functions including PUT-DOUBLE().

Session crashes when DLL function is called (on the RUN ... statement)

FACT(s) (Environment):

Progress 9.x
OpenEdge 10.x
Windows

CAUSE:

The raw data in the MEMPTR did not match the expected byte alignment for the C struct.

On Windows, the C double datatype is 8-byte aligned, meaning that in the raw data for the struct, the value can only start on the ((n x 8 ) + 1) th bytes

FIX:

Ensure that any offset used in a PUT-DOUBLE function call is (n x 8) + 1 to ensure the data is properly aligned for the C struct.