Обсуждение: Bounds error in LockMethodInit().

Поиск
Список
Период
Сортировка

Bounds error in LockMethodInit().

От
Kurt Roeckx
Дата:
In lmgr.c you have a static LOCKMASK LockConflicts[] with 9
elements in it.

You call LockMethodTableInit() with that pointer, and
MAX_LOCKMODES - 1 (10 - 1 = 9)

That calls LockMethodInit with the same arguments, but it does
numModes++.

So you basicly have a for loop that looks like:

for (i = 0; i < 10; i++, conflictsP++)

The last item you try to copy is conflictsP is not within the
the LockConflicts array anymore.

I have no idea what that numModes++ line is doing there.


Kurt



Re: Bounds error in LockMethodInit().

От
Tom Lane
Дата:
Kurt Roeckx <Q@ping.be> writes:
> I have no idea what that numModes++ line is doing there.

I think the notion is that the lock modes are counted in 1-based
numbering; the copy loop starts at 0 so it needs an extra iteration.
Look at the uses of numLockModes for evidence.  (Note the extra zero
at the start of LockConflicts[].  Why it's bothering to copy that,
I dunno.)

I agree the call from lmgr.c is bogus though --- should be doing
something involving lengthof(LockConflicts), probably.  The existing
coding would fail to raise a flag if someone added a few more lock
modes without increasing MAX_LOCKMODES.
        regards, tom lane