# Segmentation fault (core dumped) mc-light



## hirohitosan (Dec 16, 2009)

Hi to all!
For few days I have the same problem and I cannot fix it.
when I try to run mc-light I got:
	
	



```
> mc
Segmentation fault (core dumped)
```
I update my ports and 
	
	



```
portupgrade -rf mc-light
```
but still the same problem.
I don't have this problem when I'm logged as rot, just when I'm in my account

any suggestions?

thanks


----------



## DutchDaemon (Dec 16, 2009)

Do you have a .mc (or something) directory with specific settings for mc? Try (re)moving it.


----------



## hirohitosan (Dec 16, 2009)

I have an empty folder .mc 

```
drwxr-xr-x   2 user  user      512 Dec 16 14:35 .mc
-rw-------   1 user  user  1961984 Dec 16 14:40 mc.core
```
I deleted both, log again un again mc and same message

and the .mc folder mc.core file apear again.


----------



## DutchDaemon (Dec 16, 2009)

Well, other than analysing the .core file or running [cmd=]truss mc[/cmd] to see which system call fails, I have no real idea.


----------



## Beastie (Dec 16, 2009)

If root's /root/.mc directory contains conf files (such as *ini*), copy them to /home/your_user/.mc and retry.


----------



## hirohitosan (Dec 16, 2009)

I copied everything 
	
	



```
ls -al /root/.mc/
total 14
drwxr-xr-x   3 root  wheel   512 Dec 16 15:34 .
drwxr-xr-x  10 root  wheel   512 Dec 16 14:03 ..
drwx------   2 root  wheel   512 Nov 28 09:44 cedit
-rw-r--r--   1 root  wheel   172 Dec 16 15:34 edit.pos
-rw-r--r--   1 root  wheel  1531 Dec 16 15:35 history

-rw-------   1 root  wheel     0 Nov 28 09:44 hotlist
-rw-r--r--   1 root  wheel  3693 Dec 16 15:35 ini
```
and in my account I have

```
ls -al .mc/
total 12
drwxr-xr-x   2 user  user   512 Dec 16 15:58 .
drwxr-xr-x  21 user  user  1024 Dec 16 16:02 ..
-rw-r--r--   1 user  user   172 Dec 16 15:34 edit.pos
-rw-r--r--   1 user  user  1531 Dec 16 15:35 history
-rw-r--r--   1 user  user  3693 Dec 16 15:35 ini
```

I log out/login and again same message
*Segmentation fault (core dumped)*
On this computer I have KDE running ... this is the only thing that differ from other computers where I use mc-light.
And I remember that I didn't have this problem before installing KDE. Is something related to KDE?


----------



## Beastie (Dec 16, 2009)

Try running it from an xterm, then directly from a tty (with X not running).


----------



## tangram (Dec 16, 2009)

Which shell are you using with root and normal user? If they aren't the same try changing the user's shell to match root's.


----------



## DutchDaemon (Dec 16, 2009)

And, again, [cmd=]truss mc[/cmd]. See where it segfaults.


----------



## hirohitosan (Dec 16, 2009)

@ Beastie: I tried and same message. Even from ssh get same message

@ tangram: I use tchs for both (root and my account)

@ DutchDaemon: I attached the truss mc output. I cannot figure out the message


----------



## jb_fvwm2 (Dec 16, 2009)

One thing to try.
Change to the port subdirectory.

```
/bin/rm -rf work
```
After it builds, find where the actual
binary is located.  Run it instead of
the /usr/local/bin one.
If the new one does not segfault, simply
copy it to /usr/local/bin... it might 
not segfault.


----------



## DutchDaemon (Dec 16, 2009)

Hmm, these are interesting:


