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

db-parser, pdbtool, graphite-output: fix glib assertion error #3344

Merged
merged 7 commits into from Jul 6, 2020

Conversation

furiel
Copy link
Collaborator

@furiel furiel commented Jul 1, 2020

void
g_error_free (GError *error)
{
  g_return_if_fail (error != NULL);

  g_free (error->message);

  g_slice_free (GError, error);
}

g_error_free does not expect it's parameter to be null. If syslog-ng
is started with G_DEBUG=fatal-warnings, this causes a
crash. Otherwise there is a warning:

[2020-07-01T13:17:46.293581] g_error_free: assertion 'error != NULL' failed

Example configuration:

@version: 3.27

log {
  parser { db-parser(file("/tmp/patterndb.xml")); };
};

/tmp/patterndb.xml:

<patterndb version='4' pub_date='2020-03-03'>
  <ruleset name='test' id='x'>
  </ruleset>
</patterndb>


$ ../bin/pdbtool merge -D tmp --pdb output/merge.xml

(pdbtool:11058): GLib-CRITICAL **: g_error_free: assertion 'error != NULL' failed

(pdbtool:11058): GLib-CRITICAL **: g_error_free: assertion 'error != NULL' failed
$ echo $?
0
$  

@version: 3.27

log {
  source { example-msg-generator(num(1) values(test.key1 => value1 test.key2 => value2)); };
  destination { file(/dev/stdout template("$(graphite-output --timestamp 'custom_timestamp' --key test.*)")); };
};
$ ./syslog-ng -Fe -f ../etc/graphite.conf 
syslog-ng: Error setting capabilities, capability management disabled; error='Operation not permitted'
[2020-07-06T08:43:31.659210] g_error_free: assertion 'error != NULL' failed
[2020-07-06T08:43:31.659854] syslog-ng starting up; version='3.28.1.37.g3256a78'
test.key1 value1 custom_timestamp
test.key2 value2 custom_timestamp
^C[2020-07-06T08:43:33.184553] syslog-ng shutting down; version='3.28.1.37.g3256a78'
$ 

@kira-syslogng
Copy link
Contributor

Build SUCCESS

@Kokan
Copy link
Collaborator

Kokan commented Jul 1, 2020

In the tf_graphite_parse_command_line_arguments function also there is an instance of possible error. (while documentation is not clear on, I think in case of success -> true, probably it won't set error.)

@szemere
Copy link
Collaborator

szemere commented Jul 2, 2020

Unfortunately I introduced this error. :( Checked my earlier PR #3265, there are other places where we are mixing goto error with the normal code flow, and reach g_error_free without an actual error:

@kira-syslogng
Copy link
Contributor

Build SUCCESS

@furiel furiel changed the title db-parser: fix assertion during patterndb load db-parser, pdbtool, graphite-output: fix glib assertion error Jul 6, 2020
@furiel
Copy link
Collaborator Author

furiel commented Jul 6, 2020

Thanks for pointing these out. I fixed those too.

@kira-syslogng
Copy link
Contributor

Build SUCCESS

szemere
szemere previously approved these changes Jul 6, 2020
Kokan
Kokan previously approved these changes Jul 6, 2020
@furiel furiel dismissed stale reviews from Kokan and szemere via a898c96 July 6, 2020 10:39
@furiel
Copy link
Collaborator Author

furiel commented Jul 6, 2020

I forgot about a signed off. Fixed.

```
void
g_error_free (GError *error)
{
  g_return_if_fail (error != NULL);

  g_free (error->message);

  g_slice_free (GError, error);
}
```

`g_error_free` does not expect it's parameter to be null. If syslog-ng
is started with `G_DEBUG=fatal-warnings`, this causes a
crash. Otherwise there is a warning:

```
[2020-07-01T13:17:46.293581] g_error_free: assertion 'error != NULL' failed

```

Signed-off-by: Antal Nemes <antal.nemes.hu@gmail.com>
Signed-off-by: Antal Nemes <antal.nemes.hu@gmail.com>
Signed-off-by: Antal Nemes <antal.nemes.hu@gmail.com>
Signed-off-by: Antal Nemes <antal.nemes.hu@gmail.com>
Signed-off-by: Antal Nemes <antal.nemes.hu@gmail.com>
Signed-off-by: Antal Nemes <antal.nemes.hu@gmail.com>
Signed-off-by: Antal Nemes <antal.nemes.hu@gmail.com>
@kira-syslogng
Copy link
Contributor

Build SUCCESS

@szemere szemere merged commit aaed338 into syslog-ng:master Jul 6, 2020
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

4 participants