Summary:ASTERISK-12032: [patch] fix module loading of chan_oss when you already got chan_console loaded (channel type conflict)
Reporter:Caio Begotti (caio1982)Labels:
Date Opened:2008-05-16 13:37:14Date Closed:2009-02-27 16:28:11.000-0600
Versions:Frequency of
Environment:Attachments:( 0) 20080617__bug12668.diff.txt
( 1) 20080826__bug12668.diff.txt
( 2) chan_oss_loading_btfull.log
( 3) gdb_dump.7932.txt
( 4) oss-20080826-crash1.log
( 5) valgrind-trunk-175477.txt
Description:Until now chan_oss didn't handle its own loading very well. As it has the same channel type 'Console' as chan_console, if you use autoload=yes at modules.conf and chan_console loads up before chan_oss, the later would fail miserably and Asterisk wouldn't start up. Hopefully this patch will fix it by making it act more like chan_console when handling this.


WARNING[29337] channel.c: Already have a handler for type 'Console'
ERROR[29337] chan_oss.c: Unable to register channel type 'OSS'
[asterisk exits here because it was using AST_MODULE_LOAD_FAILURE]
Comments:By: Caio Begotti (caio1982) 2008-05-16 14:02:01

After some code review by Corydon-dig on IRC it's clear I probably overcorrected it, and the simplest solution is just to change AST_MODULE_LOAD_FAILURE to AST_MODULE_LOAD_DECLINE at chan_oss.c line 1444. The attached patch is not effective, thus it can be deleted :(

By: Tilghman Lesher (tilghman) 2008-05-16 16:22:53

That's not sufficient, either, really, because chan_oss should really clean up after itself, and it does not do so now (there are a bunch of elements that are allocated but not freed).  To return the DECLINE status, the module should first free all memory that it has allocated.

By: Caio Begotti (caio1982) 2008-05-17 16:31:19

Oh, now I realize why FAILURE does not require freeing anything, that was obvious... but what about the way chan_jingle checks for res_jabber? Would that be ok? It also DECLINES when cannot found the config file...

By: Tilghman Lesher (tilghman) 2008-05-18 10:25:37

That's fine, but note that chan_jingle doesn't actually allocate anything before that point, so when it returns the DECLINE status, it leaves memory in exactly the same state as it was before.  This is very important.

By: Tilghman Lesher (tilghman) 2008-06-02 16:32:28

caio82:  any progress on this?

By: Tilghman Lesher (tilghman) 2008-06-17 17:42:18

Since there has been no progress in 2 weeks, I am uploading my own patch, for 1.4, which fixes these resource leaks.

By: snuffy (snuffy) 2008-08-22 09:22:54

Can you report on any feedback for this caio1982 ?

By: Caio Begotti (caio1982) 2008-08-25 11:37:37

Sorry for the delay but I might be doing something wrong or something else because this patch Corydo76 attached does not solve the failed loading of Asterisk. Sometimes it works, sometimes it does not. I even got a segfault testing the patch on 1.4 (!). My last test was this:

*CLI> module load chan_oss.so
 == Parsing '/etc/asterisk/oss.conf': Found
[Aug 25 13:43:21] WARNING[14488]: channel.c:506 ast_channel_register: Already have a handler for type 'Console'
[Aug 25 13:43:21] ERROR[14488]: chan_oss.c:1898 load_module: Unable to register channel type 'OSS'
Segmentation fault (core dumped)

Full backtrace attached.

By: Tilghman Lesher (tilghman) 2008-08-26 08:07:49

Okay, corrected patch uploaded.

By: Caio Begotti (caio1982) 2008-08-26 09:15:47

Still crashing, oss-20080826-crash1.log attached.

By: Caio Begotti (caio1982) 2008-08-26 09:17:03

I also wonder why I do always get "APPLICATION ERROR ASTERISK-2171 Could not find a tag with that name." every time I upload a log file... :(

By: Tilghman Lesher (tilghman) 2008-08-26 10:26:30

caio1982:  file a bug in the Mantis category, please.

By: Tilghman Lesher (tilghman) 2008-08-26 11:47:48

caio1982:  could you provide a gdb dump, please?  This output is very difficult to decode.

By: Caio Begotti (caio1982) 2008-09-02 10:13:08

Ok, I've tried to reproduce it with your latest patch in order to get a gdb dump and I had to start Asterisk a couple of times because sometimes it just exits, others it works and one time it freezed (then I called ast_grab_core). I hope it helps now :-)

By: Tilghman Lesher (tilghman) 2008-10-06 15:30:40

caio1982:  due to the infrequency of crashing and the gdb output, I'm going to need you to run this under valgrind.

By: Caio Begotti (caio1982) 2008-10-17 11:56:04

Ouch, I did not notice Mantis' message about it, sorry. I'll test it under Valgrind as soon I get some spare time here. Thanks!

By: Caio Begotti (caio1982) 2008-10-20 10:08:58

I could not attach Valgrind's output to the ticket due a weird bug with Firefox 3 (bug MAN-22 filed under Mantis). I've pasted it elsewhere: http://pastebin.com/f2881fac9

The command ran was (malloc_debug.txt is empty):

sudo valgrind --log-file=valgrind.txt --leak-check=full --show-reachable=yes /usr/sbin/asterisk -vvvvddddcg 2>malloc_debug.txt

By: Caio Begotti (caio1982) 2008-10-20 10:21:22

And here it's with your patch applied (since this time Asterisk started properly I had to manuall unload chan_alsa.so, then I had a crash): http://pastebin.com/ma699f03

By: Caio Begotti (caio1982) 2008-11-04 06:56:58.000-0600

Did these logs help, Corydon76?

By: Tilghman Lesher (tilghman) 2009-01-16 14:46:42.000-0600

caio1982: the second valgrind seems to have expired from cache since you posted it.

By: Tilghman Lesher (tilghman) 2009-01-25 15:33:15.000-0600

caio1982:  I need a response before I can continue.

By: Tilghman Lesher (tilghman) 2009-02-09 14:36:47.000-0600

No response from reporter.

By: Caio Begotti (caio1982) 2009-02-13 07:32:01.000-0600

I just manage to sit down and pay attention to it right now. Valgrind log attached from latest trunk revision. If you can produce another updated patch for this (I could not do it on my own) I can test it right away, Corydon.

By: Caio Begotti (caio1982) 2009-02-13 07:34:16.000-0600

Damn you Mantis! Uploaded to my server at http://caio.ueberalles.net/asterisk/valgrind-trunk-175477.txt

By: Joshua C. Colp (jcolp) 2009-02-13 08:27:10.000-0600

I just uploaded the file myself fine.

By: Caio Begotti (caio1982) 2009-02-13 08:34:37.000-0600


By: Tilghman Lesher (tilghman) 2009-02-19 15:27:00.000-0600

caio1982:  The only problem here is deep within libasound, not within the Asterisk code.  This may need to be routed upstream to the libasound project.

By: Caio Begotti (caio1982) 2009-02-20 09:40:06.000-0600

I will try to contact them, no problem. Any hints, thoughts or comments that I should be aware of, so they can have more details about this issue concerning their library?

Thanks once more,

By: Tilghman Lesher (tilghman) 2009-02-20 10:04:58.000-0600

The gdb backtrace, actually, may be helpful to them in tracking down the problem, but they will be able to say more definitively.

By: Leif Madsen (lmadsen) 2009-02-27 16:28:11.000-0600

I'm closing this issue as the comments seem to indicate the issue is upstream in another library. Please reopen the issue should you have any new information to move this issue forward within Asterisk. Thanks!