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

access violation on shutdown of xnet connection to local database when events have been registered [CORE6231] #6475

Closed
firebird-automations opened this issue Jan 16, 2020 · 3 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: René Hoffmann (rhoffmann)

Attachments:
FirebirdEventListenerCrashTest.zip

A reproducible access violation occurs on connection shutdown, when there have events been registered.
Occurs only for XNET connections.

Workaround: If I force local connection via tcp/ip per "inet://..." database name, it works all properly.

The access violation is raised when accessing "xch" in the loop of function "xnet_read":

======Code from xnet.cpp - begin =======
while (!xnet_shutdown)
{

            \.\.\.

	const DWORD wait\_result =
		WaitForSingleObject\(xcc\-\>xcc\_event\_recv\_channel\_filled, XNET\_RECV\_WAIT\_TIMEOUT\);

	if \(wait\_result == WAIT\_OBJECT\_0\)
	\{
		// Client has written some data for us \(server\) to read

		port\-\>port\_rcv\_packets\+\+;
		port\-\>port\_rcv\_bytes \+= xch\-\>xch\_length; // <\-\-\-\-\-\- the memory address of 'xch' is invalid

		xdrs\-\>x\_handy = xch\-\>xch\_length;
		xdrs\-\>x\_private = xdrs\-\>x\_base;

		return TRUE;
	\}
	
            \.\.\.
\}

======Code from xnet.cpp - end=======

I created a command line application for testing, which I uploaded to this issue:
A command line »FirebirdEventListenerCrashTest.exe "inet://%cd%\MYDB.FDB" -u:SOMEBODY -p:something« will run successfully.
A command line »FirebirdEventListenerCrashTest.exe "xnet://%cd%\MYDB.FDB" -u:SOMEBODY -p:something« will stop prematurely.

Commits: be2d771 839c9f6

@firebird-automations
Copy link
Collaborator Author

Modified by: René Hoffmann (rhoffmann)

Attachment: FirebirdEventListenerCrashTest.zip [ 13414 ]

description: A reproducible access violation occurs on connection shutdown, when there have events been registered.
Occurs only for XNET connections.

Workaround: If I force local connection via tcp/ip per "inet://..." database name, it works all properly.

The access violation is raised when accessing "xch" in the loop of function "xnet_read":
{code:c++}
while (!xnet_shutdown)
{

            \.\.\.

	const DWORD wait\_result =
		WaitForSingleObject\(xcc\-\>xcc\_event\_recv\_channel\_filled, XNET\_RECV\_WAIT\_TIMEOUT\);

	if \(wait\_result == WAIT\_OBJECT\_0\)
	\{
		// Client has written some data for us \(server\) to read

		port\-\>port\_rcv\_packets\+\+;
		port\-\>port\_rcv\_bytes \+= xch\-\>xch\_length; // <\-\-\-\-\-\- the memory address of 'xch' is invalid

		xdrs\-\>x\_handy = xch\-\>xch\_length;
		xdrs\-\>x\_private = xdrs\-\>x\_base;

		return TRUE;
	\}
	
            \.\.\.
\}

{code}

I created a command line application for testing, which I uploaded to "https://nextcloud.hksinformatik.de/index.php/s/cBsMmR3iXjogx2f" (password: firebirdcrash):
A command line {{FirebirdEventListenerCrashTest.exe "inet://%cd%\MYDB.FDB" -u:SOMEBODY -p:something}} will run successfully.
A command line {{FirebirdEventListenerCrashTest.exe "xnet://%cd%\MYDB.FDB" -u:SOMEBODY -p:something}} will stop prematurely.

=>

A reproducible access violation occurs on connection shutdown, when there have events been registered.
Occurs only for XNET connections.

Workaround: If I force local connection via tcp/ip per "inet://..." database name, it works all properly.

The access violation is raised when accessing "xch" in the loop of function "xnet_read":

======Code from xnet.cpp - begin =======
while (!xnet_shutdown)
{

            \.\.\.

	const DWORD wait\_result =
		WaitForSingleObject\(xcc\-\>xcc\_event\_recv\_channel\_filled, XNET\_RECV\_WAIT\_TIMEOUT\);

	if \(wait\_result == WAIT\_OBJECT\_0\)
	\{
		// Client has written some data for us \(server\) to read

		port\-\>port\_rcv\_packets\+\+;
		port\-\>port\_rcv\_bytes \+= xch\-\>xch\_length; // <\-\-\-\-\-\- the memory address of 'xch' is invalid

		xdrs\-\>x\_handy = xch\-\>xch\_length;
		xdrs\-\>x\_private = xdrs\-\>x\_base;

		return TRUE;
	\}
	
            \.\.\.
\}

======Code from xnet.cpp - end=======

I created a command line application for testing, which I uploaded to this issue:
A command line »FirebirdEventListenerCrashTest.exe "inet://%cd%\MYDB.FDB" -u:SOMEBODY -p:something« will run successfully.
A command line »FirebirdEventListenerCrashTest.exe "xnet://%cd%\MYDB.FDB" -u:SOMEBODY -p:something« will stop prematurely.

@firebird-automations
Copy link
Collaborator Author

Modified by: @hvlad

assignee: Vlad Khorsun [ hvlad ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @hvlad

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 4.0 Beta 2 [ 10888 ]

Fix Version: 3.0.6 [ 10889 ]

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