Bug 205256

Summary: Segmentation fault with mount_smbfs
Product: Ports & Packages Reporter: dohzono
Component: Individual Port(s)Assignee: freebsd-bugs (Nobody) <bugs>
Status: Closed Overcome By Events    
Severity: Affects Some People CC: ardovm, vas, w.schwarzenfeld
Priority: ---    
Version: Latest   
Hardware: i386   
OS: Any   

Description dohzono 2015-12-11 23:08:20 UTC
After updating /usr/src, mount_smbfs corrupts.
Here is a log file.  
I have created /etc/src.conf contains "WITH_ICONV=yes", but has no effect.
The command "super" is just a setuided local program I have been using long time.

[dohzono@abacusUSB ~]$ uname -a
FreeBSD abacusUSB 9.3-STABLE FreeBSD 9.3-STABLE #9: Sat Dec 12 06:10:42 JST 2015     dohzono@abacusUSB:/usr/obj/usr/src/sys/GENERIC  i386
[dohzono@abacusUSB ~]$ super mount_smbfs -E UTF-8:cp936 -N //dohzono@orange/share /mnt/orange
Segmentation fault (core dumped)
[dohzono@abacusUSB ~]$ super gdb /usr/sbin/mount_smbfs mount_smbfs.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 "i386-marcel-freebsd"...(no debugging symbols found)...

warning: exec file is newer than core file.
Core was generated by `mount_smbfs'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /usr/lib/libsmb.so.4...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libsmb.so.4
Reading symbols from /lib/libkiconv.so.4...(no debugging symbols found)...done.
Loaded symbols for /lib/libkiconv.so.4
Reading symbols from /lib/libc.so.7...(no debugging symbols found)...done.
Loaded symbols for /lib/libc.so.7
Reading symbols from /usr/local/lib/libiconv.so...(no debugging symbols found)...done.
Loaded symbols for /usr/local/lib/libiconv.so
Reading symbols from /libexec/ld-elf.so.1...(no debugging symbols found)...done.
Loaded symbols for /libexec/ld-elf.so.1
#0  0x00000000 in ?? ()
(gdb) bt
#0  0x00000000 in ?? ()
#1  0x2807572b in nls_setrecode () from /usr/lib/libsmb.so.4
#2  0xbfbfe854 in ?? ()
#3  0xbfbfede5 in ?? ()
#4  0x28077814 in ?? () from /usr/lib/libsmb.so.4
#5  0xbfbfeddf in ?? ()
#6  0xbfbfe864 in ?? ()
#7  0xbfbfe678 in ?? ()
#8  0x28070b6d in smb_ctx_setcharset () from /usr/lib/libsmb.so.4
#9  0x00000036 in ?? ()
#10 0x00000000 in ?? ()
(gdb)
Comment 1 dohzono 2015-12-11 23:45:38 UTC
Do these symbols exist?

/usr/src/contrib/smbfs/lib/smb/nls.c
                iconv_lib = dlopen("libiconv.so", RTLD_LAZY | RTLD_GLOBAL);
                if (iconv_lib == NULL) {
                        warn("Unable to load iconv library: %s\n", dlerror());
                        iconv_loaded++;
                        return ENOENT;
                }
                my_iconv_open = dlsym(iconv_lib, "iconv_open");
                my_iconv = dlsym(iconv_lib, "iconv");
                my_iconv_close = dlsym(iconv_lib, "iconv_close");
Comment 2 dohzono 2015-12-12 00:10:56 UTC
Solved.

I found that nls.c referes to /usr/local/lib/libiconv.so, so
I deintall/reinstalled /usr/ports/converters/libiconv, and
this problem has gone.
Comment 3 dohzono 2015-12-13 10:26:23 UTC
Reproduced.

mount_smbfs -E UTF-8:cp936 -N //dohzono@orange/share /mnt/orange

with libiconv-1.14_8 => works ok.
with libiconv-1.14_9 => core dumped.
Comment 4 Victor Sudakov 2016-01-26 04:02:54 UTC
I have reproduced on 9.3-RELEASE-p33 and libiconv-1.14_9.

# mount_smbfs -E koi8-r:cp866 -W sibptus //scanserver@FS03-SIBPTUS/PUB /mnt2
Segmentation fault (core dumped)


Need a fix ASAP.
Comment 5 Victor Sudakov 2016-01-26 05:01:13 UTC
I had to force-install libiconv-1.14_8.txz (which I had obtained from a tape dump) and this worked around the problem.
Comment 6 Victor Sudakov 2016-01-27 02:53:50 UTC
Why is libkiconv from the base system affected in any way by /usr/local/lib/libiconv from ports? Shouldn't we reclassify this bug into a more serious category?
Comment 7 dohzono 2016-01-28 12:54:11 UTC
This may be a fix for 10/stable of this issue.
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=183153
Comment 8 Victor Sudakov 2016-01-31 02:35:28 UTC
Please see also https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=206740 for a fix.
Comment 9 Arrigo Marchiori 2016-03-23 10:12:18 UTC
IMHO vas is right; this bug is a particular case of bug #206740.

It was triggered by ports r398996, that renamed all 'iconvxxx' symbols back into 'libiconvxxx'.
Comment 10 Walter Schwarzenfeld 2018-01-13 20:48:51 UTC
9.3 is EOL. So i think this is overcome by events.
Comment 11 Arrigo Marchiori 2018-01-14 09:34:13 UTC
(In reply to w.schwarzenfeld from comment #10)
> 9.3 is EOL. So i think this is overcome by events.
I think so. And also bug #206740 should be marked as such.