Bug 912530

Summary: Midnight Commander slow to start
Product: [Fedora] Fedora Reporter: Piscium <groknok>
Component: mcAssignee: Radek Vokál <rvokal>
Status: CLOSED EOL QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 20CC: cristian.ciupitu, dgunchev, dvlasenk, groknok, mrmazda, next.little.owl, pahan, rvokal, slavazanko, van.zantvoort
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-06-29 11:46:23 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Piscium 2013-02-18 22:17:50 UTC
Description of problem:
Midnight Commander is taking 30 seconds to start on my new PC running F18. 


Version-Release number of selected component (if applicable):
4.8.7

How reproducible:
Always (on my PC).

Steps to Reproduce:
1. Start mc from a terminal, either as root or normal user.
2. 
3.
  
Actual results:
It takes 30 seconds for Midnight Commander panes to appear. 

Expected results:
Should take 0.1 second!

Additional info:
I installed some debuginfos and called mc with gdb. I stopped it running with Ctrl-C after a couple of seconds, and got the call trace below. I did this twice and got seemingly the same trace (I have not checked all the details). The goal of the exercise was to find where mc was hanging. Unfortunately I do not have the time to go through the whole trace trying to find the actual cause of the problem, but it is probably obvious for someone that know the code base.

The trace shows that the host name is "tornado". That is correct, I set it myself to that by modifying /etc/hostname. The trace also shows that the domain name is "home". I have no idea where that came from. I don't remember setting it, and if I run the domainname command I get (none).

====================
GNU gdb (GDB) Fedora (7.5.1-32.fc18)
Copyright (C) 2012 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 "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/bin/mc...Reading symbols from /usr/lib/debug/usr/bin/mc.debug...done.
done.
(gdb) run
Starting program: /usr/bin/mc 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
^C
Program received signal SIGINT, Interrupt.
0x00000033682e9970 in __poll_nocancel () at ../sysdeps/unix/syscall-template.S:81
81	T_PSEUDO (SYSCALL_SYMBOL, SYSCALL_NAME, SYSCALL_NARGS)
(gdb) bt
#0  0x00000033682e9970 in __poll_nocancel () at ../sysdeps/unix/syscall-template.S:81
#1  0x000000336a60ac05 in send_dg (resplen2=0x0, anssizp2=0x0, ansp2=0x0, anscp=0x7fffffffd5c0, 
    gotsomewhere=<synthetic pointer>, v_circuit=<synthetic pointer>, ns=0, terrno=0x7fffffffc540, anssizp=
    0x7fffffffc690, ansp=0x7fffffffc538, buflen2=0, buf2=0x0, buflen=30, buf=0x7fffffffc6c0 "\362\242\001", statp=
    0x33685b5b00 <_res.5>) at res_send.c:1059
#2  __libc_res_nsend (statp=statp@entry=0x33685b5b00 <_res.5>, buf=buf@entry=0x7fffffffc6c0 "\362\242\001", 
    buflen=30, buf2=buf2@entry=0x0, buflen2=0, ans=ans@entry=0x7fffffffd190  <incomplete sequence \362\242\201>, 
    anssiz=anssiz@entry=1024, ansp=ansp@entry=0x7fffffffd5c0, ansp2=ansp2@entry=0x0, nansp2=nansp2@entry=0x0, 
    resplen2=resplen2@entry=0x0) at res_send.c:556
#3  0x000000336a608be0 in __GI___libc_res_nquery (statp=statp@entry=0x33685b5b00 <_res.5>, name=name@entry=
    0x7fffffffcd10 "tornado.home", class=class@entry=1, type=type@entry=1, answer=answer@entry=
    0x7fffffffd190  <incomplete sequence \362\242\201>, anslen=anslen@entry=1024, answerp=answerp@entry=
    0x7fffffffd5c0, answerp2=answerp2@entry=0x0, nanswerp2=nanswerp2@entry=0x0, resplen2=resplen2@entry=0x0)
    at res_query.c:226
#4  0x000000336a609600 in __libc_res_nquerydomain (resplen2=0x0, nanswerp2=0x0, answerp2=0x0, answerp=0x7fffffffd5c0, 
    anslen=1024, answer=0x7fffffffd190  <incomplete sequence \362\242\201>, type=1, class=1, domain=
    0x33685b5b80 <_res.5+128> "home", name=0x92c770 "tornado", statp=0x33685b5b00 <_res.5>)
    at res_query.c:582
#5  __GI___libc_res_nsearch (statp=0x33685b5b00 <_res.5>, name=name@entry=0x92c770 "tornado", 
    class=class@entry=1, type=type@entry=1, answer=answer@entry=0x7fffffffd190  <incomplete sequence \362\242\201>, 
    anslen=anslen@entry=1024, answerp=0x7fffffffd5c0, answerp2=answerp2@entry=0x0, nanswerp2=nanswerp2@entry=0x0, 
    resplen2=resplen2@entry=0x0) at res_query.c:416
#6  0x00007ffff179d692 in __GI__nss_dns_gethostbyname3_r (name=name@entry=0x92c770 "tornado", af=af@entry=2, 
    result=result@entry=0x33685b5ea0 <resbuf.13232>, buffer=buffer@entry=0x92d220 "\177", buflen=buflen@entry=1024, 
    errnop=errnop@entry=0x7ffff7fc8780, h_errnop=h_errnop@entry=0x7fffffffdb50, ttlp=ttlp@entry=0x0, 
    canonp=canonp@entry=0x0) at nss_dns/dns-host.c:192
#7  0x00007ffff179d964 in _nss_dns_gethostbyname_r (name=0x92c770 "tornado", result=0x33685b5ea0 <resbuf.13232>, 
    buffer=0x92d220 "\177", buflen=1024, errnop=0x7ffff7fc8780, h_errnop=0x7fffffffdb50) at nss_dns/dns-host.c:268
#8  0x000000336830bab5 in __gethostbyname_r (name=name@entry=0x92c770 "tornado", resbuf=resbuf@entry=
    0x33685b5ea0 <resbuf.13232>, buffer=0x92d220 "\177", buflen=1024, result=result@entry=0x7fffffffdb60, 
    h_errnop=h_errnop@entry=0x7fffffffdb50) at ../nss/getXXbyYY_r.c:255
#9  0x000000336830b2dd in gethostbyname (name=name@entry=0x92c770 "tornado") at ../nss/getXXbyYY.c:116
#10 0x00000000004b5695 in sys_gethostbyname (name=name@entry=0x92c770 "tornado") at lib/system.c:303
#11 0x00000000004b3c75 in Get_Hostbyname (name=<optimized out>) at lib/util.c:2479
#12 0x00000000004b4009 in get_myname (my_name=0x73fe60 <myhostname> "", ip=ip@entry=0x0) at lib/util.c:1845
#13 0x000000000046b20f in smbfs_init (me=0x738040) at smbfs.c:389
#14 0x000000000046060f in vfs_register_class (vfs=vfs@entry=0x738040) at vfs.c:297
#15 0x000000000046e640 in init_smbfs () at smbfs.c:2263
#16 0x0000000000468828 in vfs_plugins_init () at plugins_init.c:126
#17 0x000000000040fee0 in main (argc=1, argv=0x7fffffffe1c8) at main.c:296

Comment 1 Felix Miata 2013-03-05 06:02:34 UTC
With my 64 bit 3.0GHz family 15 model 4 stepping 3 F18/KDE host gx62b, MC starts instantly whether on the ttys or in Konsole.

Comment 2 Piscium 2013-03-07 22:14:04 UTC
I understand now better what happened. It started with Anaconda for F18. As I could not find a way to set the host name, I changed it after installation by modifying the file /etc/hostname. This is what made MC start slower.

The way to fix the problem is then to revert /etc/hostname to its default value (“localhost”), however I do not like that. I found another solution, adding the new host name to /etc/hosts. I tested two ways that both work: adding the new host name as an alias for localhost, or alternatively adding a new line in the file with a different address (such as 127.0.1.1).

The question is then: is this a MC bug or not? I don't know. I also noticed that when MC is slow to start, the command dnsdomainname also is slow. Maybe there is a common cause, and it might be the function gethostbyname in glibc (or a function called by it, or systemd).

In a nutshell, I solved my immediate problem (MC not working) but there may be a bug, and I don't know enough to say there is (or isn't). Hopefully someone more knowledgeable will be able to shed some light on this. I don't mind if this issue is closed.

Comment 3 Slava Zanko 2013-03-25 18:48:31 UTC
> #9  0x000000336830b2dd in gethostbyname (name=name@entry=0x92c770 "tornado") at ../nss/getXXbyYY.c:116

Check your /etc/hosts file or DNS settings. Your computer should know how to resolve own hostname to IP address and vise versa. Also, please check resolving for 'localhost.locakdomain' hostname.

Comment 4 Piscium 2013-03-25 22:15:29 UTC
This is my current /etc/hosts:
=============
127.0.0.1	localhost.localdomain	localhost
::1		localhost.localdomain	localhost6	localhost
127.0.1.1	tornado
=============

The first two lines are the default on my Fedora 18 box (except that I added some extra whitespace). I manually added the third line and that solved the problem (however as I said in my previous comment, adding "tornado" to the first line is an alternative way to solve the problem).

The question now is this: is there a bug or not? if yes where? in MC? in some other tool?

If you do "man hostnamectl" you will see that it does not mention /etc/hosts. Is there a bug in hostnamectl?

See also Bug 856456 and Bug 890027.

Comment 5 Slava Zanko 2013-03-27 08:26:48 UTC
> The question now is this: is there a bug or not?
It's a good question. Same behavior will be for Sendmail, for example.

> if yes where? in MC?

Yes, in MC. In Smbfs module, if more exactly. The module is deprecated (because have a lot of code from very old Samba implementation). The module will be rewritten for usage of the libsmbclient library in near time (hope, month or two). But I don't sure that new module will not add a delay when host will have issues with the DNS names lookup (it will be tested of course, but not now).

> Is there a bug in hostnamectl?

Generally it's a bug with the DNS names lookup. The bug may be in your /etc/hosts, in the dnsmasq package, in /etc/nssswitch.conf or in /etc/resolv.conf files. It happens when computer haven't had ability to transform own hostname to an IP address and/or vise versa.

Comment 7 Doncho Gunchev 2013-11-14 13:47:46 UTC
He-he, I remember this behaviour from the previous century, so it's a century old bug :D

No, seriously, I use that 'bug' to check if I missed to edit /etc/hosts after changing the host name. You'll notice similar problems in other programs too, but mc is my litmus paper for that.

Comment 8 Fedora End Of Life 2013-12-21 11:31:08 UTC
This message is a reminder that Fedora 18 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 18. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '18'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 18's end of life.

Thank you for reporting this issue and we are sorry that we may not be 
able to fix it before Fedora 18 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior to Fedora 18's end of life.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 9 Cristian Ciupitu 2014-01-07 18:14:10 UTC
I seem to have the same problem with mc-4.8.11-1.fc20.x86_64. It took
forever to start when the DNS servers weren't responding (the host host
command returned ";; connection timed out; no servers could be
reached").

Comment 10 Fedora End Of Life 2014-02-05 19:17:30 UTC
Fedora 18 changed to end-of-life (EOL) status on 2014-01-14. Fedora 18 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.

Comment 11 Václav Mocek 2014-05-26 18:34:09 UTC
The reason is the way how the virtual smbfs is initialised.

The call chain is:

main() 			[src/main.c]
vfs_plugins_init()	[src/vfs/plugins_init.c]
init_smbfs()		[src/vfs/smbfs/smbfs.c]
vfs_register_class()	[lib/vfs/vfs.c]
smbfs_init()		[src/vfs/smbfs/smbfs.c]
get_myname()		[src/vfs/smbfs/helpers/lib/util.c]
Get_Hostbyname()	[src/vfs/smbfs/helpers/lib/util.c]
sys_gethostbyname()	[src/vfs/smbfs/helpers/lib/system.c]
...
...
<the main loop of mc>


The problem starts in get_myname() and continues to sys_gethostbyname(). The code can generate several unsuccessful calls of gethostbyname() with timeouts and it can block the initialization of the main loop for very long time.

This is a fundamental design issue, no slow network related operations, like a DNS lookup, should be allowed to block the main execution loop and UI.

Given the current state of code of the virtual smbfs, which is fortunately deprecated, I suggest to build mc without support for smbfs, at least until it is possible to disable this functionality in Options->Virtual FS menu. It means to remove "--enable-vfs-smb" from the SPEC file.

Comment 13 Felix Miata 2015-03-05 04:17:59 UTC
http://www.midnight-commander.org/ticket/40 appears to be the upstream bug covering this.

Comment 14 Fedora End Of Life 2015-05-29 08:53:54 UTC
This message is a reminder that Fedora 20 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 20. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '20'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 20 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 15 Fedora End Of Life 2015-06-29 11:46:23 UTC
Fedora 20 changed to end-of-life (EOL) status on 2015-06-23. Fedora 20 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.