Re: BUG #3841: core dump in uuid-ossp - Mailing list pgsql-bugs

From Alvaro Herrera
Subject Re: BUG #3841: core dump in uuid-ossp
Date
Msg-id 20071227194044.GP5709@alvh.no-ip.org
Whole thread Raw
In response to Re: BUG #3841: core dump in uuid-ossp  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: BUG #3841: core dump in uuid-ossp  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
Tom Lane wrote:
> Alvaro Herrera <alvherre@commandprompt.com> writes:
> >     if (err != NULL)
> >         ereport(ERROR,
> >                 (errmsg("OSSP uuid failure: %s", err)));
> >     else
> >         ereport(ERROR,
> >                 (errmsg("OSSP uuid failure: error code %d", rc)));
>
> Maybe "OSSP uuid library failure"?  Otherwise seems OK.

Sold.

> > Alternatively we could pass the called function name into
> > pguuid_complain, but I'm not sure it's worth the trouble (what does it
> > give the user, anyway?)
>
> Probably not much, if the uuid_error() strings are well written.

char *uuid_error(uuid_rc_t rc)
{
    char *str;

    switch (rc) {
        case UUID_RC_OK:  str = "everything ok";    break;
        case UUID_RC_ARG: str = "invalid argument"; break;
        case UUID_RC_MEM: str = "out of memory";    break;
        case UUID_RC_SYS: str = "system error";     break;
        case UUID_RC_INT: str = "internal error";   break;
        case UUID_RC_IMP: str = "not implemented";  break;
        default:          str = NULL;               break;
    }
    return str;
}


> Can we throw some more specific SQLSTATE than the default "internal
> error" here?  Offhand I can't think of anything, but as a rule of
> thumb an ereport() ought to have an errcode().  If it really is an
> internal error then elog() is good enough.

Hmm.  I looked at the extant list, and found that the contrib/xml2 code
uses ERRCODE_EXTERNAL_ROUTINE_EXCEPTION whereas pgcrypto uses
ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION.

In passing, I noticed the use of xml_ereport and xml_ereport_by_code in
the core XML code, and I'm left wondering whether we shouldn't add them
to the list of gettext triggers in nls.mk.  Also some messages there are
marked with ERRCODE_INTERNAL_ERROR.  (PLy_elog too?)

(Sorry, totally unrelated:) Wow, in plpython.c there is this:

static void *
PLy_malloc(size_t bytes)
{
    void       *ptr = malloc(bytes);

    if (ptr == NULL)
        ereport(FATAL,
                (errcode(ERRCODE_OUT_OF_MEMORY),
                 errmsg("out of memory")));
    return ptr;
}

I wonder why is it a good idea to have this report be FATAL.

--
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #3841: core dump in uuid-ossp
Next
From: Simon Riggs
Date:
Subject: Re: BUG #3843: archiver process is restarted after the smart shutdown