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

Firebird crash when executing an stored procedure called by a trigger that converts string to upper [CORE4123] #4451

Closed
firebird-issue-importer opened this issue Jun 18, 2013 · 18 comments

Comments

@firebird-issue-importer

Submitted by: Jesus Angel Garcia Zarco (cointec)

Is related to CORE2912
Relate to CORE4127

I have a table with a trigger before insert that calls a strored procedure. Inside the stored procedure the next statement is executed, uResult = upper(Result), where Result is a varchar(40) input variable, that comes from a row field value.

When an insert is executed in the table, if the field value is 'ÿÿÿÿ', and the stored procedure is called with it, firebird crash, and before crash, I get an exception "arithmetic..."

Also, If I try to run select upper( 'ÿ' ) from rdb$database, returns "arithmethic exception, string truncation or numeri overflow..".

When this error raises inserting a row in the table, after the exception is raised, Firebird terminates abnormally. If I execute the stored procedure, the error raises, but firebird does not crash, only if the stored procedure is called from the trigger.

I can supply DB (5Gb), and insert command.

When the server termitates abnormally, starts again, and my process application tries to execute the insert again and Firebird terminates abnormally again. After some crashes, the firebird database gets corrupted, because users and processes (reconnectting) were working, while shutting down and restarting the engine..

SERVIDOR-CAB (Client) Tue Jun 18 14:36:54 2013
Guardian starting: "C:\Firebird\bin\fbserver.exe"
SERVIDOR-CAB (Client) Tue Jun 18 14:37:01 2013
"C:\Firebird\bin\fbserver.exe": terminated abnormally (4294967295)
SERVIDOR-CAB (Client) Tue Jun 18 14:37:02 2013
Guardian starting: "C:\Firebird\bin\fbserver.exe"
SERVIDOR-CAB (Client) Tue Jun 18 14:37:09 2013
"C:\Firebird\bin\fbserver.exe": terminated abnormally (4294967295)
......

When validating database.....

SERVIDOR-CAB (Server) Tue Jun 18 14:54:55 2013
Database: Gestlab
Relation has 1 orphan backversions (148 in use) in table LIS_ENL_COLA_RESULTADO (532)
SERVIDOR-CAB (Server) Tue Jun 18 14:55:04 2013
Database: Gestlab
Relation has 3 orphan backversions (0 in use) in table PET_DIARIO (600)
SERVIDOR-CAB (Server) Tue Jun 18 14:57:36 2013
Database: Gestlab
Relation has 625 orphan backversions (212 in use) in table PET_PRUEBA (670)
SERVIDOR-CAB (Server) Tue Jun 18 14:58:05 2013
Database: Gestlab
Relation has 1 orphan backversions (20 in use) in table PETICION (717)
SERVIDOR-CAB (Server) Tue Jun 18 14:58:43 2013
Database: Gestlab
Page 614694 is an orphan
SERVIDOR-CAB (Server) Tue Jun 18 14:58:43 2013
Database: Gestlab
Page 614917 is an orphan
SERVIDOR-CAB (Server) Tue Jun 18 14:58:43 2013
Database: Gestlab
Page 614926 is an orphan
SERVIDOR-CAB (Server) Tue Jun 18 14:58:43 2013
Database: Gestlab
Page 614987 is an orphan
SERVIDOR-CAB (Server) Tue Jun 18 14:58:43 2013
Database: Gestlab
Page 615010 is an orphan
SERVIDOR-CAB (Server) Tue Jun 18 14:58:43 2013
Database: Gestlab
Page 615011 is an orphan
SERVIDOR-CAB (Server) Tue Jun 18 14:58:43 2013
Database: Gestlab
Page 615012 is an orphan
SERVIDOR-CAB (Server) Tue Jun 18 14:58:43 2013
Database: Gestlab
Page 615015 is an orphan

and so.....

Commits: 4ae620e FirebirdSQL/fbt-repository@6c46d50

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Jun 18, 2013

Modified by: Jesus Angel Garcia Zarco (cointec)

description: I have a table with a trigger before insert that calls a strored procedure. Inside the stored procedure is executed, uResult = upper(Result), where Result is a varchar(40) input variable, that comes from a row table field value.

If the stored procedure parameter is 'ÿÿÿÿ', when an insert is executed in the table, firebird crash.

Also, If I try to run select upper( 'ÿ' ) from rdb$database, returns "arithmethic exception, string truncation or numeri overflow..". When this error raises inserting a row in the table, after the exception is raised, Firebird terminates abnormally.

=>

I have a table with a trigger before insert that calls a strored procedure. Inside the stored procedure the next statement is executed, uResult = upper(Result), where Result is a varchar(40) input variable, that comes from a row field value.

If the stored procedure parameter is 'ÿÿÿÿ', when an insert is executed in the table, firebird crash. Before crash, I get an exception "arithmetic..."

Also, If I try to run select upper( 'ÿ' ) from rdb$database, returns "arithmethic exception, string truncation or numeri overflow..".

When this error raises inserting a row in the table, after the exception is raised, Firebird terminates abnormally. If I execute the stored procedure, the error raises, but firebird does not crash, only if the stored procedure is called from the trigger.

I can supply DB (5Gb), and insert command.

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Jun 18, 2013

Modified by: Jesus Angel Garcia Zarco (cointec)

description: I have a table with a trigger before insert that calls a strored procedure. Inside the stored procedure the next statement is executed, uResult = upper(Result), where Result is a varchar(40) input variable, that comes from a row field value.

If the stored procedure parameter is 'ÿÿÿÿ', when an insert is executed in the table, firebird crash. Before crash, I get an exception "arithmetic..."

Also, If I try to run select upper( 'ÿ' ) from rdb$database, returns "arithmethic exception, string truncation or numeri overflow..".

When this error raises inserting a row in the table, after the exception is raised, Firebird terminates abnormally. If I execute the stored procedure, the error raises, but firebird does not crash, only if the stored procedure is called from the trigger.

I can supply DB (5Gb), and insert command.

=>

I have a table with a trigger before insert that calls a strored procedure. Inside the stored procedure the next statement is executed, uResult = upper(Result), where Result is a varchar(40) input variable, that comes from a row field value.

When an insert is executed in the table, if the field value is 'ÿÿÿÿ', and the stored procedure is called with it, firebird crash, and before crash, I get an exception "arithmetic..."

Also, If I try to run select upper( 'ÿ' ) from rdb$database, returns "arithmethic exception, string truncation or numeri overflow..".

When this error raises inserting a row in the table, after the exception is raised, Firebird terminates abnormally. If I execute the stored procedure, the error raises, but firebird does not crash, only if the stored procedure is called from the trigger.

I can supply DB (5Gb), and insert command.

When the server termitates abnormally, starts again, and my process application tries to execute the insert again and Firebird terminates abnormally again. After some crashes, the firebird database gets corrupted, becasu all users were working.

SERVIDOR-CAB (Client) Tue Jun 18 14:36:54 2013
Guardian starting: "C:\Firebird\bin\fbserver.exe"
SERVIDOR-CAB (Client) Tue Jun 18 14:37:01 2013
"C:\Firebird\bin\fbserver.exe": terminated abnormally (4294967295)
SERVIDOR-CAB (Client) Tue Jun 18 14:37:02 2013
Guardian starting: "C:\Firebird\bin\fbserver.exe"
SERVIDOR-CAB (Client) Tue Jun 18 14:37:09 2013
"C:\Firebird\bin\fbserver.exe": terminated abnormally (4294967295)

When validating database.....

