aMule Bug Tracker - aMule
View Issue Details
0001630aMuleExternal Connpublic2010-10-07 17:392011-03-09 15:14
moo 
sturedman 
normalminoralways
acknowledgedopen 
2.2.6 
 
openwrt x86
0001630: amuleweb working as amuled child, die on url add
when i submit ed2k url from the web, amuleweb dies
there's the strace log

recv(9, "POST /footer.php HTTP/1.1\r\nHost:"..., 4096, MSG_NOSIGNAL) = 797
time(NULL) = 1286464629
futex(0xb743ba40, FUTEX_WAKE_PRIVATE, 2147483647) = 0
write(1, "Template not found, reverting t"..., 43) = -1 EPIPE (Broken pipe)
--- SIGPIPE (Broken pipe) @ 0 (0) ---
exit_group(-1) = ?
Process 8895 detached

and part of amule.conf
[WebServer]
Enabled=1
Port=4711
WebUPnPTCPPort=50001
UPnPWebServerEnabled=0
UseGzip=1
UseLowRightsUser=0
PageRefreshTime=120
Template=
# lsof -np `pidof amuleweb` (before it dies)
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
amuleweb 8956 downloader cwd DIR 8,3 1024 110602 /data/home/downloader
amuleweb 8956 downloader rtd DIR 8,3 1024 2 /
amuleweb 8956 downloader txt REG 8,3 474532 540674 /usr/bin/amuleweb
amuleweb 8956 downloader mem REG 8,3 61865 49169 /lib/libresolv-2.7.so
amuleweb 8956 downloader mem REG 8,3 16514 49174 /lib/libnss_dns-2.7.so
amuleweb 8956 downloader mem REG 8,3 8270 49205 /lib/libdl-2.7.so
amuleweb 8956 downloader mem REG 8,3 1345915 49173 /lib/libc-2.7.so
amuleweb 8956 downloader mem REG 8,3 104971 49171 /lib/libgcc_s.so.1
amuleweb 8956 downloader mem REG 8,3 147517 49224 /lib/libm-2.7.so
amuleweb 8956 downloader mem REG 8,3 895811 45261 /usr/lib/libstdc++.so.6.0.14
amuleweb 8956 downloader mem REG 8,3 149540 45273 /usr/lib/libpng12.so.0.44.0
amuleweb 8956 downloader mem REG 8,3 198395 45089 /usr/lib/libncurses.so.5.7
amuleweb 8956 downloader mem REG 8,3 572025 46125 /usr/lib/libreadline.so.5.2
amuleweb 8956 downloader mem REG 8,3 80697 45093 /usr/lib/libz.so.1.2.5
amuleweb 8956 downloader mem REG 8,3 1193983 45384 /usr/lib/libwx_baseu-2.8.so.0.6.0
amuleweb 8956 downloader mem REG 8,3 170773 45121 /usr/lib/libwx_baseu_net-2.8.so.0.6.0
amuleweb 8956 downloader mem REG 8,3 86328 49218 /lib/libpthread-2.7.so
amuleweb 8956 downloader mem REG 8,3 124335 49235 /lib/ld-2.7.so
amuleweb 8956 downloader 0u IPv4 698918 0t0 TCP 127.0.0.1:58048->127.0.0.1:4712 (ESTABLISHED)
amuleweb 8956 downloader 1u IPv4 699009 0t0 TCP *:4711 (LISTEN)
amuleweb 8956 downloader 2w REG 0,11 179967 190 /tmp/log/runsvdir.log
amuleweb 8956 downloader 4u IPv4 704069 0t0 TCP 192.168.1.1:4711->192.168.1.3:2506 (ESTABLISHED)
amuleweb 8956 downloader 5u sock 0,5 0t0 704063 can't identify protocol

output of "ps -efH"root 782 731 0 17:52 ? 00:00:00 runsv amule
103 785 782 0 17:52 ? 00:00:00 logger -t amule
103 8951 782 46 23:26 ? 00:01:09 amuled --log-stdout
103 8956 8951 0 23:26 ? 00:00:00 amuleweb --amule-config-file=/home/downloader/.aMule/amule.conf

by roughly reading amule source i can see quit is set to true if amuleweb starts with --amule-config-file to avoid writing to fd 1, but it still write to fd 1 as you can see from my strace loghope you have better idea than i do
No tags attached.
Issue History
2010-10-07 17:39mooNew Issue
2010-10-07 17:39mooOperating System => openwrt x86
2010-10-09 22:50sturedmanNote Added: 0003499
2010-10-10 09:50mooNote Added: 0003501
2010-10-10 09:54mooNote Added: 0003502
2010-10-10 17:16mooNote Added: 0003504
2010-10-10 17:33mooNote Added: 0003505
2011-02-03 09:58mooNote Added: 0003536
2011-03-09 15:10sturedmanNote Edited: 0003501
2011-03-09 15:14sturedmanNote Added: 0003543
2011-03-09 15:14sturedmanAssigned To => sturedman
2011-03-09 15:14sturedmanSeveritymajor => minor
2011-03-09 15:14sturedmanStatusnew => acknowledged

Notes
(0003499)
sturedman   
2010-10-09 22:50   
Please run amuleweb with gdb to get a backtrace (it has to have debug info).
(0003501)
moo   
2010-10-10 09:50   
(edited on: 2011-03-09 15:10)
it is reproducable if file name is not ascii like the following url
ed2k://|file|%5B%E5%90%8D%E4%BE%A6%E6%8E%A2%E6%9F%AF%E5%8D%97.%E5%89%A7%E5%9C%BA%E7%89%88%E7%AC%AC%E5%8D%81%E5%9B%9B%E5%BC%B9.%E5%A4%A9%E7%A9%BA%E7%9A%84%E9%81%87%E9%9A%BE%E8%88%B9%5D.%5BHYSUB%5Dxxxxxxxxxxxxxxxxxxxxxx%5BDVD-RMVB%5D%5BGB_RV10%5D%5B856X480%5D.rmvb|492999999|000000000000000000000000000000|h=km6ylogseygmefpjoi4ibt7pmhnoobew|/ [^]
i found a way to workaround some url by using amulecmd instead, but the above url is refused by amulecmd
 > Request failed with the following error: Invalid link or already on list.
after i remove the non-ascii part of filename from the url, it works, either in amulecmd or amuleweb

what do you wan't from gdb? it's a normal exit and what backtrace should i print? break on Show function and cath the message "Template not found, reverting t"? i'll have to recompile amule but you can try the above link

(0003502)
moo   
2010-10-10 09:54   
btw, the non-ascii part of filename is UTF-8 encoding, and then URL encoded

so we get 2 problem.
1. handle utf-8 filenames (or because there's no locale files/support on openwrt?)
2. never ever write to fd 1 when amuleweb is started by amuled
(0003504)
moo   
2010-10-10 17:16   
write(1, "Template not found, reverting t"..., 43) = -1 EPIPE (Broken pipe)
--- SIGPIPE (Broken pipe) @ 0 (0) ---
exit_group(-1) = ?

i have no idea yet on why it's triggered, the logic and the m_KeepQuiet variable is correct

# gdb --pid `pidof amuleweb`
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> [^]
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-openwrt-linux".
Attaching to process 9386
Reading symbols from /data/root/amule/src/webserver/src/amuleweb...done.
Reading symbols from /lib/libpthread.so.0...done.
Loaded symbols for /lib/libpthread.so.0
Reading symbols from /usr/lib/libwx_baseu_net-2.8.so.0...done.
Loaded symbols for /usr/lib/libwx_baseu_net-2.8.so.0
Reading symbols from /usr/lib/libwx_baseu-2.8.so.0...done.
Loaded symbols for /usr/lib/libwx_baseu-2.8.so.0
Reading symbols from /usr/lib/libbfd-2.19.1.so...done.
Loaded symbols for /usr/lib/libbfd-2.19.1.so
Reading symbols from /usr/lib/libz.so.1...done.
Loaded symbols for /usr/lib/libz.so.1
Reading symbols from /usr/lib/libreadline.so.5...done.
Loaded symbols for /usr/lib/libreadline.so.5
Reading symbols from /usr/lib/libncurses.so.5...done.
Loaded symbols for /usr/lib/libncurses.so.5
Reading symbols from /usr/lib/libpng12.so.0...done.
Loaded symbols for /usr/lib/libpng12.so.0
Reading symbols from /usr/lib/libstdc++.so.6...
warning: no loadable sections found in added symbol-file /usr/lib/libstdc++.so.6
done.
Loaded symbols for /usr/lib/libstdc++.so.6
Reading symbols from /lib/libm.so.6...done.
Loaded symbols for /lib/libm.so.6
Reading symbols from /lib/libgcc_s.so.1...
warning: no loadable sections found in added symbol-file /lib/libgcc_s.so.1
done.
Loaded symbols for /lib/libgcc_s.so.1
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
Reading symbols from /lib/libdl.so.2...done.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /lib/libnss_dns.so.2...done.
Loaded symbols for /lib/libnss_dns.so.2
Reading symbols from /lib/libresolv.so.2...done.
Loaded symbols for /lib/libresolv.so.2
0xb7326f78 in select () from /lib/libc.so.6
(gdb) br CaMuleExternalConnector::Show
Breakpoint 1 at 0x80748a5: file ../../../src/ExternalConnector.cpp, line 227.
(gdb) c
Continuing.

Breakpoint 1, CaMuleExternalConnector::Show (this=0x8d42770, s=@0xbfc98e94) at ../../../src/ExternalConnector.cpp:227
227 if( !m_KeepQuiet ) {
(gdb) c
Continuing.
--- now submit url from web or reload to resubmit previous submitted url, don't request to any other urls ---
Breakpoint 1, CaMuleExternalConnector::Show (this=0x8d42770, s=@0xbfc98c2c) at ../../../src/ExternalConnector.cpp:227
227 if( !m_KeepQuiet ) {
(gdb)
Continuing.

Breakpoint 1, CaMuleExternalConnector::Show (this=0x8d42770, s=@0xbfc98ba0) at ../../../src/ExternalConnector.cpp:227
227 if( !m_KeepQuiet ) {
(gdb)
Continuing.

Breakpoint 1, CaMuleExternalConnector::Show (this=0x8d42770, s=@0xbfc98ba4) at ../../../src/ExternalConnector.cpp:227
227 if( !m_KeepQuiet ) {
(gdb) n
233 }
(gdb)
CWebServerBase::Print (this=0x8d4db18, s=@0xbfc98ba4) at WebServer.cpp:250
250 }
(gdb)
CScriptWebServer::CheckLoggedin (this=0x8d4db18, Data=@0xbfc98dc4) at WebServer.cpp:1838
1838 Data.parsedURL.ConvertParams(session->m_get_vars);
(gdb) n
CParsedUrl::ConvertParams (this=0xbfc98dc4, dst=@0x8d65c34) at WebServer.cpp:211
211 std::string key(unicode2char(i->first)), value(unicode2char(i->second));
(gdb)
212 dst[key] = value;
(gdb)
211 std::string key(unicode2char(i->first)), value(unicode2char(i->second));
(gdb)
210 for(std::map<wxString, wxString>::iterator i = m_params.begin(); i != m_params.end(); i++) {
(gdb)
211 std::string key(unicode2char(i->first)), value(unicode2char(i->second));
(gdb) bt
#0 CParsedUrl::ConvertParams (this=0xbfc98dc4, dst=@0x8d65c34) at WebServer.cpp:211
0000001 0x0805ae91 in CScriptWebServer::CheckLoggedin (this=0x8d4db18, Data=@0xbfc98dc4) at WebServer.cpp:1838
0000002 0x0805b053 in CScriptWebServer::ProcessURL (this=0x8d4db18, Data=
      {parsedURL = {m_path = {<wxStringBase> = {static npos = 4294967295, m_pchData = 0xb7703aa8}, <No data fields>}, m_file = {<wxStringBase> = {static npos = 4294967295, m_pchData = 0x8d6612c}, <No data fields>}, m_params = {_M_t = {_M_impl = {<std::allocator<std::_Rb_tree_node<std::pair<const wxString, wxString> > >> = {<__gnu_cxx::new_allocator<std::_Rb_tree_node<std::pair<const wxString, wxString> > >> = {<No data fields>}, <No data fields>}, _M_key_compare = {<std::binary_function<wxString, wxString, bool>> = {<No data fields>}, <No data fields>}, _M_header = {_M_color = std::_S_red, _M_parent = 0x8d691e0, _M_left = 0x8d6a300, _M_right = 0x8d69200}, _M_node_count = 3}}}}, sURL = {<wxStringBase> = {static npos = 4294967295, m_pchData = 0x8d66fe4}, <No data fields>}, SessionID = 1681692777, pSocket = 0x8d64a38}) at WebServer.cpp:1859
0000003 0x08072c2c in CWebSocket::OnRequestReceived (this=0x8d64a38,
    pHeader=0x8d64af1 "HTTP/1.1\r\nHost: router:4711\r\nUser-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0b8pre) Gecko/20101009 Firefox/4.0b8pre\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAcce"...,
    pData=0x8d64d07 "Submit=Download+link&ed2klink=ed2k%3A%2F%2F%7Cfile%7C%25E8%25B6%2585%25E4%25BA%25BA%25E5%2589%258D%25E4%25BC%25A0.Smallville.S10E01.Chi_Eng.HDTVrip.720X396-YYeTs%25E4%25BA%25BA%25E4%25BA%25BA%25E5%25B"..., dwDataLen=293) at WebSocket.cpp:224
0000004 0x08072641 in CWebSocket::OnInput (this=0x8d64a38) at WebSocket.cpp:139
0000005 0x0805277c in CWebServerBase::OnWebSocketEvent (this=0x8d4db18, event=@0x8d649a8) at WebServer.cpp:317
0000006 0xb765a56f in wxAppConsole::HandleEvent () from /usr/lib/libwx_baseu-2.8.so.0
0000007 0x08d4db18 in ?? ()
0000008 0x08d649a8 in ?? ()
0000009 0x00002712 in ?? ()
0000010 0xb775a5c4 in wxSocketBase::OnRequest () from /usr/lib/libwx_baseu_net-2.8.so.0
#11 0x00000001 in ?? ()
0000012 0xbfc98f18 in ?? ()
0000013 0xb76ef449 in wxEvtHandler::ProcessEventIfMatches () from /usr/lib/libwx_baseu-2.8.so.0
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb) n

Program received signal SIGPIPE, Broken pipe.
0xb731bcce in write () from /lib/libc.so.6
(gdb) bt
#0 0xb731bcce in write () from /lib/libc.so.6
0000001 0xb72bcedc in _IO_file_write () from /lib/libc.so.6
0000002 0xb72bcb6f in ?? () from /lib/libc.so.6
0000003 0xb72be0be in _IO_do_write () from /lib/libc.so.6
0000004 0xb72bd692 in _IO_file_sync () from /lib/libc.so.6
0000005 0xb73a94c0 in ?? () from /lib/libc.so.6
0000006 0xb7788000 in ?? ()
0000007 0x0000002b in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb)
(0003505)
moo   
2010-10-10 17:33   
something going wrong inside unicode2char i guess, non-ascii character(s) is in i->first or i->second (in typeof wxString) and it's not gonna convert to std::string with current locale

be aware that i'm using openwrt, i'm not sure how to add locale to it or does it have a locale support

the openwrt is built with eglibc 2.12 (and also tested with glibc 2.7)
target-i386_eglibc-2.11
target-i386_glibc-2.7

the ed2k url is always UTF-8 encoded. i strongly suggest amule to use UTF-8 as encoding (before it's urlencoded) between ExternalConnectors (amuleweb / amulecmd) and amuled

the ExternalConnectors should take care of user input encoding if necessary on the client side
and amuled take care of its own filename encoding at the server side

when locale is not supported, fall back to UTF-8 encoding
(0003536)
moo   
2011-02-03 09:58   
i can confirm this was not fixed in SVN-r10422
(0003543)
sturedman   
2011-03-09 15:14   
The m_KeepQuiet logic was surely flawed. Please try if 10486 fixes your problem.

I pasted your link into amuleweb, and it made no problem. The Chinese chars showed up correctly in amule (though not in amuleweb, but that's a different story).

Oh, and please never post real ed2k links here. Make a bogus link that shows the problem instead.