Possible issue with Oracle, 64bit and stBigDecimal
Posted: 17.01.2024, 16:57
I've included a console program below which when run in 64bit should cause an "A memory block footer has been corrupted." message. This seems to happen with bigdecimals and 64bit. I'm using FastMM5 to test for issues. I haven't been able to detect the source of the issue but data's being written past an allocation as a result of setting the bigdecimal bind variable.
The text of the error message:
A memory block footer has been corrupted.
The block size is 22.
The block was allocated by thread 0x1804, and the stack trace (return addresses) at the time was:
0000000000238EDA [FastMM5.pas][FastMM5][_ZN7Fastmm532FastMM_DebugGetMem_GetDebugBlockExb][7818]
0000000000238F95 [FastMM5.pas][FastMM5][_ZN7Fastmm518FastMM_DebugGetMemEx][7845]
00000000004B11C7 [ZDbcStatement.pas][ZDbcStatement][_ZN13Zdbcstatement27TZAbstractPreparedStatement13SetParamCountEi][4138]
0000000000219984 [System.pas][System][_ZN6System7_GetMemEx][4923]
00000000006D5577 [ZDbcOracleStatement.pas][ZDbcOracleStatement][_ZN19Zdbcoraclestatement25TZAbstractOracleStatement10InitBufferEN9Zdbcintfs9TZSQLTypeEPN15Zdbcoracleutils14TZOCIBindValueEjji][637]
00000000004ACEA6 [ZDbcStatement.pas][ZDbcStatement][_ZN13Zdbcstatement27TZAbstractPreparedStatement19CheckParameterIndexERi][3132]
00000000006D39C4 [ZDbcOracleStatement.pas][ZDbcOracleStatement][_ZN19Zdbcoraclestatement25TZAbstractOracleStatement19CheckParameterIndexERi][405]
0000000000229A7E [System.pas][System][_ZN6System10_IntfClearERNS_15DelphiInterfaceINS_10IInterfaceEEE][39015]
00000000006D94C3 [ZDbcOracleStatement.pas][ZDbcOracleStatement][_ZN19Zdbcoraclestatement33TZAbstractOraclePreparedStatement13SetBigDecimalEiRKN4Data6Fmtbcd4TBcdE][1255]
00000000003FA368 [ZClasses.pas][ZClasses][_ZN8Zclasses19TZCustomElementList11SetCapacityEx][2843]
000000000031D9AA [System.Classes.pas][System.Classes][_ZN6System7Classes11TStringListD0Ev][7481]
00000000004409E5 [ZDbcCache.pas][ZDbcCache][_ZN9Zdbccache13TZRowAccessor13FillStatementEN6System15DelphiInterfaceIN9Zdbcintfs19IZPreparedStatementEEEPNS_15TZIndexPairListENS2_INS3_19IZResultSetMetadataEEE][1501]
0000000000229AB5 [System.pas][System][_ZN6System9_IntfCopyERNS_15DelphiInterfaceINS_10IInterfaceEEES2_][39048]
00000000004535F1 [ZDbcGenericResolver.pas][ZDbcGenericResolver][_ZN19Zdbcgenericresolver33TZKeyAndPreparedStatementPairList3AddEyN6System15DelphiInterfaceIN9Zdbcintfs19IZPreparedStatementEEE][1124]
0000000000452332 [ZDbcGenericResolver.pas][ZDbcGenericResolver][_ZN19Zdbcgenericresolver27TZGenerateSQLCachedResolver11PostUpdatesEN6System15DelphiInterfaceIN19Zdbccachedresultset17IZCachedResultSetEEEN9Zdbccache15TZRowUpdateTypeEPNS6_13TZR
0000000000459FAA [ZDbcCachedResultSet.pas][ZDbcCachedResultSet][_ZN19Zdbccachedresultset25TZAbstractCachedResultSet14PostRowUpdatesEPN9Zdbccache13TZRowAccessorES3_][760]
000000000045A40A [ZDbcCachedResultSet.pas][ZDbcCachedResultSet][_ZN19Zdbccachedresultset25TZAbstractCachedResultSet11PostUpdatesEv][879]
000000000045CC37 [ZDbcCachedResultSet.pas][ZDbcCachedResultSet][_ZN19Zdbccachedresultset25TZAbstractCachedResultSet9InsertRowEv][2358]
000000000086A9DD [ZAbstractDataset.pas][ZAbstractDataset][_ZN16Zabstractdataset19TZAbstractRWDataSet17InternalAddRecordEPvb][506]
000000000045C89A [ZDbcCachedResultSet.pas][ZDbcCachedResultSet][_ZN19Zdbccachedresultset25TZAbstractCachedResultSet23UpdateDefaultExpressionEiN6System13UnicodeStringE][2208]
The allocation number is: 3545
Current memory dump of 30 bytes starting at pointer address 1AF71B13480:
02 C1 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 7E FF DA 8E 23 00
. . . . . . . . . . . . . . . . . . . . . . . . ~ . . . # .
Code: Select all
program ZeosOracleTest;
{$APPTYPE CONSOLE}
{$R *.res}
uses
FastMM5,
System.SysUtils,
ZConnection,
ZDataset;
var
ZConn: TZConnection;
ZQuery: TZQuery;
begin
FastMM_EnterDebugMode;
try
ZConn := TZConnection.Create(nil);
try
ZConn.Protocol := 'Oracle';
ZConn.User := 'MARK';
ZConn.Password := 'MARKSPW';
ZConn.Database := 'mydbalias';
{$IFDEF WIN64}
ZConn.LibraryLocation := 'C:\U\DbClients\Oracle\21.8\64Bit\oci.dll';
{$ELSE}
ZConn.LibraryLocation := 'C:\U\DbClients\Oracle\21.8\32Bit\oci.dll';
{$ENDIF}
ZConn.Connect;
// ZConn.ExecuteDirect('drop table otest');
// ZConn.ExecuteDirect('create table otest (id number(38))');
ZConn.ExecuteDirect('delete from otest');
ZQuery := TZQuery.Create(nil);
try
ZQuery.Connection := ZConn;
ZQuery.SQL.Text := 'select id from otest';
ZQuery.Open;
ZQuery.Insert;
ZQuery.Fields[0].Value := 1;
ZQuery.Post;
ZQuery.Close;
finally
ZQuery.Free;
end;
ZConn.Disconnect;
finally
ZConn.Free;
end;
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
Write('Press Enter to quit...');
ReadLn;
FastMM_ExitDebugMode;
end.
A memory block footer has been corrupted.
The block size is 22.
The block was allocated by thread 0x1804, and the stack trace (return addresses) at the time was:
0000000000238EDA [FastMM5.pas][FastMM5][_ZN7Fastmm532FastMM_DebugGetMem_GetDebugBlockExb][7818]
0000000000238F95 [FastMM5.pas][FastMM5][_ZN7Fastmm518FastMM_DebugGetMemEx][7845]
00000000004B11C7 [ZDbcStatement.pas][ZDbcStatement][_ZN13Zdbcstatement27TZAbstractPreparedStatement13SetParamCountEi][4138]
0000000000219984 [System.pas][System][_ZN6System7_GetMemEx][4923]
00000000006D5577 [ZDbcOracleStatement.pas][ZDbcOracleStatement][_ZN19Zdbcoraclestatement25TZAbstractOracleStatement10InitBufferEN9Zdbcintfs9TZSQLTypeEPN15Zdbcoracleutils14TZOCIBindValueEjji][637]
00000000004ACEA6 [ZDbcStatement.pas][ZDbcStatement][_ZN13Zdbcstatement27TZAbstractPreparedStatement19CheckParameterIndexERi][3132]
00000000006D39C4 [ZDbcOracleStatement.pas][ZDbcOracleStatement][_ZN19Zdbcoraclestatement25TZAbstractOracleStatement19CheckParameterIndexERi][405]
0000000000229A7E [System.pas][System][_ZN6System10_IntfClearERNS_15DelphiInterfaceINS_10IInterfaceEEE][39015]
00000000006D94C3 [ZDbcOracleStatement.pas][ZDbcOracleStatement][_ZN19Zdbcoraclestatement33TZAbstractOraclePreparedStatement13SetBigDecimalEiRKN4Data6Fmtbcd4TBcdE][1255]
00000000003FA368 [ZClasses.pas][ZClasses][_ZN8Zclasses19TZCustomElementList11SetCapacityEx][2843]
000000000031D9AA [System.Classes.pas][System.Classes][_ZN6System7Classes11TStringListD0Ev][7481]
00000000004409E5 [ZDbcCache.pas][ZDbcCache][_ZN9Zdbccache13TZRowAccessor13FillStatementEN6System15DelphiInterfaceIN9Zdbcintfs19IZPreparedStatementEEEPNS_15TZIndexPairListENS2_INS3_19IZResultSetMetadataEEE][1501]
0000000000229AB5 [System.pas][System][_ZN6System9_IntfCopyERNS_15DelphiInterfaceINS_10IInterfaceEEES2_][39048]
00000000004535F1 [ZDbcGenericResolver.pas][ZDbcGenericResolver][_ZN19Zdbcgenericresolver33TZKeyAndPreparedStatementPairList3AddEyN6System15DelphiInterfaceIN9Zdbcintfs19IZPreparedStatementEEE][1124]
0000000000452332 [ZDbcGenericResolver.pas][ZDbcGenericResolver][_ZN19Zdbcgenericresolver27TZGenerateSQLCachedResolver11PostUpdatesEN6System15DelphiInterfaceIN19Zdbccachedresultset17IZCachedResultSetEEEN9Zdbccache15TZRowUpdateTypeEPNS6_13TZR
0000000000459FAA [ZDbcCachedResultSet.pas][ZDbcCachedResultSet][_ZN19Zdbccachedresultset25TZAbstractCachedResultSet14PostRowUpdatesEPN9Zdbccache13TZRowAccessorES3_][760]
000000000045A40A [ZDbcCachedResultSet.pas][ZDbcCachedResultSet][_ZN19Zdbccachedresultset25TZAbstractCachedResultSet11PostUpdatesEv][879]
000000000045CC37 [ZDbcCachedResultSet.pas][ZDbcCachedResultSet][_ZN19Zdbccachedresultset25TZAbstractCachedResultSet9InsertRowEv][2358]
000000000086A9DD [ZAbstractDataset.pas][ZAbstractDataset][_ZN16Zabstractdataset19TZAbstractRWDataSet17InternalAddRecordEPvb][506]
000000000045C89A [ZDbcCachedResultSet.pas][ZDbcCachedResultSet][_ZN19Zdbccachedresultset25TZAbstractCachedResultSet23UpdateDefaultExpressionEiN6System13UnicodeStringE][2208]
The allocation number is: 3545
Current memory dump of 30 bytes starting at pointer address 1AF71B13480:
02 C1 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 7E FF DA 8E 23 00
. . . . . . . . . . . . . . . . . . . . . . . . ~ . . . # .