server crash in to_timestamp function
Hi,
While looking at the code base I have encountered a server crash in
to_timestamp function.
select TO_TIMESTAMP ( '2006 1', 'YYYY Q' );
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
I further debugged the issue and here are my thoughts
[function DCH_from_char]
...
case DCH_Q:
/*
* We ignore Q when converting to date because it is not
* normative.
*
* We still parse the source string for an integer, but it
* isn't stored anywhere in 'out'.
*/
from_char_parse_int((int *) NULL, &s, n);
s += SKIP_THth(n->suffix);
...
This piece of code is calling function "from_char_parse_int" with
first argument NULL. The function "from_char_parse_int" in turn calls
"from_char_parse_int_len" which in turn calls "from_char_set_int".
In the function "from_char_set_int" the first argument "dest" is being
derefernced without the null check.
(if (*dest != 0 && *dest != value)
--
Ibrar Ahmed
EnterpriseDB http://www.enterprisedb.com
"Ibrar Ahmed" <ibrar.ahmad@gmail.com> writes:
While looking at the code base I have encountered a server crash in
to_timestamp function.
select TO_TIMESTAMP ( '2006 1', 'YYYY Q' );
server closed the connection unexpectedly
Looks like Heikki fixed this yesterday. It works here:
regression=# select TO_TIMESTAMP ( '2006 1', 'YYYY Q' );
to_timestamp
------------------------
2006-01-01 00:00:00-05
(1 row)
regards, tom lane