Issue Details (XML | Word | Printable)

Key: CORE-1885
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Adriano dos Santos Fernandes
Reporter: Philippe Makowski
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Firebird Core

CREATE COLLATION connection lost under Posix

Created: 06/May/08 03:14 AM   Updated: 28/May/08 09:24 AM
Component/s: Charsets/Collation
Affects Version/s: 2.5 Initial, 2.1.0
Fix Version/s: 2.5 Alpha 1, 2.1.1

Time Tracking:
Not Specified

File Attachments: 1. File core.3741.bz2 (224 kB)

Environment: Linux and MacOsX

Planning Status: Unspecified


 Description  « Hide
Under Windows :
under win32 :


C:\FB21\bin>isql
Use CONNECT or CREATE DATABASE to specify a database
SQL> create database 'c:\fb21\db\col1.fdb';
SQL> show collation;
There are no collations in this database
SQL> CREATE COLLATION UNICODE_ENUS_CI
CON> FOR UTF8
CON> FROM UNICODE
CON> CASE INSENSITIVE
CON> 'LOCALE=en_US';
Statement failed, SQLCODE = -607
unsuccessful metadata update
-Invalid collation attributes
SQL>
Expected. Our ICU doesn't have locales.

Under Linux and MacOsX :
SQL> create database '127.0.0.1:/Volumes/tempo/firebird_db/coll1.fdb';
SQL> CREATE COLLATION UNICODE_ENUS_CI
CON> FOR UTF8
CON> FROM UNICODE
CON> CASE INSENSITIVE
CON> 'LOCALE=en_US';
Statement failed, SQLCODE = -902
Unable to complete network request to host "127.0.0.1".
-Error reading data from the connection.
Statement failed, SQLCODE = -902
Unable to complete network request to host "127.0.0.1".
-Error reading data from the connection.


 All   Comments   Work Log   Change History   Version Control   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Alexander Peshkov added a comment - 06/May/08 04:54 AM
I've tried with CS 2.1.0 32-bit (standard built).

bash-2.05b# ./isql -z
ISQL Version: LI-V2.1.0.17798 Firebird 2.1

echo "CREATE COLLATION UNICODE_ENUS_CI FOR UTF8 FROM UNICODE CASE INSENSITIVE 'LOCALE=en_US';" | ./isql -user sysdba -pas masterkey localhost:/tmp/coll1.fdb

Works as expected:
Statement failed, SQLCODE = -607
unsuccessful metadata update
-Invalid collation attributes


Alexander Peshkov added a comment - 06/May/08 05:01 AM
In HEAD in DEV_BUILD statement fails due to the following assertion:

fb_assert(sym && sym->intlsym_charset_id == constant->nod_desc.getCharSet());

I've found that constant->nod_desc has dynamic text type (127), METD_get_charset_name() successfully finds "NONE" as attachment charset, METD_get_charset() creates dsql_intlsym with charset_id==0. All this looks OK for me, therefore I suppose assert should be fixed. When I commented it out (to experiment), result was as expected - statement succeeded and
SQL> show COLLATION;
UNICODE_ENUS_CI, CHARACTER SET UTF8, FROM EXTERNAL ('UNICODE'), PAD SPACE, CASE INSENSITIVE, 'COLL-VERSION=49.192.5.5;LOCALE=en_US'

Also looks OK.

Adriano, I must say I've failed to reproduce initial bug. If you need more help please provide more details.

Philippe Makowski added a comment - 06/May/08 05:12 AM
So it is a 64bits issue :

on both MacOSX 10.5 and Linux 64 with Classic 64 :
/opt/firebird/bin/isql -z
ISQL Version: LI-V2.1.0.17798 Firebird 2.1
isql -z
ISQL Version: UI-V2.1.0.17798 Firebird 2.1

echo "CREATE COLLATION UNICODE_ENUS_CI FOR UTF8 FROM UNICODE CASE INSENSITIVE 'LOCALE=en_US';" | /opt/firebird/bin/isql -user sysdba -pas masterkey 127.0.0.1:employee
Statement failed, SQLCODE = -902
Unable to complete network request to host "127.0.0.1".
-Error reading data from the connection.
Statement failed, SQLCODE = -902
Unable to complete network request to host "127.0.0.1".
-Error reading data from the connection.
Statement failed, SQLCODE = -902
Unable to complete network request to host "127.0.0.1".
-Error writing data to the connection.
-Broken pipe

echo "CREATE COLLATION UNICODE_ENUS_CI FOR UTF8 FROM UNICODE CASE INSENSITIVE 'LOCALE=en_US';" | isql -user sysdba -pas masterkey 127.0.0.1:/Volumes/tempo/firebird_db/coll1.fdb
Statement failed, SQLCODE = -902
Unable to complete network request to host "127.0.0.1".
-Error reading data from the connection.
Statement failed, SQLCODE = -902
Unable to complete network request to host "127.0.0.1".
-Error reading data from the connection.

Alexander Peshkov added a comment - 06/May/08 05:31 AM
Philippe, unfortunately failed to reproduce. I've installed standard amd64 package, and tried both remote and embedded access. In both cases:
Statement failed, SQLCODE = -607
unsuccessful metadata update
-Invalid collation attributes

I'm afraid you should create core file and sent it to me. In 2.1 all you need to have core file (in /tmp) is just BugcheckAbort = 1 in firebird.conf.

Philippe Makowski added a comment - 06/May/08 05:41 AM
here the core file (Linux CS64)

Alexander Peshkov added a comment - 06/May/08 06:40 AM
I've found an exact place, where it dies.

UnicodeUtil::ICU* UnicodeUtil::Utf16Collation::loadICU(
    const Firebird::string& collVersion, const Firebird::string& locale,
    const Firebird::string& configInfo)
{
    ObjectsArray<string> versions;
    getVersions(configInfo, versions);

    for (ObjectsArray<string>::const_iterator i(versions.begin()); i != versions.end(); ++i)
    {
        ICU* icu = UnicodeUtil::loadICU(*i, configInfo);
        if (!icu)
            continue;

        UErrorCode status = U_ZERO_ERROR;

        if (locale.hasData())
        {
            int avail = icu->ulocCountAvailable();

            while (--avail >= 0)
            {
                if (locale == icu->ulocGetAvailable(avail))

In this string::operator==() the first thing is done is strlen() of what was returned by ulocGetAvailable(avail). I can only suppose why ulocGetAvailable returns something not acceptable for strlen() - all data is stored in registers and it's already lost for the moment of AV.

Certainly, it will be good to set breakpoint here on a system where it fails. Or add some debugging printf()s. May be Adriano has better ideas?


Adriano dos Santos Fernandes added a comment - 06/May/08 10:47 PM
The problem is that ulocCountAvailable() is returning 1 instead of 0. I didn't found any specific bug fixed in ICU SVN. This may be a problem caused by our changes to strip locales, but it doesn't cause problems in Windows.

I will investigate further, and maybe contact the ICU guys.

Adriano dos Santos Fernandes added a comment - 07/May/08 10:34 PM
I have not found the exact ICU bug, but adding one locale fix the problem.

Philippe Makowski added a comment - 28/May/08 09:24 AM
test ok and qmtest made