Dear libcg developers,
it looked like you have some interesting new additions in the latest code, but 
I found when building from the latest git source cgconfigparser segfaults when 
/etc/cgconfig.conf is not empty. The PKGBUILD is adapted from the AUR package 
to build a -git package in Artix using OpenRC. Here are my build details in 
case it is only my error!



$ cat PKGBUILD
pkgname=libcgroup-git
pkgver=r920.62f7665
pkgrel=1
pkgdesc='Library that abstracts the control group file system in Linux - GIT 
version'
arch=('i686' 'x86_64')
url='http://libcg.sourceforge.net <http://libcg.sourceforge.net>'
license=(LGPL)
makedepends=('git')
backup=('etc/cgconfig.conf'
        'etc/cgrules.conf'
'etc/cgsnapshot_blacklist.conf')
options=('!emptydirs' '!libtool')
install=libcgroup.install
source=("git://git.code.sf.net/p/libcg/libcg 
<http://git.code.sf.net/p/libcg/libcg>")
md5sums=('SKIP')

pkgver() {
        cd "$srcdir/libcg"
        printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short 
HEAD)"
}

build() {
cd "${srcdir}/libcg"
autoreconf -i
./configure \
--prefix=/usr \
--sysconfdir=/etc \
--localstatedir=/var \
--sbindir=/usr/bin \
--enable-opaque-hierarchy=name=openrc
make
}

package() {
cd "${srcdir}/libcg"
make DESTDIR="${pkgdir}" pkgconfigdir="/usr/lib/pkgconfig" install
install -D -m0644 samples/cgconfig.conf "${pkgdir}/etc/cgconfig.conf"
install -D -m0644 samples/cgrules.conf "${pkgdir}/etc/cgrules.conf"
install -D -m0644 samples/cgsnapshot_blacklist.conf 
"${pkgdir}/etc/cgsnapshot_blacklist.conf"
rm -f ${pkgdir}/usr/lib/security/pam_cgroup.{la,so,so.0}
mv ${pkgdir}/usr/lib/security/pam_cgroup.so.0.0.0 
${pkgdir}/usr/lib/security/pam_cgroup.so
rm -rf ${pkgdir}/etc/rc.d
# Make cgexec setgid cgred
chown root:160 ${pkgdir}/usr/bin/cgexec
chmod 2755 ${pkgdir}/usr/bin/cgexec
}


$ cat libcgroup.install
post_install() {
  getent group cgred &>/dev/null || groupadd -r -g 160 cgred >/dev/null
}

post_upgrade() {
  post_install
}

post_remove() {
  getent group cgred &>/dev/null && groupdel cgred >/dev/null
}



$ gcc --version
gcc (GCC) 9.1.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

makepkg.conf altered for debug build:
#OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge !debug)
OPTIONS=(!strip docs !libtool !staticlibs emptydirs zipman purge debug)


cgconfig.conf taken from man page example:

            mount {
                     cpu = /mnt/cgroups/cpu;
                     cpuacct = /mnt/cgroups/cpuacct;
              }

              group daemons {
                     cpuacct{
                     }
                     cpu {
                     }
              }




$ sudo /usr/bin/cgconfigparser -l /etc/cgconfig.conf
Segmentation fault
$ sudo gdb --args /usr/bin/cgconfigparser -l /etc/cgconfig.conf
GNU gdb (GDB) 8.3
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html 
<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-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/ <http://www.gnu.org/software/gdb/bugs/>>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/ 
<http://www.gnu.org/software/gdb/documentation/>>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/bin/cgconfigparser...
(gdb) run
Starting program: /usr/bin/cgconfigparser -l /etc/cgconfig.conf
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7ca0540 in __strncpy_ssse3 () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007ffff7ca0540 in __strncpy_ssse3 () from /usr/lib/libc.so.6
#1  0x00007ffff7d4479e in strncpy (__len=4095, __src=0x5555f8b0 <error: Cannot 
access memory at address 0x5555f8b0>, __dest=<optimized out>)
    at /usr/include/bits/string_fortified.h:106
#2  config_insert_cgroup (cg_name=0x5555f8b0 <error: Cannot access memory at 
address 0x5555f8b0>, flag=flag@entry=0) at config.c:174
#3  0x00007ffff7d44808 in cgroup_config_insert_cgroup (cg_name=<optimized out>) 
at config.c:193
#4  0x00007ffff7d3a9a5 in yyparse () at parse.y:106
#5  0x00007ffff7d445be in cgroup_parse_config (pathname=0x555555559280 
"/etc/cgconfig.conf") at config.c:1083
#6  0x00007ffff7d452a9 in cgroup_config_load_config (pathname=<optimized out>) 
at config.c:1127
#7  0x000055555555534c in main (argc=<optimized out>, argv=0x7fffffffe5c8) at 
cgconfig.c:191
(gdb) 

Trying again building with an older gcc-7 resulted in the same issue:
$ sudo gdb --args /usr/bin/cgconfigparser -l /etc/cgconfig.conf
...
Reading symbols from /usr/bin/cgconfigparser...
(gdb) run
Starting program: /usr/bin/cgconfigparser -l /etc/cgconfig.conf
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7ca0540 in __strncpy_ssse3 () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007ffff7ca0540 in __strncpy_ssse3 () from /usr/lib/libc.so.6
#1  0x00007ffff7d44648 in strncpy (__len=4095, __src=0x5555f8b0 <error: Cannot 
access memory at address 0x5555f8b0>, __dest=<optimized out>)
    at /usr/include/bits/string_fortified.h:106
#2  config_insert_cgroup (cg_name=0x5555f8b0 <error: Cannot access memory at 
address 0x5555f8b0>, flag=flag@entry=0) at config.c:174
#3  0x00007ffff7d44728 in cgroup_config_insert_cgroup (cg_name=<optimized out>) 
at config.c:193
#4  0x00007ffff7d3af2c in yyparse () at parse.y:106
#5  0x00007ffff7d4453e in cgroup_parse_config (pathname=0x555555559280 
"/etc/cgconfig.conf") at config.c:1083
#6  0x00007ffff7d45189 in cgroup_config_load_config (pathname=<optimized out>) 
at config.c:1127
#7  0x0000555555555394 in main (argc=<optimized out>, argv=0x7fffffffe5c8) at 
cgconfig.c:191
(gdb)



_______________________________________________
Libcg-devel mailing list
Libcg-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to