Merge ~mirespace/ubuntu/+source/augeas:lp-1828074-bionic-augeas-memorybomb into ubuntu/+source/augeas:ubuntu/bionic-devel

Proposed by Miriam España Acebal
Status: Approved
Approved by: Utkarsh Gupta
Approved revision: b0c6fa20dcc275383ba7dcc3d0ac88ad40aabc38
Proposed branch: ~mirespace/ubuntu/+source/augeas:lp-1828074-bionic-augeas-memorybomb
Merge into: ubuntu/+source/augeas:ubuntu/bionic-devel
Diff against target: 206 lines (+162/-1)
5 files modified
debian/changelog (+13/-0)
debian/control (+2/-1)
debian/patches/0005-Replace-pure-funcs-calls-in-path-expr-w-result.patch (+143/-0)
debian/patches/series (+1/-0)
debian/rules (+3/-0)
Reviewer Review Type Date Requested Status
Utkarsh Gupta (community) Approve
Canonical Server MOTU reviewers Pending
Review via email: mp+408941@code.launchpad.net

Description of the change

Hi Team,

PPA for these SRUs is : ppa:mirespace/sru-lp-1828074-bionic-augeas-large-http-files

Two issues were fixed here:

- The use of memory grows as a site conf file enlarges when using augeas:
    * d/p/0005-Memory-usage-issues-with-large-Apache-httpd-configuration-files.patch:
      Replace pure function invocations in
      path expressions with their result. Thanks to
      David Lutterkort <email address hidden>
      (LP: #1828074).

    Steps to reproduce the issue are described in the SRU template of the bug.

- Package augeas was FTBFS in Bionic:
    * d/rules: Disable gnulib tests, thanks to Matthias
    Klose <email address hidden>
    (Closes: #919662)(LP: #1813566).

  Without this, the package can't be built on Bionic (2 tests fail: test-rwlock1 , test-thread_create). This tests are not checking augeas itself as commented on https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=919662

Both fixes have been cherry picked from upstream (the patch) and Debian.

Built tests passed ok (No DEP8 tests present):

============================================================================
Testsuite summary for augeas 1.10.1
============================================================================
# TOTAL: 247
# PASS: 243
# SKIP: 4
# XFAIL: 0
# FAIL: 0
# XPASS: 0
# ERROR: 0
============================================================================

Thanks in advance!

To post a comment you must log in.
Revision history for this message
Utkarsh Gupta (utkarsh) wrote :

Hello,

Thank you for the MP, please find the comments inline. TIA! \o/

review: Needs Fixing
Revision history for this message
Miriam España Acebal (mirespace) wrote :

Hello... some changes are done, some answers are inline with the no-changes.

Let me what you think and thanks for reviewing.

Revision history for this message
Miriam España Acebal (mirespace) wrote :

(For the inline comments)

Revision history for this message
Utkarsh Gupta (utkarsh) wrote :

Looks good, thanks, Miriam. I'll make minor edits in the d/ch entry and the patch whilst sponsoring.

review: Approve
Revision history for this message
Miriam España Acebal (mirespace) wrote :

SRUs templates updated!

Revision history for this message
Utkarsh Gupta (utkarsh) wrote :

$ dput ubuntu ../augeas_1.10.1-2ubuntu1_source.changes
Checking signature on .changes
gpg: ../augeas_1.10.1-2ubuntu1_source.changes: Valid signature from 823E967606C34B96
Checking signature on .dsc
gpg: ../augeas_1.10.1-2ubuntu1.dsc: Valid signature from 823E967606C34B96
Package includes an .orig.tar.gz file although the debian revision suggests
that it might not be required. Multiple uploads of the .orig.tar.gz may be
rejected by the upload queue management software.
Uploading to ubuntu (via ftp to upload.ubuntu.com):
  Uploading augeas_1.10.1-2ubuntu1.dsc: done.
  Uploading augeas_1.10.1.orig.tar.gz: done.
  Uploading augeas_1.10.1-2ubuntu1.debian.tar.xz: done.
  Uploading augeas_1.10.1-2ubuntu1_source.buildinfo: done.
  Uploading augeas_1.10.1-2ubuntu1_source.changes: done.
Successfully uploaded packages.

Unmerged commits

b0c6fa2... by Miriam España Acebal

changelog: 1.10.1-2ubuntu1

1e324e6... by Miriam España Acebal

update-maintainers

f4e6a83... by Miriam España Acebal

* d/rules: Disable gnulib tests due to that tests are not testing augeas
  itself. Thanks to Matthias Klose (Closes: #919662)(LP: #1813566).

c243422... by Miriam España Acebal

  * d/p/0005-Replace-pure-funcs-calls-in-path-expr-w-result.patch:
    Replace pure function invocations in path
    expressions with their result. Thanks to
    David Lutterkort <email address hidden>.
    (LP: #1828074)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/debian/changelog b/debian/changelog
index a3fef72..7690cfa 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,16 @@
1augeas (1.10.1-2ubuntu1) bionic; urgency=medium
2
3 * d/p/0005-Replace-pure-funcs-calls-in-path-expr-w-result.patch:
4 Replace pure function invocations in path
5 expressions with their result. Thanks to
6 David Lutterkort <github@watzmann.net>.
7 (LP: #1828074)
8 * d/rules: Disable gnulib tests due to that tests are not
9 testing augeas itself. Thanks to Matthias Klose
10 (Closes: #919662)(LP: #1813566).
11
12 -- Miriam España Acebal <miriam.espana@canonical.com> Mon, 20 Sep 2021 11:18:53 +0200
13
1augeas (1.10.1-2) unstable; urgency=medium14augeas (1.10.1-2) unstable; urgency=medium
215
3 * Add correct file paths to clamav.aug (Closes: #892913)16 * Add correct file paths to clamav.aug (Closes: #892913)
diff --git a/debian/control b/debian/control
index 523f25d..20711d5 100644
--- a/debian/control
+++ b/debian/control
@@ -1,6 +1,7 @@
1Source: augeas1Source: augeas
2Priority: optional2Priority: optional
3Maintainer: Hilko Bengen <bengen@debian.org>3Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
4XSBC-Original-Maintainer: Hilko Bengen <bengen@debian.org>
4Uploaders: Micah Anderson <micah@debian.org>5Uploaders: Micah Anderson <micah@debian.org>
5Build-Depends: debhelper (>= 10~),6Build-Depends: debhelper (>= 10~),
6 libreadline-dev,7 libreadline-dev,
diff --git a/debian/patches/0005-Replace-pure-funcs-calls-in-path-expr-w-result.patch b/debian/patches/0005-Replace-pure-funcs-calls-in-path-expr-w-result.patch
7new file mode 1006448new file mode 100644
index 0000000..57513cd
--- /dev/null
+++ b/debian/patches/0005-Replace-pure-funcs-calls-in-path-expr-w-result.patch
@@ -0,0 +1,143 @@
1Description: Replace pure function invocations in path expressions with their result
2 .
3 In path expressions, we generally need to evaluate functions against every
4 node that we consider for the result set. For example, in the path
5 expression /files/etc/hosts/*[ipaddr =~ regexp('127\\.')], the regexp
6 function was evaluated against every entry in /etc/hosts. Evaluating that
7 function requires the construction and compilation of a new regexp. Because
8 of how memory is managed during evaluation of path expressions, the memory
9 used by all these copies of the same regexp is only freed after we are done
10 evaluating the path expression. This causes unacceptable memory usage in
11 large files (see https://github.com/hercules-team/augeas/issues/569)
12 .
13 To avoid these issues, we now distinguish between pure and impure functions
14 in the path expression interpreter. When we encounter a pure function, we
15 change the AST for the path expression so that the function invocation is
16 replaced with the result of invoking the function. With the example above,
17 that means we only construct and compile the regexp '127\\.' once,
18 regardless of how many nodes it gets checked against. That leads to a
19 dramatic reduction in the memory required to evaluate path expressions with
20 such constructs against large files.
21Author: David Lutterkort <github@watzmann.net>
22Origin: upstream
23Bug: https://github.com/hercules-team/augeas/issues/569
24Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/augeas/+bug/1828074
25Forwarded: not-needed
26Applied-Upstream: https://github.com/hercules-team/augeas/pull/578/commits/bbf31f719db54916993be9042254f6d77b61cb13
27Last-Update: 2021-09-20
28---
29This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
30diff --git a/src/pathx.c b/src/pathx.c
31index 48c8b0b1..4c2aa3a7 100644
32--- a/src/pathx.c
33+++ b/src/pathx.c
34@@ -208,6 +208,10 @@ struct expr {
35 struct { /* E_APP */
36 const struct func *func;
37 struct expr **args;
38+ /* If fold is true, replace this function invocation
39+ * with its value after the first time we evaluate this
40+ * expression */
41+ bool fold;
42 };
43 };
44 };
45@@ -282,6 +286,7 @@ struct func {
46 const char *name;
47 unsigned int arity;
48 enum type type;
49+ bool pure; /* Result only depends on args */
50 const enum type *arg_types;
51 func_impl_t impl;
52 };
53@@ -304,40 +309,40 @@ static const enum type arg_types_nodeset_string[] = { T_NODESET, T_STRING };
54
55 static const struct func builtin_funcs[] = {
56 { .name = "last", .arity = 0, .type = T_NUMBER, .arg_types = NULL,
57- .impl = func_last },
58+ .impl = func_last, .pure = false },
59 { .name = "position", .arity = 0, .type = T_NUMBER, .arg_types = NULL,
60- .impl = func_position },
61+ .impl = func_position, .pure = false },
62 { .name = "label", .arity = 0, .type = T_STRING, .arg_types = NULL,
63- .impl = func_label },
64+ .impl = func_label, .pure = false },
65 { .name = "count", .arity = 1, .type = T_NUMBER,
66 .arg_types = arg_types_nodeset,
67- .impl = func_count },
68+ .impl = func_count, .pure = false },
69 { .name = "regexp", .arity = 1, .type = T_REGEXP,
70 .arg_types = arg_types_string,
71- .impl = func_regexp },
72+ .impl = func_regexp, .pure = true },
73 { .name = "regexp", .arity = 1, .type = T_REGEXP,
74 .arg_types = arg_types_nodeset,
75- .impl = func_regexp },
76+ .impl = func_regexp, .pure = true },
77 { .name = "regexp", .arity = 2, .type = T_REGEXP,
78 .arg_types = arg_types_string_string,
79- .impl = func_regexp_flag },
80+ .impl = func_regexp_flag, .pure = true },
81 { .name = "regexp", .arity = 2, .type = T_REGEXP,
82 .arg_types = arg_types_nodeset_string,
83- .impl = func_regexp_flag },
84+ .impl = func_regexp_flag, .pure = true },
85 { .name = "glob", .arity = 1, .type = T_REGEXP,
86 .arg_types = arg_types_string,
87- .impl = func_glob },
88+ .impl = func_glob, .pure = true },
89 { .name = "glob", .arity = 1, .type = T_REGEXP,
90 .arg_types = arg_types_nodeset,
91- .impl = func_glob },
92+ .impl = func_glob, .pure = true },
93 { .name = "int", .arity = 1, .type = T_NUMBER,
94- .arg_types = arg_types_string, .impl = func_int },
95+ .arg_types = arg_types_string, .impl = func_int, .pure = false },
96 { .name = "int", .arity = 1, .type = T_NUMBER,
97- .arg_types = arg_types_nodeset, .impl = func_int },
98+ .arg_types = arg_types_nodeset, .impl = func_int, .pure = false },
99 { .name = "int", .arity = 1, .type = T_NUMBER,
100- .arg_types = arg_types_bool, .impl = func_int },
101+ .arg_types = arg_types_bool, .impl = func_int, .pure = false },
102 { .name = "not", .arity = 1, .type = T_BOOLEAN,
103- .arg_types = arg_types_bool, .impl = func_not }
104+ .arg_types = arg_types_bool, .impl = func_not, .pure = true }
105 };
106
107 #define RET_ON_ERROR \
108@@ -1409,6 +1414,16 @@ static void eval_expr(struct expr *expr, struct state *state) {
109 break;
110 case E_APP:
111 eval_app(expr, state);
112+ if (expr->fold) {
113+ /* Do constant folding: replace the function application with
114+ * a reference to the value that resulted from evaluating it */
115+ for (int i=0; i < expr->func->arity; i++)
116+ free_expr(expr->args[i]);
117+ free(expr->args);
118+ value_ind_t vind = state->values_used - 1;
119+ expr->tag = E_VALUE;
120+ expr->value_ind = state->values[vind];
121+ }
122 break;
123 default:
124 assert(0);
125@@ -1493,6 +1508,18 @@ static void check_app(struct expr *expr, struct state *state) {
126 if (f < ARRAY_CARDINALITY(builtin_funcs)) {
127 expr->func = builtin_funcs + f;
128 expr->type = expr->func->type;
129+ expr->fold = expr->func->pure;
130+ if (expr->fold) {
131+ /* We only do constant folding for invocations of pure functions
132+ * whose arguments are literal values. That misses opportunities
133+ * for constant folding, e.g., "regexp('foo' + 'bar')" but is
134+ * a bit simpler than doing full tracking of constants
135+ */
136+ for (int i=0; i < expr->func->arity; i++) {
137+ if (expr->args[i]->tag != E_VALUE)
138+ expr->fold = false;
139+ }
140+ }
141 } else {
142 STATE_ERROR(state, PATHX_ETYPE);
143 }
diff --git a/debian/patches/series b/debian/patches/series
index 03f97f2..c9d719e 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -2,3 +2,4 @@
20002-Skip-tests-that-need-root-privileges-when-fakeroot-h.patch20002-Skip-tests-that-need-root-privileges-when-fakeroot-h.patch
30003-Make-NRPE-lens-less-strict.patch30003-Make-NRPE-lens-less-strict.patch
40004-Add-Debian-specific-paths-for-ClamAV-configuration-f.patch40004-Add-Debian-specific-paths-for-ClamAV-configuration-f.patch
50005-Replace-pure-funcs-calls-in-path-expr-w-result.patch
diff --git a/debian/rules b/debian/rules
index f077249..524d61e 100755
--- a/debian/rules
+++ b/debian/rules
@@ -10,6 +10,9 @@ include /usr/share/dpkg/buildflags.mk
10override_dh_autoreconf:10override_dh_autoreconf:
11 dh_autoreconf autoreconf -- -i11 dh_autoreconf autoreconf -- -i
1212
13override_dh_auto_configure:
14 dh_auto_configure -- --disable-gnulib-tests
15
13override_dh_auto_build:16override_dh_auto_build:
14 rm -f tetsts/lens-*.sh17 rm -f tetsts/lens-*.sh
15 dh_auto_build18 dh_auto_build

Subscribers

People subscribed via source and target branches