```
ioctl(3,TIOCGETA,0xffffe250)			 ERR#25 'Inappropriate ioctl for device'
[..]
ioctl(1,CONS_GETINFO,0x5a4460)			 ERR#25 'Inappropriate ioctl for device'
[..]
ioctl(1,TIOCGETA,0xffffe0d0)			 = 0 (0x0)
ioctl(1,TIOCGETA,0xc3b138)			 = 0 (0x0)
ioctl(1,TIOCGETA,0xffffe080)			 = 0 (0x0)
ioctl(1,TIOCGWINSZ,0xffffe0d0)			 = 0 (0x0)
ioctl(1,TIOCGWINSZ,0xffffe590)			 = 0 (0x0)
ioctl(0,TIOCGETA,0x5a4ee0)			 = 0 (0x0)
sigprocmask(SIG_BLOCK,SIGINT|SIGQUIT|SIGTSTP|SIGTTIN|SIGTTOU,0x0) = 0 (0x0)
ioctl(0,TIOCGETA,0xffffe540)			 = 0 (0x0)
ioctl(0,TIOCGETA,0x5a9ba0)			 = 0 (0x0)
ioctl(0,TIOCGETA,0xffffe590)			 = 0 (0x0)
ioctl(0,TIOCSETAW,0xffffe590)			 = 0 (0x0)
                                                          sigprocmask(SIG_SETMASK,0x0,0x0)		 = 0 (0x0)
                                  ioctl(0,TIOCGETA,0x5a4f20)			 = 0 (0x0)
         SIGNAL 22 (SIGTTOU)
```

To me, this looks like a console/terminal/shell problem. As suggested, could you use the same shell as root does (just type [cmd=]csh[/cmd] (which is normally the root shell) in your current session and run mc from that shell)?


----------



## tangram (Dec 16, 2009)

Or it could be a problem with the environment variables that differ from root to user.

Oh and try to check both root and user's .cshrc.


----------



## hirohitosan (Dec 17, 2009)

@ jb_fvwm2: My 
	
	



```
# cd /usr/ports/misc/mc-light/
# ls -al
total 26
drwxr-xr-x    3 root  wheel    512 Dec 16 13:20 .
drwxr-xr-x  561 root  wheel  11776 Dec 16 12:38 ..
-rw-r--r--    1 root  wheel   1451 Jun  6  2008 Makefile
-rw-r--r--    1 root  wheel    200 Jan 22  2006 distinfo
drwxr-xr-x    2 root  wheel    512 Nov 27 17:16 files
-rw-r--r--    1 root  wheel    254 Sep  2  2004 pkg-descr
-rw-r--r--    1 root  wheel   3421 Sep  3  2004 pkg-plist
```
I installed using make install clean
I search for mc using locate mc

```
# locate mc
/usr/local/bin/mc

/usr/local/kde4/share/locale/l10n/mc
/usr/local/kde4/share/locale/l10n/mc/entry.desktop
/usr/local/kde4/share/locale/l10n/mc/flag.png

/usr/local/share/mc

/var/db/pkg/mc-light-4.1.40.p9_7
/var/db/pkg/mc-light-4.1.40.p9_7/+COMMENT
/var/db/pkg/mc-light-4.1.40.p9_7/+CONTENTS
/var/db/pkg/mc-light-4.1.40.p9_7/+DESC
/var/db/pkg/mc-light-4.1.40.p9_7/+MTREE_DIRS
/var/db/ports/mc-light
/var/db/ports/mc-light/options

cd /usr/local/share/mc/bin/
> ls
mcfn_install
> cd ..
> ls -al
total 200
drwxr-xr-x    8 root  wheel     512 Dec 16 13:20 .
drwxr-xr-x  146 root  wheel    3072 Dec 16 12:43 ..
-r--r--r--    1 root  wheel   36385 Dec 16 13:20 FAQ
drwxr-xr-x    2 root  wheel     512 Dec 16 13:20 bin
drwxr-xr-x    2 root  wheel    1024 Dec 16 13:20 codepages
drwxr-xr-x    2 root  wheel     512 Dec 16 13:20 extfs
-r--r--r--    1 root  wheel   16207 Dec 16 13:20 mc.ext
-r--r--r--    1 root  wheel    3400 Dec 16 13:20 mc.hint
-rw-r--r--    1 root  wheel  117768 Dec 16 13:20 mc.hlp
-r--r--r--    1 root  wheel    1570 Dec 16 13:20 mc.lib
-r--r--r--    1 root  wheel    7596 Dec 16 13:20 mc.menu
drwxr-xr-x    2 root  wheel    1536 Dec 16 13:20 syntax
drwxr-xr-x    2 root  wheel     512 Nov 27 18:29 templates
drwxr-xr-x    2 root  wheel     512 Dec 16 13:20 term
```

I didn't see any executable than /usr/local/bin/mc

@ DutchDaemon:
I did:

```
> csh
% mc
Segmentation fault (core dumped)
                                %
```
same message

@ tangram:
for user:

```
> cat .cshrc 
# $FreeBSD: src/share/skel/dot.cshrc,v 1.14.10.1.2.1 2009/10/25 01:10:29 kensmith Exp $
#
# .cshrc - csh resource script, read at beginning of execution by each shell
#
# see also csh(1), environ(7).
#

alias h		history 25
alias j		jobs -l
alias la	ls -a
alias lf	ls -FA
alias ll	ls -lA

# A righteous umask
umask 22

set path = (/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin $HOME/bin)

setenv	EDITOR	vi
setenv	PAGER	more
setenv	BLOCKSIZE	K
setenv  http_proxy http://my.proxy.server:3128
setenv  ftp_proxy  http://my.proxy.server:3128

if ($?prompt) then
	# An interactive shell -- set some stuff up
	set filec
	set history = 100
	set savehist = 100
	set mail = (/var/mail/$USER)
	if ( $?tcsh ) then
		bindkey "^W" backward-delete-word
		bindkey -k up history-search-backward
		bindkey -k down history-search-forward
	endif
endif
```
for root:
	
	



```
> cat .cshrc
# $FreeBSD: src/etc/root/dot.cshrc,v 1.30.10.1.2.1 2009/10/25 01:10:29 kensmith Exp $
#
# .cshrc - csh resource script, read at beginning of execution by each shell
#
# see also csh(1), environ(7).
#

alias h		history 25
alias j		jobs -l
alias la	ls -a
alias lf	ls -FA
alias ll	ls -lA

# A righteous umask
umask 22

set path = (/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin $HOME/bin)

setenv	EDITOR	vi
setenv	PAGER	more
setenv	BLOCKSIZE	K
setenv  http_proxy http://my.proxy.server:3128
setenv  ftp_proxy  http://my.proxy.server:3128

if ($?prompt) then
	# An interactive shell -- set some stuff up
	set prompt = "`/bin/hostname -s`# "
	set filec
	set history = 100
	set savehist = 100
	set mail = (/var/mail/$USER)
	if ( $?tcsh ) then
		bindkey "^W" backward-delete-word
		bindkey -k up history-search-backward
		bindkey -k down history-search-forward
	endif
endif
```


----------



## achix (Dec 17, 2009)

hirohitosan

to find the exact name of your mc installed package do
`pkg_info | grep -i mc`
to find all files installed (owned) by this package do
`pkg_info -L <name of your mc package: e.g. mc-1.2.3,4_5>`
to find the package (if any) which owns a file do
`pkg_info -W <path to file>`

Now, as jb_fvwm2 said, try to rebuild mc with debugging support (-g).
Then you might do `gdb <path to mc executable> <path to mc.core>`
and then type 
`where`
to see exactly where it segfaults.

It would be very interesting to try to run it *NOT* under KDE, but under
lets say twm or mwm, and see if it segfaults.


----------



## hirohitosan (Dec 17, 2009)

achix said:
			
		

> try to rebuild mc with debugging support (-g).


I don't know how to build with debugging support, but I did like this:

```
# cd /usr/ports/misc/mc-light/
# make deinstall
# make clean
# make install
> gdb /usr/local/bin/mc mc.core
GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "amd64-marcel-freebsd"...(no debugging symbols found)...
Core was generated by `mc'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /lib/libcrypt.so.5...(no debugging symbols found)...done.
Loaded symbols for /lib/libcrypt.so.5
Reading symbols from /lib/libncurses.so.8...(no debugging symbols found)...done.
Loaded symbols for /lib/libncurses.so.8
Reading symbols from /lib/libc.so.7...(no debugging symbols found)...done.
Loaded symbols for /lib/libc.so.7
Reading symbols from /libexec/ld-elf.so.1...(no debugging symbols found)...done.
Loaded symbols for /libexec/ld-elf.so.1
#0  0x0000000800a2531b in strlen () from /lib/libc.so.7
```


----------



## crsd (Dec 17, 2009)

```
make -D WITH_DEBUG -C /usr/ports/misc/mc-light deinstall clean install clean
```

You might also need to rebuild libc with debug symbols:

```
cd /usr/src/lib/libc && make cleandir obj && make DEBUG_FLAGS=-g && make install
```


----------



## achix (Dec 17, 2009)

hirohitosan, also you must see (and show us) the output of gdb "where" command.


----------



## jb_fvwm2 (Dec 18, 2009)

What I was suggesting is "make build" after
removing 'work' in the port subdirectory. 
There will then be a *new* mc in the port 
folder somewhere.  That one may not segfault
and you might not have to debug the old one
if you simply copy the new one 

```
cd /usr/ports/misc/mc/work/mc-something/src
. ./mc 
# if that does not segfault
# the path might be different
cp -iv /usr/ports/misc/mc/work/mc-[something]/src/mc 
/usr/local/bin/mc
```


----------



## crsd (Dec 18, 2009)

Why it wouldn't segfault? Compile it into submission, eh?


----------



## hirohitosan (Dec 18, 2009)

here's what I did:

```
make -D WITH_DEBUG -C /usr/ports/misc/mc-light deinstall clean install clean

cd /usr/src/lib/libc && make cleandir obj && make DEBUG_FLAGS=-g && make install

> mc
Segmentation fault (core dumped)
                                > gdb /usr/local/bin/mc mc.core
Core was generated by `mc'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /lib/libcrypt.so.5...done.
Loaded symbols for /lib/libcrypt.so.5
Reading symbols from /lib/libncurses.so.8...done.
Loaded symbols for /lib/libncurses.so.8
Reading symbols from /lib/libc.so.7...done.
Loaded symbols for /lib/libc.so.7
Reading symbols from /libexec/ld-elf.so.1...done.
Loaded symbols for /libexec/ld-elf.so.1
#0  0x0000000800a5042b in strlen () from /lib/libc.so.7
(gdb) where
#0  0x0000000800a5042b in strlen () from /lib/libc.so.7
#1  0x00000000004089b3 in copy_strings (first=0x4aafce "/tmp") at util.c:798
#2  0x000000000043e1fa in init_subshell () at subshell.c:313
#3  0x0000000000462c4a in main (argc=1, argv=0x7fffffffe688) at main.c:3432
(gdb)
```
any hints?

thanks


----------



## crsd (Dec 18, 2009)

Could you please show [CMD=""]bt full[/CMD]


----------



## hirohitosan (Dec 18, 2009)

```
(gdb) bt full
#0  0x0000000800a5042b in strlen () from /lib/libc.so.7
No symbol table info available.
#1  0x00000000004089b3 in copy_strings (first=0x4aafce "/tmp") at util.c:798
        ap = {{gp_offset = 24, fp_offset = 48,
    overflow_arg_area = 0x7fffffffe560, reg_save_area = 0x7fffffffe4a0}}
        len = 13
        data = 0x585c <Address 0x585c out of bounds>
        result = 0x0
#2  0x000000000043e1fa in init_subshell () at subshell.c:313
        tmpdir = 0x4aafce "/tmp"
        pty_slave = 4
        tcsh_fifo = 0x0
        pty_name = "/dev/ttyp0", '\0' <repeats 29 times>
#3  0x0000000000462c4a in main (argc=1, argv=0x7fffffffe688) at main.c:3432
No locals.
```


----------



## crsd (Dec 18, 2009)

Guessing on trace, you are running tcsh and mc-light was built with SUBSHELL option defined. Care to read the comment for that option?


----------



## achix (Dec 18, 2009)

crsd said:
			
		

> Guessing on trace, you are running tcsh and mc-light was built with SUBSHELL option defined. Care to read the comment for that option?



You are very right!

Just tried with SUBSHELL and it coredumped for me as well, either in bash, sh or tcsh.
However reconfiguring without this option, by
`portinstall -C /usr/ports/misc/mc-light`
did the trick.
IMO, the SUBSHELL issue is a bug and should be reported to the port maintainer az@FreeBSD.org

I think in similar issues it would be good people to report the respective options file in 
/var/db/ports/ in order to know the exact compilation configuration options.
In this case that might be /var/db/ports/mc-light/options


----------



## hirohitosan (Dec 18, 2009)

sorry ... sound a little cryptic for me, but I installed mc-light on other 3  computers (one with X and 2 servers) and it's works with no issues (all computers has tcsh). Just on this com. i have this problem and only in my account! that's really odd.

In this case, how I can fix this?


----------



## achix (Dec 18, 2009)

You have two options:

a) recompile mc-light without SUBSHELL option (as i told you)
or
b) simply the shell change your account to use bash. To do that just give:

```
% chsh
... then an editor with smth like:
#Changing user information for foo.
Shell: /bin/tcsh
Full Name: User &
Office Location:
Office Phone:
Home Phone:
Other information:
... will appear. Replace /bin/tcsh to /usr/local/bin/bash,
save, exit, logout, login again, and tell us what you got.
```


----------



## hirohitosan (Dec 18, 2009)

well thanks guys!
I installed bash, change tcsh to bash and works fine


----------

