Skip to content

cdb: fix SEGFAULT for gpdb builded with cassert#381

Merged
Stolb27 merged 3 commits into
adb-6.x-devfrom
ADBDEV-2973
Aug 30, 2022
Merged

cdb: fix SEGFAULT for gpdb builded with cassert#381
Stolb27 merged 3 commits into
adb-6.x-devfrom
ADBDEV-2973

Conversation

@HustonMmmavr

Copy link
Copy Markdown

Partition exchanging with different distribution policy may produce
SEGFAULT at gpdb builded with --enable-cassert.

If table, that are exhanging, has deleted column and has difference in
distribution policy with parent table (ex. parent was created with
default policy and new table created with GpPolicy
distributed randomly, or distribution column was dropped at new table)
then operation:
alter table parent_tbl exhange partition for ... with exchange_tbl
may produce SEGFAULT at function is_exchangeble.
In case described above, Assert(newpol->attrs[i] > 0), checks that
new GpPolicy (of new table) has distribution keys, but it doesn't
have them (attrs is NULL and nattrs=0), so a NULL pointer
dereference occurs.
This assertion, seems, should be deleted, because next access to
attrs is at function GpPolicyEqual(adjpol, newpol) (in the code
below), but before accessing to attrs function validates equality of
the GpPolicie's nattrs, if them not equal this function returns false
and attrs won't be accessed.

Here are some reminders before you submit the pull request

  • Add tests for the change
  • Document changes
  • Communicate in the mailing list if needed
  • Pass make installcheck
  • Review a PR in return to support the community

Stolb27 and others added 2 commits August 24, 2022 14:29
ADB 6.21.1_arenadata36 release
Partition exchanging with different distribution policy may produce
`SEGFAULT` at gpdb builded with `--enable-cassert`.

If table, that are exhanging, has deleted column and has difference in
distribution policy with parent table (ex. parent was created with
default policy and new table created with `GpPolicy`
`distributed randomly`, or distribution column was dropped at new table)
then operation:
`alter table parent_tbl exhange partition for ... with exchange_tbl`
may produce `SEGFAULT` at function `is_exchangeble`.
In case described above, `Assert(newpol->attrs[i] > 0)`, checks that
new `GpPolicy` (of new table) has distribution keys, but it doesn't
have them (`attrs` is `NULL` and `nattrs`=0), so a NULL pointer
dereference occurs.
This assertion, seems, should be deleted, because next access to
`attrs` is at function `GpPolicyEqual(adjpol, newpol)` (in the code
below), but before accessing to `attrs` function validates equality of
the GpPolicie's `nattrs`, if them not equal this function returns false
and `attrs` won't be accessed.
@HustonMmmavr HustonMmmavr marked this pull request as ready for review August 25, 2022 06:01
@HustonMmmavr HustonMmmavr requested a review from a team August 25, 2022 07:43
RekGRpth
RekGRpth previously approved these changes Aug 25, 2022
@Stolb27 Stolb27 changed the base branch from adb-6.x to adb-6.x-dev August 29, 2022 03:52
@Stolb27 Stolb27 dismissed RekGRpth’s stale review August 29, 2022 03:52

The base branch was changed.

@Stolb27 Stolb27 enabled auto-merge (squash) August 29, 2022 03:53

@Stolb27 Stolb27 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @HustonMmmavr. Thank you, @RekGRpth, for review.

@Stolb27 Stolb27 merged commit 5ee1288 into adb-6.x-dev Aug 30, 2022
@Stolb27 Stolb27 deleted the ADBDEV-2973 branch August 30, 2022 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants