File: h323-workaround-openh323-segfault

package info (click to toggle)
asterisk 1%3A1.6.2.9-2%2Bsqueeze12
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 67,296 kB
  • ctags: 65,026
  • sloc: ansic: 327,660; sh: 11,153; cpp: 5,940; perl: 3,078; makefile: 2,594; yacc: 2,140; asm: 642; xml: 309; sql: 290; tcl: 113; php: 62
file content (31 lines) | stat: -rw-r--r-- 1,290 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Subject: Hack dynamic loader to workaround libopenh323 bug
Author: Faidon Liambotis <paravoid@debian.org>
Forwarded: no
Last-Update: 2009-12-19

libopenh323 is buggy and crashes on dlclose() when the library was opened with
RTLD_LAZY (#438815). Hack around this by opening it with RTLD_NOW by matching
the module names (chan_h323.so and the external chan_oh323.so)

This is a very crude hack needed because we are removing libopenh323
dependencies from the asterisk binary. (h323-no-deps-on-asterisk)
Namely, it will have unexpected results if e.g. the user renames the module
for any reason.

Should be removed when #438815 closes.

--- a/main/loader.c
+++ b/main/loader.c
@@ -382,6 +382,12 @@ static struct ast_module *load_dynamic_m
 	if (missing_so)
 		strcat(resource_being_loaded->resource, ".so");
 
+	/* libopenh323 is buggy and segfaults on dlclose() when opened with
+	 * RTLD_LAZY. Workaround this until it gets fixed */
+	if (!strcasecmp(resource_being_loaded->resource, "chan_h323.so") ||
+	    !strcasecmp(resource_being_loaded->resource, "chan_oh323.so"))
+		lib = dlopen(fn, RTLD_NOW | RTLD_LOCAL);
+
 	if (!(lib = dlopen(fn, RTLD_LAZY | RTLD_LOCAL))) {
 		ast_log(LOG_WARNING, "Error loading module '%s': %s\n", resource_in, dlerror());
 		ast_free(resource_being_loaded);