Skip to content
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

isc_que_events callback function randomly return invalid Update Buffer [CORE5254] #5533

Open
firebird-automations opened this issue May 26, 2016 · 4 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Mahmudov Ilgar S. (maxis)

I use POST EVENT in triggers and stored procedures. For catching events I try use FIBPlus, but found AV when registering/unregistering Events (~50 % times in application staring/closing). I write my own component (similar to FIBPlus super alerter and IBEvents) and found that EventBuffer used in
res = Parent->Database->ClientLibrary->isc_que_events(StatusVector, &DBH, &EventID, EventBufferLen, EventBuffer, (TISC_CALLBACK)EventCallback, PVoid)this);
in sometimes corrupt, because of in EventCallback function receive invalid Updated, witch copied to ResulBuffer and then isc_event_counts copied ResultBuffer to EventBuffer

void EventCallback(void *Ptr, short Length, unsigned char *Updated)
{
if (Ptr && Updated)
{
TMxFBEventsBlockListener *T = (TMxFBEventsBlockListener *)Ptr;

	T\-\>UpdateResultBuffer\(Length, Updated\);
	T\-\>SignalEvent\(\);
\}

}
//---------------------------------------------------------------------------
void __fastcall TMxFBEventsBlockListener::UpdateResultBuffer(short Length, unsigned char *Updated)
{
if (Length == EventBufferLen && Updated[0] == 1)
memcpy(ResultBuffer, Updated, Length);
else // ---------------------------------------------------> INVALID UPDATED
{
memcpy(ResultBuffer, EventBuffer, EventBufferLen); // this is my patch, witch help call isc_que_events without error 335544973
// bFirstTime = true;
Parent->DoError("MxFBEventsAlerter: Invalid Updated buffer ="+IntToStr(Length), 0);
}
}

This is floating error. You can 100 times unregister and register again same event list and see this error 20-50 times.

İ can send all sources

@firebird-automations
Copy link
Collaborator Author

Modified by: Mahmudov Ilgar S. (maxis)

description: I use POST EVENT in triggers and stored procedures. For catching events I try use FIBPlus, but found AV when registering/unregistering Events (50 % times in application staring/closing). I write my own component (similar to FIBPlus super alerter and IBEvents) and found that EventBuffer used in
res = Parent->Database->ClientLibrary->isc_que_events(StatusVector, &DBH, &EventID, EventBufferLen, EventBuffer, (TISC_CALLBACK)EventCallback, PVoid)this);
in sometimes corrupt, because of in EventCallback function receive invalid Updated, witch copied to ResulBuffer and after isc_event_counts copied to EventBuffer

void EventCallback(void *Ptr, short Length, unsigned char *Updated)
{
if (Ptr && Updated)
{
TMxFBEventsBlockListener *T = (TMxFBEventsBlockListener *)Ptr;

	T\-\>UpdateResultBuffer\(Length, Updated\);
	T\-\>SignalEvent\(\);
\}

}
//---------------------------------------------------------------------------
void __fastcall TMxFBEventsBlockListener::UpdateResultBuffer(short Length, unsigned char *Updated)
{
if (Length == EventBufferLen && Updated[0] == 1)
memcpy(ResultBuffer, Updated, Length);
else // ---------------------------------------------------> INVALID UPDATED
{
memcpy(ResultBuffer, EventBuffer, EventBufferLen);
// bFirstTime = true;
Parent->DoError("MxFBEventsAlerter: Invalid Updated buffer ="+IntToStr(Length), 0);
}
}

This is floating error. You can 100 times unregister and register again same event list and see this error 20-50 times.

=>

I use POST EVENT in triggers and stored procedures. For catching events I try use FIBPlus, but found AV when registering/unregistering Events (~50 % times in application staring/closing). I write my own component (similar to FIBPlus super alerter and IBEvents) and found that EventBuffer used in
res = Parent->Database->ClientLibrary->isc_que_events(StatusVector, &DBH, &EventID, EventBufferLen, EventBuffer, (TISC_CALLBACK)EventCallback, PVoid)this);
in sometimes corrupt, because of in EventCallback function receive invalid Updated, witch copied to ResulBuffer and then isc_event_counts copied ResultBuffer to EventBuffer

void EventCallback(void *Ptr, short Length, unsigned char *Updated)
{
if (Ptr && Updated)
{
TMxFBEventsBlockListener *T = (TMxFBEventsBlockListener *)Ptr;

	T\-\>UpdateResultBuffer\(Length, Updated\);
	T\-\>SignalEvent\(\);
\}

}
//---------------------------------------------------------------------------
void __fastcall TMxFBEventsBlockListener::UpdateResultBuffer(short Length, unsigned char *Updated)
{
if (Length == EventBufferLen && Updated[0] == 1)
memcpy(ResultBuffer, Updated, Length);
else // ---------------------------------------------------> INVALID UPDATED
{
memcpy(ResultBuffer, EventBuffer, EventBufferLen); // this is my patch, witch help call isc_que_events without error 335544973
// bFirstTime = true;
Parent->DoError("MxFBEventsAlerter: Invalid Updated buffer ="+IntToStr(Length), 0);
}
}

This is floating error. You can 100 times unregister and register again same event list and see this error 20-50 times.

İ can send all sources

@firebird-automations
Copy link
Collaborator Author

Commented by: @aafemt

In callback you must check that length > 0 in addition to updated != NULL.

@firebird-automations
Copy link
Collaborator Author

Commented by: Mahmudov Ilgar S. (maxis)

İt's already checked in UpdateResultBuffer
if (Length == EventBufferLen && Updated[0] == 1)

@firebird-automations
Copy link
Collaborator Author

Commented by: @hvlad

It looks like recently fixed CORE5521
Is it still actual ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant