Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add necessary unref to accessor.c and report.c #1334

Merged
merged 4 commits into from
Mar 24, 2022

Conversation

HashidaTKS
Copy link
Contributor

@HashidaTKS HashidaTKS commented Mar 17, 2022

Related: #1333, #1330

When executing grn_accessor_execute or grn_report_table, a referred object is not un-referred in some cases.
I have added necessary unrefs for those.

Please see the added reference_count.test for reproducing the issue.
This affect to #1330.

@HashidaTKS HashidaTKS force-pushed the add_unref_to_select branch 3 times, most recently from b15bba8 to d7a8741 Compare March 23, 2022 06:43
lib/report.c Outdated
@@ -87,6 +87,9 @@ grn_report_table(grn_ctx *ctx,
GRN_TEXT_PUT(ctx, &description, name, name_size);
GRN_TEXT_PUTS(ctx, &description, ">");
}
if (target != table) {
grn_obj_unref(ctx, target);
Copy link
Member

Choose a reason for hiding this comment

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

This is invalid.
We use target after this grn_obj_unref for target = grn_ctx_at(ctx, target->header.domain). If target is closed by this grn_obj_unref(), target->header.domain touches invalid memory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, I have fixed it.

#@add-ignore-log-pattern /\A\[io\]/
log_level --level dump
select Items \
--column[price_with_tax].stage initial \
Copy link
Member

Choose a reason for hiding this comment

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

Could you use columns instead of column because column is deprecated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have fixed it.

Modify to use columns in the test
lib/report.c Outdated
@@ -65,7 +65,7 @@ grn_report_table(grn_ctx *ctx,
grn_obj *table)
{
grn_obj description;
grn_obj *target;
grn_obj *target, *previous_target = NULL;
Copy link
Member

Choose a reason for hiding this comment

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

Could you declare one variable per line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have fixed it.

lib/report.c Outdated
if (previous_target && previous_target != table) {
grn_obj_unref(ctx, previous_target);
}
previous_target = target;
Copy link
Member

Choose a reason for hiding this comment

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

Could you move this to for (...) to indicating that this is update in each loop?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have fixed it.

@kou kou marked this pull request as ready for review March 24, 2022 01:42
@HashidaTKS
Copy link
Contributor Author

I have noticed that grn_report_column and grn_report_accessor seem to have the same issue.
I will fix them another PR.

@kou kou merged commit 556fb5d into groonga:master Mar 24, 2022
@kou
Copy link
Member

kou commented Mar 24, 2022

It makes sense.

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.

None yet

2 participants