Please, fix!!! The backend can crash on your system!

From: Alexis Wilke <alexis_wilke(at)yahoo(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Please, fix!!! The backend can crash on your system!
Date: 2001-03-28 19:03:55
Message-ID: 20010328190355.12331.qmail@web1105.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

If PostgreSQL failed to compile on your computer or you found a bug that
is likely to be specific to one platform then please fill out this form
and e-mail it to pgsql-ports(at)postgresql(dot)org(dot)

To report any other bug, fill out the form below and e-mail it to
pgsql-bugs(at)postgresql(dot)org(dot)

If you not only found the problem but solved it and generated a patch
then e-mail it to pgsql-patches(at)postgresql(dot)org instead. Please use the
command "diff -c" to generate the patch.

You may also enter a bug report at http://www.postgresql.org/ instead of
e-mail-ing this form.

============================================================================
POSTGRESQL BUG REPORT TEMPLATE
============================================================================

Your name : Alexis Wilke
Your email address : alexis(at)m2osw(dot)com

System Configuration
---------------------
Architecture (example: Intel Pentium) : trust me, doesn't matter

Operating System (example: Linux 2.0.26 ELF) : trust me, doesn't matter

PostgreSQL version (example: PostgreSQL-7.0): since PostgreSQL-6.5.x
and still in the code

Compiler used (example: gcc 2.8.0) : trust me, doesn't matter

Please enter a FULL description of your problem:
------------------------------------------------

It crashes when pg_database is too large. This is because
the index is compare to max with <= instead of <. I already
fixed the bug on my system. That's at line

Please describe a way to repeat the problem. Please try to provide a
concise reproducible example, if at all possible:
----------------------------------------------------------------------

Create many database (or create/destroy the same many times).

Once the pg_database is more than one page (16Kb) then it starts
crashing. (may not crash on all systems, but trust me, my fix
will work GREAT).

If you know how this problem might be fixed, list the solution below:
---------------------------------------------------------------------

Okay, so go in the following file:

./src/backend/utils/misc/database.c

and move to the line #183 (V7.0.1)

There, fix the for() as is:

for(i = 0; i < max; i++)

Why? Well, because 'i' starts at 0, therefore, you
can't access the tuple number 'max'. If you look in
other source files, you will quickly see that all
these for() loops are starting with an index of
1 and use some special functions/macros to access
the tuple data.

--- pgsql-hackers-owner(at)postgresql(dot)org wrote:
> Date: Wed, 28 Mar 2001 05:44:05 -0500 (EST)
> From: pgsql-hackers-owner(at)postgresql(dot)org
> To: Alexis Wilke <alexis_wilke(at)yahoo(dot)com>
> Subject: Stalled post to pgsql-hackers
>
> Your message to pgsql-hackers has been delayed
> pending approval of the list owner for
> the following reason(s):
>
> Non-Member Submission from Alexis Wilke <alexis_wilke(at)yahoo(dot)com>
>
>

> ATTACHMENT part 2 message/rfc822
> Date: Wed, 28 Mar 2001 02:28:45 -0800 (PST)
> From: Alexis Wilke <alexis_wilke(at)yahoo(dot)com>
> Subject: HUGE BUG - Please fix!!!
> To: pgsql-hackers(at)postgresql(dot)org
>
> Hi guys,
>
> I don't want to do a patch for a one character error. Yet, that's a HUGE
> error and it really needs to be fixed.
>
> Once you have a pg_database file which is over 1 page, it CRASHES.
> That's
> what it did on me. Yes! I have many databases or rather, I often destroy
> my databases to regenerate them from scratch (that's for me the easiest
> way to do it). Because of that, the pg_database is now two pages.
>
> The utils/misc/database.c has a function called GetRawDatabaseInfo()
> which reads that file "on its own". There is a HUGE bug in there, and
> it may not always crash a system, but it really needs to be fixed.
>
> At line #183, you have a for() loop which looks like this (since at
> least V6.5.0 and still present in V7.0.3):
>
> for (i = 0; i <= max; i++)
>
> All the other such loops start with an index of 1, not zero. And
> therefore you want the <=. In this special case loop (or are all
> the others special cases?!?) you need to use the following:
>
> for(i = 0; i < max; i++)
>
> Please, I know it's easier when you get a patch, but FIX IT. It's
> not fun to try to access your database and have the backend crash
> because of such a tiny bug!
>
> Thank you for all your work.
>
>
>
> Alexis Wilke
> Director
> Made to Order Software, Ltd
>
> e-mail: alexis(at)m2sow(dot)com
>
> Web Page: http://www.m2osw.com
> Company e-mail: contact(at)m2osw(dot)com
> Phone: 020 8748 9898 +(44) 20 8748 9898
> Fax: 020 8748 4250 +(44) 20 8748 4250
> Address: Britannia House
> 1-11 Glenthorne Road
> Hammersmith
> London W6 0LF
> United Kingdom
>
>
> __________________________________________________
> Do You Yahoo!?
> Get email at your own domain with Yahoo! Mail.
> http://personal.mail.yahoo.com/?.refer=text
>

__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.
http://personal.mail.yahoo.com/?.refer=text

Browse pgsql-bugs by date

  From Date Subject
Next Message pgsql-bugs 2001-03-28 19:15:13 Option in pg_hba.conf to specify permissions and owner for the socket file
Previous Message Tom Lane 2001-03-28 18:39:14 Re: Datatype SERIAL incorrectly interpreted