Issue Details (XML | Word | Printable)

Key: CORE-1579
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Alexander Peshkov
Reporter: James Linse
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.
Firebird Core

Corrupt BLOB in UDF if followed by a char* that is a timestamp

Created: 09/Nov/07 03:57 AM   Updated: 19/Jan/16 05:02 AM
Component/s: UDF
Affects Version/s: 2.0.1, 2.0.3
Fix Version/s: 2.1 RC1, 2.0.4

Linux version 2.6.17 64-bit
GCC 4.1.2 and GCC 4.1.1

QA Status: No test

 Description  « Hide
If I call the following with BLOB_IS_NULL('abc', NULL, CURRENT_TIMESTAMP) the blob in the udf will get corrupted.
This only happens on a 64 bit system as I've tested it on a 32bit system and it works as I would expect.
If I rearrange the parameters as BLOB_IS_NULL('abc', CURRENT_TIMESTAMP, NULL) things seem to be ok.
If I try to cast the timestamp explicitly BLOB_IS_NULL('abc', NULL, CAST(CURRENT_TIMESTAMP AS CHAR(30))) the blob still gets corrupted.
If I just pass a regular string as parameter 3 everything is fine also. BLOB_IS_NULL('abc', NULL, 'abc')

BLOB null,
ENTRY_POINT 'blobisnull' MODULE_NAME 'mptfbudf';

__int32 blobisnull(char* name, blobcallback* blob_in, char* data)
  if(blob_in && blob_in->blob_handle && (blob_in->blob_total_length > 0)) {
    if(blob_in->blob_total_length > 0) {
      return 0; // Blob is not null
  } else {
    return 1;

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Alexander Peshkov added a comment - 16/Nov/07 07:36 AM
Bug happened only for NULL BLOBS. This was due to incorrect space allocation for them on UDF parameters' stack. On 64-bit builds it was more destructive cause blob_handle could be overwritten by next parameter (not a case for 32-bit builds due to smaller pointer size).