New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Server crashes when calling external function from UDF having BLOB params [CORE1901] #2333
Comments
Commented by: @hvlad > DLL compiled by "MS VC++ Toolkit 2003" Try MSVC 2005, please |
Commented by: Tomas Mandys (tma0) It's not solution unless you planned introduce incompatability. I suppose there is some alignment problem or so. I have not MSVC 2005 and UTF libaries may be compiled also by other languages (Delphi, ...). If you really want UDF running only with FB2.1 they should be distinquishable in file name (xyz.fb2.1.dll) to know which version can be used with but it's path to the hell. |
Commented by: @hvlad Its not about language but about used run-time libraries. |
Commented by: Tomas Mandys (tma0) Seems the problem is fixed in Firebird 2.1.1.17910 |
Modified by: @dyemanovsecurity: Developers [ 10012 ] => |
Modified by: @dyemanovstatus: Open [ 1 ] => Resolved [ 5 ] resolution: Fixed [ 1 ] Fix Version: 2.1.1 [ 10223 ] |
Modified by: @pcisarstatus: Resolved [ 5 ] => Closed [ 6 ] |
Modified by: @pavel-zotovQA Status: No test |
Submitted by: Tomas Mandys (tma0)
I have own UDF library which implements also simply blob maniulation, i.e. param is blob. The library works correctly on Interbase and Firebird up to version 2.0. But v.2.1 crashes when function is being called - respectively server somohow freezes, no expception is generated, even I put "return" as first instruction, problem is during DLL function call. DLL compiled by "MS VC++ Toolkit 2003"
What has changed since version 2.0 in UDP call API ? I see there is a non documented (at least in IB6 langref.pdf) "BY DESCRIPTOR" and "PARAMETER 2" clause. But it hasn't changed since 2.0.
declare external function string2blob
varchar(300) by descriptor,
blob returns parameter 2
entry_point 'string2blob' module_name 'fbudf';
My function:
void EXPORT String_To_Blob(unsigned char ISC_FAR * val, BLOBCALLBACK_ b1)
{
ISC_ULONG n = 0;
return; // <----------------------------- doesn't help
if (val == NULL)
return;
while (*(val+n) != 0)
n++;
buff_to_blob((unsigned char ISC_FAR *) val, n+1, b1);
}
void buff_to_blob(unsigned char ISC_FAR * buff, ISC_ULONG len, BLOBCALLBACK_ b)
{
if (!b || !b->blob_handle) return;
while (len > 0) {
(*b->blob_put_segment) (b->blob_handle, buff, (ISC_USHORT) min(BUFFER_SIZE, len));
buff += BUFFER_SIZE;
if (len > BUFFER_SIZE)
len -= BUFFER_SIZE;
else
len = 0;
}
}
// declared in Firebird's ibase.h but missing in Interbases' distribution
typedef struct blobcallback_ {
short (ISC_FAR *blob_get_segment)
(void ISC_FAR* hnd, unsigned char* buffer, ISC_USHORT buf_size, ISC_USHORT ISC_FAR * result_len);
void ISC_FAR *blob_handle;
ISC_LONG blob_number_segments;
ISC_LONG blob_max_segment;
ISC_LONG blob_total_length;
void (ISC_FAR *blob_put_segment)
(void ISC_FAR* hnd, unsigned char* buffer, ISC_USHORT buf_size);
ISC_LONG (ISC_FAR *blob_lseek)
(void ISC_FAR* hnd, ISC_USHORT mode, ISC_LONG offset);
} ISC_FAR *BLOBCALLBACK_;
DECLARE EXTERNAL FUNCTION REPL$STRING_TO_BLOB
CSTRING(32765)
RETURNS BLOB
ENTRY_POINT 'String_To_Blob'
MODULE_NAME 'ib_repl'
The text was updated successfully, but these errors were encountered: