Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 104122 - Memory problems when running in sandbox
Summary: Memory problems when running in sandbox
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Sandbox (show other bugs)
Hardware: All Linux
: High minor
Assignee: Sandbox Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-29 04:55 UTC by Patrick Kursawe (RETIRED)
Modified: 2005-08-30 05:44 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick Kursawe (RETIRED) gentoo-dev 2005-08-29 04:55:13 UTC
When I try to build freehdl-20050510 I get a:
../v2cc/freehdl-v2cc -lieee -L .. std_logic_arith.vhdl >std_logic_arith.cc.tmp
&& mv std_logic_arith.cc.tmp std_logic_arith.cc
../v2cc/freehdl-v2cc -lieee -L .. math_real.vhdl >math_real.cc.tmp && mv
math_real.cc.tmp math_real.cc
*** glibc detected *** corrupted double-linked list: 0x083c5718 ***
/bin/sh: line 1:  6879 Aborted                 ../v2cc/freehdl-v2cc -lieee -L ..
std_logic_arith.vhdl >std_logic_arith.cc.tmp
make[1]: *** [std_logic_arith.cc] Error 134

when sandbox is in FEATURES. When I disable sandbox, everything is fine.

Portage 2.0.51.22-r2 (default-linux/x86/2005.0, gcc-3.4.4, glibc-2.3.5-r1,
2.6.11.12 i686)
=================================================================
System uname: 2.6.11.12 i686 AMD Athlon(tm) Processor
Gentoo Base System version 1.4.16
distcc 2.16 i686-pc-linux-gnu (protocols 1 and 2) (default port 3632) [disabled]
ccache version 2.3 [enabled]
dev-lang/python:     2.2.3-r6, 2.3.5
sys-apps/sandbox:    1.2.12
sys-devel/autoconf:  2.13, 2.59-r6
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.5
sys-devel/binutils:  2.15.92.0.2-r10
sys-devel/libtool:   1.5.18-r1
virtual/os-headers:  2.6.11-r2
ACCEPT_KEYWORDS="x86"
AUTOCLEAN="yes"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-march=athlon-xp -O2 -pipe"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/2/share/config /usr/kde/3.3/env
/usr/kde/3.3/share/config /usr/kde/3.3/shutdown /usr/kde/3/share/config
/usr/lib/X11/xkb /usr/lib/mozilla/defaults/pref /usr/share/config
/usr/share/texmf/dvipdfm/config/ /usr/share/texmf/dvips/config/
/usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/
/usr/share/texmf/xdvi/ /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/gconf /etc/snort /etc/terminfo /etc/env.d"
CXXFLAGS="-march=athlon-xp -O2 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoconfig ccache cvs distlocks maketest sandbox sfperms strict test"
GENTOO_MIRRORS="http://linux.rz.ruhr-uni-bochum.de/download/gentoo-mirror
http://ftp.uni-erlangen.de/pub/mirrors/gentoo"
LDFLAGS="-Wl,-O2"
LINGUAS="de pl"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/gentoo-x86"
SYNC="rsync://linux.rz.ruhr-uni-bochum.de/gentoo-portage"
USE="x86 3dnow X Xaw3d adns alsa apm arts avi berkdb bitmap-fonts bonobo bzip2
bzlib caps cdf cdr cln crypt cscope cups curl dga djbfft doc eds emboss encode
esd fam fftw flac flash foomaticdb fortran gd gdbm gif gimp gimpprint ginac gmp
gphoto2 gsl gstreamer gtk gtk2 guile hdf hdf5 imagemagick imap imlib ipv6 java
jce jpeg junit kde libg++ libwww lirc mad maildir mikmod mmx mng motif mozilla
mp3 mpeg mysql ncurses netcdf nls nptl nptlonly oci8 ogg oggvorbis opengl oss
pam pcre pdflib perl pic plotutils png ppds python qt quicktime readline samba
scanner sdk sdl slang spell sse ssl svg szip tcltk tcpd tetex tiff truetype
truetype-fonts type1-fonts unicode usb v4l v4l2 vorbis wmf xine xml xml2 xmms xv
zlib video_cards_matrox linguas_de linguas_pl userland_GNU kernel_linux elibc_glibc"
Unset:  ASFLAGS, CTARGET, LANG, LC_ALL
Comment 1 Martin Schlemmer (RETIRED) gentoo-dev 2005-08-29 05:31:24 UTC
Just cp the freehdl-20040113 ebuild over to freehdl-20050510 ?
Comment 2 Martin Schlemmer (RETIRED) gentoo-dev 2005-08-29 05:32:34 UTC
NM, aparently my cvs update of an hour ago was not recent enough.
Comment 3 Martin Schlemmer (RETIRED) gentoo-dev 2005-08-29 06:53:54 UTC
Got a nice backtrace here (PS: freehdl is one big POS in regards to casting
pointers to int's if it ever needs to be ported to 64bit):

-----
../v2cc/freehdl-v2cc -lieee -L .. std_logic_arith.vhdl >std_logic_arith.cc.tmp
&& mv std_logic_arith.cc.tmp std_logic_arith.cc
*** glibc detected ***
/var/tmp/portage/freehdl-20050510/work/freehdl-20050510/v2cc/.libs/lt-freehdl-v2cc:
corrupted double-linked list: 0x0000003000f2c158 ***
======= Backtrace: =========
/lib/libc.so.6[0x3000d6c893]
/lib/libc.so.6[0x3000d6c9fb]
/lib/libc.so.6[0x3000d6d067]
/lib/libc.so.6(__libc_free+0x6c)[0x3000d6d39c]
/usr/lib/libsandbox.so[0x2aaaaaac7c79]
/usr/lib/libsandbox.so(libsb_fini+0x6f)[0x2aaaaaac7d07]
/usr/lib/libsandbox.so[0x2aaaaaac7662]
======= Memory map: ========
00400000-00505000 r-xp 00000000 fe:04 13255168                          
/var/tmp/portage/freehdl-20050510/work/freehdl-20050510/v2cc/.libs/lt-freehdl-v2cc
00605000-00612000 rw-p 00105000 fe:04 13255168                          
/var/tmp/portage/freehdl-20050510/work/freehdl-20050510/v2cc/.libs/lt-freehdl-v2cc
00612000-00c22000 rw-p 00612000 00:00 0                                  [heap]
3000000000-300001a000 r-xp 00000000 fe:04 16340998                      
/lib64/ld-2.3.90.so
300011a000-300011b000 r--p 0001a000 fe:04 16340998                      
/lib64/ld-2.3.90.so
300011b000-300011d000 rw-p 0001b000 fe:04 16340998                      
/lib64/ld-2.3.90.so
3000d00000-3000e26000 r-xp 00000000 fe:04 16340999                      
/lib64/libc-2.3.90.so
3000e26000-3000f25000 ---p 00126000 fe:04 16340999                      
/lib64/libc-2.3.90.so
3000f25000-3000f28000 r--p 00125000 fe:04 16340999                      
/lib64/libc-2.3.90.so
3000f28000-3000f2c000 rw-p 00128000 fe:04 16340999                      
/lib64/libc-2.3.90.so
3000f2c000-3000f30000 rw-p 3000f2c000 00:00 0
3001000000-3001084000 r-xp 00000000 fe:04 16341000                      
/lib64/libm-2.3.90.so
3001084000-3001183000 ---p 00084000 fe:04 16341000                      
/lib64/libm-2.3.90.so
3001183000-3001185000 rw-p 00083000 fe:04 16341000                      
/lib64/libm-2.3.90.so
3001200000-3001202000 r-xp 00000000 fe:04 16341002                      
/lib64/libdl-2.3.90.so
3001202000-3001302000 ---p 00002000 fe:04 16341002                      
/lib64/libdl-2.3.90.so
3001302000-3001304000 rw-p 00002000 fe:04 16341002                      
/lib64/libdl-2.3.90.so
3004d00000-3004dee000 r-xp 00000000 fe:04 5341688                       
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.0.1/libstdc++.so.6.0.5
3004dee000-3004eed000 ---p 000ee000 fe:04 5341688                       
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.0.1/libstdc++.so.6.0.5
3004eed000-3004ef6000 rw-p 000ed000 fe:04 5341688                       
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.0.1/libstdc++.so.6.0.5
3004ef6000-3004f08000 rw-p 3004ef6000 00:00 0
3005400000-300540d000 r-xp 00000000 fe:04 5341687                       
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.0.1/libgcc_s.so.1
300540d000-300550c000 ---p 0000d000 fe:04 5341687                       
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.0.1/libgcc_s.so.1
300550c000-300550d000 rw-p 0000c000 fe:04 5341687                       
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.0.1/libgcc_s.so.1
2aaaaaac5000-2aaaaaac6000 rw-p 2aaaaaac5000 00:00 0
2aaaaaac6000-2aaaaaacd000 r-xp 00000000 fe:04 13435663                  
/usr/lib64/libsandbox.so.0.0.0
2aaaaaacd000-2aaaaabcc000 ---p 00007000 fe:04 13435663                  
/usr/lib64/libsandbox.so.0.0.0
2aaaaabcc000-2aaaaabcd000 rw-p 00006000 fe:04 13435663                  
/usr/lib64/libsandbox.so.0.0.0
2aaaaabcd000-2aaaaabcf000 rw-p 2aaaaabcd000 00:00 0
2aaaaabcf000-2aaaaac63000 r-xp 00000000 fe:04 13206952                  
/var/tmp/portage/freehdl-20050510/work/freehdl-20050510/vaul/.libs/libfreehdl-vaul.so.0.0.0
2aaaaac63000-2aaaaad62000 ---p 00094000 fe:04 13206952                  
/var/tmp/portage/freehdl-20050510/work/freehdl-20050510/vaul/.libs/libfreehdl-vaul.so.0.0.0
2aaaaad62000-2aaaaad72000 rw-p 00093000 fe:04 13206952                  
/var/tmp/portage/freehdl-20050510/work/freehdl-20050510/vaul/.libs/libfreehdl-vaul.so.0.0.0
2aaaaad72000-2aaaaadad000 r-xp 00000000 fe:04 13060604                  
/var/tmp/portage/freehdl-20050510/work/freehdl-20050510/fire/.libs/libfreehdl-fire.so.0.0.0
2aaaaadad000-2aaaaaeac000 ---p 0003b000 fe:04 13060604                  
/var/tmp/portage/freehdl-20050510/work/freehdl-20050510/fire/.libs/libfreehdl-fire.so.0.0.0
2aaaaaeac000-2aaaaaeb9000 rw-p 0003a000 fe:04 13060604                  
/var/tmp/portage/freehdl-20050510/work/freehdl-20050510/fire/.libs/libfreehdl-fire.so.0.0.0
2aaaaaeb9000-2aaaaaebe000 rw-p 2aaaaaeb9000 00:00 0
2aaaaaf00000-2aaaaaf21000 rw-p 2aaaaaf00000 00:00 0
2aaaaaf21000-2aaaab000000 ---p 2aaaaaf21000 00:00 0
7fffff791000-7fffff88f000 rw-p 7fffff791000 00:00 0                      [stack]
ffffffffff600000-ffffffffffe00000 ---p 00000000 00:00 0                  [vdso]
/bin/sh: line 1:  1614 Aborted                 ../v2cc/freehdl-v2cc -lieee -L ..
std_logic_arith.vhdl >std_logic_arith.cc.tmp
-----
Comment 4 Martin Schlemmer (RETIRED) gentoo-dev 2005-08-29 07:09:18 UTC
And a debugging run:

-----
(gdb) r -lieee -L .. std_logic_arith.vhdl > foo
Starting program:
/var/tmp/portage/freehdl-20050510/work/freehdl-20050510/v2cc/.libs/lt-freehdl-v2cc
-lieee -L .. std_logic_arith.vhdl > foo
*** glibc detected ***
/var/tmp/portage/freehdl-20050510/work/freehdl-20050510/v2cc/.libs/lt-freehdl-v2cc:
corrupted double-linked list: 0x0000003000f2c158 ***
======= Backtrace: =========
/lib/libc.so.6[0x3000d6c893]
/lib/libc.so.6[0x3000d6c9fb]
/lib/libc.so.6[0x3000d6d067]
/lib/libc.so.6(__libc_free+0x6c)[0x3000d6d39c]
/usr/lib/libsandbox.so[0x2aaaaaac7c79]
/usr/lib/libsandbox.so(libsb_fini+0x6f)[0x2aaaaaac7d07]
/usr/lib/libsandbox.so[0x2aaaaaac7662]
======= Memory map: ========
00400000-00505000 r-xp 00000000 fe:04 13255168                          
/var/tmp/portage/freehdl-20050510/work/freehdl-20050510/v2cc/.libs/lt-freehdl-v2cc
00605000-00612000 rw-p 00105000 fe:04 13255168                          
/var/tmp/portage/freehdl-20050510/work/freehdl-20050510/v2cc/.libs/lt-freehdl-v2cc
00612000-00c22000 rw-p 00612000 00:00 0                                  [heap]
3000000000-300001a000 r-xp 00000000 fe:04 16340998                      
/lib64/ld-2.3.90.so
300011a000-300011b000 r--p 0001a000 fe:04 16340998                      
/lib64/ld-2.3.90.so
300011b000-300011d000 rw-p 0001b000 fe:04 16340998                      
/lib64/ld-2.3.90.so
3000d00000-3000e26000 r-xp 00000000 fe:04 16340999                      
/lib64/libc-2.3.90.so
3000e26000-3000f25000 ---p 00126000 fe:04 16340999                      
/lib64/libc-2.3.90.so
3000f25000-3000f28000 r--p 00125000 fe:04 16340999                      
/lib64/libc-2.3.90.so
3000f28000-3000f2c000 rw-p 00128000 fe:04 16340999                      
/lib64/libc-2.3.90.so
3000f2c000-3000f30000 rw-p 3000f2c000 00:00 0
3001000000-3001084000 r-xp 00000000 fe:04 16341000                      
/lib64/libm-2.3.90.so
3001084000-3001183000 ---p 00084000 fe:04 16341000                      
/lib64/libm-2.3.90.so
3001183000-3001185000 rw-p 00083000 fe:04 16341000                      
/lib64/libm-2.3.90.so
3001200000-3001202000 r-xp 00000000 fe:04 16341002                      
/lib64/libdl-2.3.90.so
3001202000-3001302000 ---p 00002000 fe:04 16341002                      
/lib64/libdl-2.3.90.so
3001302000-3001304000 rw-p 00002000 fe:04 16341002                      
/lib64/libdl-2.3.90.so
3004d00000-3004dee000 r-xp 00000000 fe:04 5341688                       
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.0.1/libstdc++.so.6.0.5
3004dee000-3004eed000 ---p 000ee000 fe:04 5341688                       
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.0.1/libstdc++.so.6.0.5
3004eed000-3004ef6000 rw-p 000ed000 fe:04 5341688                       
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.0.1/libstdc++.so.6.0.5
3004ef6000-3004f08000 rw-p 3004ef6000 00:00 0
3005400000-300540d000 r-xp 00000000 fe:04 5341687                       
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.0.1/libgcc_s.so.1
300540d000-300550c000 ---p 0000d000 fe:04 5341687                       
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.0.1/libgcc_s.so.1
300550c000-300550d000 rw-p 0000c000 fe:04 5341687                       
/usr/lib64/gcc/x86_64-pc-linux-gnu/4.0.1/libgcc_s.so.1
2aaaaaac5000-2aaaaaac6000 rw-p 2aaaaaac5000 00:00 0
2aaaaaac6000-2aaaaaacd000 r-xp 00000000 fe:04 13435663                  
/usr/lib64/libsandbox.so.0.0.0
2aaaaaacd000-2aaaaabcc000 ---p 00007000 fe:04 13435663                  
/usr/lib64/libsandbox.so.0.0.0
2aaaaabcc000-2aaaaabcd000 rw-p 00006000 fe:04 13435663                  
/usr/lib64/libsandbox.so.0.0.0
2aaaaabcd000-2aaaaabcf000 rw-p 2aaaaabcd000 00:00 0
2aaaaabcf000-2aaaaac63000 r-xp 00000000 fe:04 13206952                  
/var/tmp/portage/freehdl-20050510/work/freehdl-20050510/vaul/.libs/libfreehdl-vaul.so.0.0.0
2aaaaac63000-2aaaaad62000 ---p 00094000 fe:04 13206952                  
/var/tmp/portage/freehdl-20050510/work/freehdl-20050510/vaul/.libs/libfreehdl-vaul.so.0.0.0
2aaaaad62000-2aaaaad72000 rw-p 00093000 fe:04 13206952                  
/var/tmp/portage/freehdl-20050510/work/freehdl-20050510/vaul/.libs/libfreehdl-vaul.so.0.0.0
2aaaaad72000-2aaaaadad000 r-xp 00000000 fe:04 13060604                  
/var/tmp/portage/freehdl-20050510/work/freehdl-20050510/fire/.libs/libfreehdl-fire.so.0.0.0
2aaaaadad000-2aaaaaeac000 ---p 0003b000 fe:04 13060604                  
/var/tmp/portage/freehdl-20050510/work/freehdl-20050510/fire/.libs/libfreeh
Program received signal SIGABRT, Aborted.
0x0000003000d30c3a in raise () from /lib/libc.so.6
(gdb) bt
#0  0x0000003000d30c3a in raise () from /lib/libc.so.6
#1  0x0000003000d31fa0 in abort () from /lib/libc.so.6
#2  0x0000003000d673bf in __fsetlocking () from /lib/libc.so.6
#3  0x0000003000d6c893 in malloc_usable_size () from /lib/libc.so.6
#4  0x0000003000d6c9fb in malloc_usable_size () from /lib/libc.so.6
#5  0x0000003000d6d067 in malloc_usable_size () from /lib/libc.so.6
#6  0x0000003000d6d39c in free () from /lib/libc.so.6
#7  0x00002aaaaaac7c79 in clean_env_entries (prefixes_array=0x2aaaaabcc4a8,
prefixes_num=0x2aaaaabcc4b0) at libsandbox.c:878
#8  0x00002aaaaaac7d07 in libsb_fini () at libsandbox.c:288
#9  0x00002aaaaaac7662 in __do_global_dtors_aux () from /usr/lib/libsandbox.so
#10 0x00007fffffa92b40 in ?? ()
#11 0x00002aaaaaacb5a1 in _fini () from /usr/lib/libsandbox.so
#12 0x0000000000000000 in ?? ()
#13 0x000000300000d083 in _dl_fini () from /lib64/ld-linux-x86-64.so.2
Previous frame inner to this frame (corrupt stack?)
(gdb)

Comment 5 Martin Schlemmer (RETIRED) gentoo-dev 2005-08-29 07:13:04 UTC
All though that should be fine, as we check and zero whatever if we free it.  I
wonder if its not a problem in libfreehdl-vaul.so.0, libfreehdl-fire.so.0.0.0 or
lt-freehdl-v2cc itself.
Comment 6 Martin Schlemmer (RETIRED) gentoo-dev 2005-08-29 12:30:02 UTC
For a mtrace() run, address 0x621720 is the one that gets double freed, and this
is the output:

----
 $ grep 0x621720 ieee/trace.txt
@ /usr/lib/libsandbox.so:[0x2aaaaaaaf5db] + 0x621720 0x2000
@ /usr/lib/libsandbox.so:[0x2aaaaaaaf778] - 0x621720
@ /usr/lib/libsandbox.so:[0x2aaaaaaae63a] + 0x621720 0x2000
@ /usr/lib/libsandbox.so:[0x2aaaaaaadad2] - 0x621720
----

So either there is a bug or something else in the malloc double free detectors,
mtrace() is busted, or some weird memory overlapping issue ??? :/
Comment 7 Martin Schlemmer (RETIRED) gentoo-dev 2005-08-29 13:06:10 UTC
Patrick, can you please try run it through valgrind ?  Over here valgrind do not
want to play nice :/
Comment 8 Martin Schlemmer (RETIRED) gentoo-dev 2005-08-29 14:11:06 UTC
Ok, electric fence give something like this:

-----
make[1]: Entering directory
`/var/tmp/portage/freehdl-20050510/work/freehdl-20050510/ieee'
../v2cc/freehdl-v2cc -lieee -L .. std_logic_1164.vhdl >std_logic_1164.cc.tmp &&
mv std_logic_1164.cc.tmp std_logic_1164.cc

ElectricFence: Registering with atexit().
ElectricFence: If this hangs, change the library load order with LD_PRELOAD.
ElectricFence: Registration was successful.

ElectricFence Aborting:
Free mismatch: allocator 'new[] (array)' used  at UNKNOWN (use #include
"efencepp.h")(0)
  but  deallocator 'delete (element)' called at UNKNOWN (use #include
"efencepp.h")(0)!
-----

So it seems its a problem somewhere inside freehdl.  I cannot however get the
whole thing to compile with efence, as they redefine the new operator, and
efence do not like that.
Comment 9 Patrick Kursawe (RETIRED) gentoo-dev 2005-08-30 02:02:35 UTC
Oh boy... maybe I should point the developers to valgrind. It's a miracle this
program ever ran without crashing.

After fixing two wrong delete/delete[]s I still get:
==28005== More than 30000 total errors detected.  I'm not reporting any more.
==28005== Final error counts will be inaccurate.  Go fix your program!

Sorry for wasting your time, I just thought it was a sandbox problem because it
didn't crash when it didn't run in sandbox.
Comment 10 Patrick Kursawe (RETIRED) gentoo-dev 2005-08-30 05:44:58 UTC
Made a little patch that fixes this issue. You still don't want to look at the
valgrind output, but at least the mismatched new[]/delete are gone. Thanks for
your time and the valgrind hint (didn't use it before).