SERVIDOR-CAB (Server) Tue Jun 18 14:54:55 2013
Database: Gestlab
Relation has 1 orphan backversions (148 in use) in table LIS_ENL_COLA_RESULTADO (532)
SERVIDOR-CAB (Server) Tue Jun 18 14:55:04 2013
Database: Gestlab
Relation has 3 orphan backversions (0 in use) in table PET_DIARIO (600)
SERVIDOR-CAB (Server) Tue Jun 18 14:57:36 2013
Database: Gestlab
Relation has 625 orphan backversions (212 in use) in table PET_PRUEBA (670)
SERVIDOR-CAB (Server) Tue Jun 18 14:58:05 2013
Database: Gestlab
Relation has 1 orphan backversions (20 in use) in table PETICION (717)
SERVIDOR-CAB (Server) Tue Jun 18 14:58:43 2013
Database: Gestlab
Page 614694 is an orphan
SERVIDOR-CAB (Server) Tue Jun 18 14:58:43 2013
Database: Gestlab
Page 614917 is an orphan
SERVIDOR-CAB (Server) Tue Jun 18 14:58:43 2013
Database: Gestlab
Page 614926 is an orphan
SERVIDOR-CAB (Server) Tue Jun 18 14:58:43 2013
Database: Gestlab
Page 614987 is an orphan
SERVIDOR-CAB (Server) Tue Jun 18 14:58:43 2013
Database: Gestlab
Page 615010 is an orphan
SERVIDOR-CAB (Server) Tue Jun 18 14:58:43 2013
Database: Gestlab
Page 615011 is an orphan
SERVIDOR-CAB (Server) Tue Jun 18 14:58:43 2013
Database: Gestlab
Page 615012 is an orphan
SERVIDOR-CAB (Server) Tue Jun 18 14:58:43 2013
Database: Gestlab
Page 615015 is an orphan

and so.....

environment: Windows 2008 Server, Database ISO8859_1 => Windows 2008 Server, Database ISO8859_1, Superserver

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Jun 18, 2013

Modified by: Jesus Angel Garcia Zarco (cointec)

description: I have a table with a trigger before insert that calls a strored procedure. Inside the stored procedure the next statement is executed, uResult = upper(Result), where Result is a varchar(40) input variable, that comes from a row field value.

When an insert is executed in the table, if the field value is 'ÿÿÿÿ', and the stored procedure is called with it, firebird crash, and before crash, I get an exception "arithmetic..."

Also, If I try to run select upper( 'ÿ' ) from rdb$database, returns "arithmethic exception, string truncation or numeri overflow..".

When this error raises inserting a row in the table, after the exception is raised, Firebird terminates abnormally. If I execute the stored procedure, the error raises, but firebird does not crash, only if the stored procedure is called from the trigger.

I can supply DB (5Gb), and insert command.

When the server termitates abnormally, starts again, and my process application tries to execute the insert again and Firebird terminates abnormally again. After some crashes, the firebird database gets corrupted, becasu all users were working.

SERVIDOR-CAB (Client) Tue Jun 18 14:36:54 2013
Guardian starting: "C:\Firebird\bin\fbserver.exe"
SERVIDOR-CAB (Client) Tue Jun 18 14:37:01 2013
"C:\Firebird\bin\fbserver.exe": terminated abnormally (4294967295)
SERVIDOR-CAB (Client) Tue Jun 18 14:37:02 2013
Guardian starting: "C:\Firebird\bin\fbserver.exe"
SERVIDOR-CAB (Client) Tue Jun 18 14:37:09 2013
"C:\Firebird\bin\fbserver.exe": terminated abnormally (4294967295)

When validating database.....

