Skip to content

Draft: agent: use g_test_set_nonfatal_assertions() to disable asserts

Juan Navarro requested to merge j1elo/libnice:assert-disable into master

libnice changed from g_assert() to the g_assert_*() family of functions provided by the GLib Test module, in this commit: 1da0537b

The intention of that change was to provide better debug logs when an assertion is not passed, because g_assert() just aborts the process, while the g_assert_*() alternatives will also print the actual values that were expected and obtained just before aborting.

It might be useful to disable assertions in big production servers, and for that, GLib supports compiling the application with -DG_DISABLE_ASSERT. However this only works for the basic case of using g_assert(), and not for all the other functions that libnice uses. So users of libnice have been unable to disable all assertions since the change described above.

GLib does, however, allow to disable calls to abort() from its Test assert functions, as long as g_test_set_nonfatal_assertions() has been called before. This change does precisely that, in the Agent constructor.

Fixes #128 (closed)

Requires / Depends on !207 (merged). This MR has been based on the branch of !207 (merged), and it's the first time I do that, so I guess changes of both branches will show up here, until !207 (merged) gets merged, then Gitlab should update this MR automatically, to reflect only the actual changes introduced here. Meanwhile, this MR is marked as Draft, to prevent accidentally merging this before !207 (merged).

Merge request reports