SERVIDOR-CAB (Server) Tue Jun 18 14:54:55 2013
Database: Gestlab
Relation has 1 orphan backversions (148 in use) in table LIS_ENL_COLA_RESULTADO (532)
SERVIDOR-CAB (Server) Tue Jun 18 14:55:04 2013
Database: Gestlab
Relation has 3 orphan backversions (0 in use) in table PET_DIARIO (600)
SERVIDOR-CAB (Server) Tue Jun 18 14:57:36 2013
Database: Gestlab
Relation has 625 orphan backversions (212 in use) in table PET_PRUEBA (670)
SERVIDOR-CAB (Server) Tue Jun 18 14:58:05 2013
Database: Gestlab
Relation has 1 orphan backversions (20 in use) in table PETICION (717)
SERVIDOR-CAB (Server) Tue Jun 18 14:58:43 2013
Database: Gestlab
Page 614694 is an orphan
SERVIDOR-CAB (Server) Tue Jun 18 14:58:43 2013
Database: Gestlab
Page 614917 is an orphan
SERVIDOR-CAB (Server) Tue Jun 18 14:58:43 2013
Database: Gestlab
Page 614926 is an orphan
SERVIDOR-CAB (Server) Tue Jun 18 14:58:43 2013
Database: Gestlab
Page 614987 is an orphan
SERVIDOR-CAB (Server) Tue Jun 18 14:58:43 2013
Database: Gestlab
Page 615010 is an orphan
SERVIDOR-CAB (Server) Tue Jun 18 14:58:43 2013
Database: Gestlab
Page 615011 is an orphan
SERVIDOR-CAB (Server) Tue Jun 18 14:58:43 2013
Database: Gestlab
Page 615012 is an orphan
SERVIDOR-CAB (Server) Tue Jun 18 14:58:43 2013
Database: Gestlab
Page 615015 is an orphan

and so.....

=>

I have a table with a trigger before insert that calls a strored procedure. Inside the stored procedure the next statement is executed, uResult = upper(Result), where Result is a varchar(40) input variable, that comes from a row field value.

When an insert is executed in the table, if the field value is 'ÿÿÿÿ', and the stored procedure is called with it, firebird crash, and before crash, I get an exception "arithmetic..."

Also, If I try to run select upper( 'ÿ' ) from rdb$database, returns "arithmethic exception, string truncation or numeri overflow..".

When this error raises inserting a row in the table, after the exception is raised, Firebird terminates abnormally. If I execute the stored procedure, the error raises, but firebird does not crash, only if the stored procedure is called from the trigger.

I can supply DB (5Gb), and insert command.

When the server termitates abnormally, starts again, and my process application tries to execute the insert again and Firebird terminates abnormally again. After some crashes, the firebird database gets corrupted, because users and processes (reconnectting) were working, while shutting down and restarting the engine..

SERVIDOR-CAB (Client) Tue Jun 18 14:36:54 2013
Guardian starting: "C:\Firebird\bin\fbserver.exe"
SERVIDOR-CAB (Client) Tue Jun 18 14:37:01 2013
"C:\Firebird\bin\fbserver.exe": terminated abnormally (4294967295)
SERVIDOR-CAB (Client) Tue Jun 18 14:37:02 2013
Guardian starting: "C:\Firebird\bin\fbserver.exe"
SERVIDOR-CAB (Client) Tue Jun 18 14:37:09 2013
"C:\Firebird\bin\fbserver.exe": terminated abnormally (4294967295)
......

When validating database.....

SERVIDOR-CAB (Server) Tue Jun 18 14:54:55 2013
Database: Gestlab
Relation has 1 orphan backversions (148 in use) in table LIS_ENL_COLA_RESULTADO (532)
SERVIDOR-CAB (Server) Tue Jun 18 14:55:04 2013
Database: Gestlab
Relation has 3 orphan backversions (0 in use) in table PET_DIARIO (600)
SERVIDOR-CAB (Server) Tue Jun 18 14:57:36 2013
Database: Gestlab
Relation has 625 orphan backversions (212 in use) in table PET_PRUEBA (670)
SERVIDOR-CAB (Server) Tue Jun 18 14:58:05 2013
Database: Gestlab
Relation has 1 orphan backversions (20 in use) in table PETICION (717)
SERVIDOR-CAB (Server) Tue Jun 18 14:58:43 2013
Database: Gestlab
Page 614694 is an orphan
SERVIDOR-CAB (Server) Tue Jun 18 14:58:43 2013
Database: Gestlab
Page 614917 is an orphan
SERVIDOR-CAB (Server) Tue Jun 18 14:58:43 2013
Database: Gestlab
Page 614926 is an orphan
SERVIDOR-CAB (Server) Tue Jun 18 14:58:43 2013
Database: Gestlab
Page 614987 is an orphan
SERVIDOR-CAB (Server) Tue Jun 18 14:58:43 2013
Database: Gestlab
Page 615010 is an orphan
SERVIDOR-CAB (Server) Tue Jun 18 14:58:43 2013
Database: Gestlab
Page 615011 is an orphan
SERVIDOR-CAB (Server) Tue Jun 18 14:58:43 2013
Database: Gestlab
Page 615012 is an orphan
SERVIDOR-CAB (Server) Tue Jun 18 14:58:43 2013
Database: Gestlab
Page 615015 is an orphan

and so.....

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Jun 19, 2013

Commented by: @dyemanov

Please provide the database by uploading it somewhere and sending the URL to me at mailto:firebird2@yandex.ru.

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Jun 19, 2013

Commented by: @dyemanov

The problem starts with the character 'ÿ' that does not have an upper case representation in ISO8859_1 (unlike WIN1252). I don't really know what is more correct in this case - throw an error or leave the character untouched. Nowadays Firebird throws an error, FWIW. Then a silly error checking allows the broken data descriptor to pass to the index scanning code that causes a local bufer overrun thus corrupting the stack.

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Jun 19, 2013

Modified by: @dyemanov

assignee: Dmitry Yemanov [ dimitr ]

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Jun 19, 2013

Commented by: Jesus Angel Garcia Zarco (cointec)

I think that if a character does not have an upper representation, leave as is in the returning string. Is like if I call upper with '(' or '$' that does not have upper representation.

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Jun 19, 2013

Commented by: @dyemanov

Strictly speaking, 'ÿ' does have an upper representation (visually rendered diferently), but it's missing in the partcular charset. It's another situation as with '(' or '$'.

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Jun 19, 2013

Commented by: Jesus Angel Garcia Zarco (cointec)

The source of corrupted index pages is the corrupted stack?
Why with this issue the database gets corrupted?

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Jun 20, 2013

Modified by: @asfernandes

Link: This issue is related to CORE2912 [ CORE2912 ]

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Jun 20, 2013

Commented by: @asfernandes

Added a link to CORE2912. Once the crash is fixed, I think this bug can be closed here.

The "crash" in CORE2912 is just about the arithmetic exception.

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Jun 20, 2013

Commented by: @asfernandes

And I think I have a solution to CORE2912. It seems the same problem and solution of CORE1431.

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Jun 20, 2013

Modified by: @dyemanov

Link: This issue relate to CORE4127 [ CORE4127 ]

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Jun 20, 2013

Commented by: @dyemanov

I've moved the buffer overrun to a separate issue, see CORE4127.

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Jun 20, 2013

Commented by: @dyemanov

Adriano, I have nothing to add for this ticket, both issues I've found are fixed now. If you want to change my patch for TextType or commit something else, please feel free.

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Jun 20, 2013

Modified by: @asfernandes

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

resolution: Fixed [ 1 ]

Fix Version: 3.0 Alpha 1 [ 10331 ]

Fix Version: 2.5.3 [ 10461 ]

Fix Version: 2.1.6 [ 10460 ]

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Jul 12, 2015

Modified by: @pavel-zotov

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

QA Status: Done successfully

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented Jul 12, 2015

Modified by: @pavel-zotov

status: Resolved [ 5 ] => Closed [ 6 ]

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