[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1043238: marked as done (libpfm4: crashes on initialization on 32bit arm in autopkgtest CI)



Your message dated Tue, 05 Sep 2023 14:40:23 +0000
with message-id <E1qdXE7-00E0gi-8c@fasolo.debian.org>
and subject line Bug#1043238: fixed in libpfm4 4.13.0+git15-gefd10fb-2
has caused the Debian Bug report #1043238,
regarding libpfm4: crashes on initialization on 32bit arm in autopkgtest CI
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
1043238: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1043238
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---
Package: libpfm4
Version: 4.13.0-1
Severity: important
Tags: patch

Hello,

We are seeing a crash at libpfm initialization in the starpu autopkgtest
CI testsuite. This can be easily reproduced in the autopkgtest CI
environment with:

#include <perfmon/pfmlib.h>

int main(void) {
        pfm_initialize();
}

gcc test.c -o test -lpfm



(gdb) r
Starting program: /root/test
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabi/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0xf7f8f4e0 in pfmlib_getl (buffer=buffer@entry=0xfffefab0,
    len=len@entry=0xfffefaac, fp=fp@entry=0x403190) at pfmlib_common.c:794
 794            b[i] = '\0';
(gdb) bt
#0  0xf7f8f4e0 in pfmlib_getl (buffer=buffer@entry=0xfffefab0,
    len=len@entry=0xfffefaac, fp=fp@entry=0x403190) at pfmlib_common.c:794
#1  0xf7f94124 in pfmlib_getcpuinfo_attr (attr=0xf7f977fc "CPU implementer",
    ret_buf=0xf7f94124 <pfmlib_getcpuinfo_attr+120> "\020\260\235\345\001",
    ret_buf@entry=0xfffefae4 "\304\373\376\367\001", maxlen=128)
    at pfmlib_arm.c:78
#2  0xf7f94240 in pfm_arm_detect (this=<optimized out>) at pfmlib_arm.c:156
#3  0xf7f94980 in pfm_arm_detect_cortex_a7 (this=<optimized out>)
    at pfmlib_arm_armv7_pmuv1.c:48
#4  0xf7f8fbf4 in pfmlib_init_pmus () at pfmlib_common.c:1139
#5  pfm_initialize () at pfmlib_common.c:1239
#6  0x00400588 in main ()

(gdb) bt full
#0  0xf7f8f4e0 in pfmlib_getl (buffer=buffer@entry=0xfffefac0,
    len=len@entry=0xfffefabc, fp=fp@entry=0x403190) at pfmlib_common.c:794
        b = 0x0
        c = <optimized out>
        maxsz = 0
        maxi = 4294967294
        d = <optimized out>
        i = 0
#1  0xf7f94124 in pfmlib_getcpuinfo_attr (attr=0xf7f977fc "CPU implementer",
    ret_buf=0xf7f94124 <pfmlib_getcpuinfo_attr+120> "\020\260\235\345\001",
    ret_buf@entry=0xfffefaf4 "\304\373\376\367\001", maxlen=128)
    at pfmlib_arm.c:78
        fp = 0x403190
        ret = -1
        attr_len = 15
        buf_len = 0
        p = <optimized out>
        value = <optimized out>
        buffer = 0x0
#2  0xf7f94240 in pfm_arm_detect (this=<optimized out>) at pfmlib_arm.c:156
        ret = <optimized out>
        buffer = "\304\373\376\367\001\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\001\000\000\000X\372\376\367\000\000\000\000\360#\374\367(\374\376\3678\360\376\367", '\000' <repeats 28 times>, "\377\377\377\377HE\370\367\360#\374\367", '\000' <repeats 20 times>, "X\372\376\367\001\377\376\377p\375\376\377LI\000\000x\322\343\367\300\242\373", <incomplete sequence \367>
#3  0xf7f94980 in pfm_arm_detect_cortex_a7 (this=<optimized out>)
    at pfmlib_arm_armv7_pmuv1.c:48
        ret = <optimized out>
#4  0xf7f8fbf4 in pfmlib_init_pmus () at pfmlib_common.c:1139
        p = 0xf7fb75a4 <arm_cortex_a7_support>
        i = <optimized out>
        ret = 0
        nsuccess = -66220
        p = <optimized out>
        i = <optimized out>
        ret = <optimized out>
        nsuccess = <optimized out>
        __func__ = "pfmlib_init_pmus"
#5  pfm_initialize () at pfmlib_common.c:1239
        ret = <optimized out>
        __func__ = <optimized out>
#6  0x00400588 in main ()


It seems that it is crashing because /proc/cpuinfo is empty, and thus
pfmlib_getl never allocates a buffer, and the trailing b[i] = '\0' thus
becomes bogus. The attached patch fixes this in my tests.

Samuel

-- System Information:
Debian Release: trixie/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable-debug'), (500, 'testing-debug'), (500, 'stable-security'), (500, 'stable-debug'), (500, 'oldstable-proposed-updates-debug'), (500, 'oldstable-proposed-updates'), (500, 'oldoldstable-proposed-updates'), (500, 'oldoldstable'), (500, 'buildd-unstable'), (500, 'unstable'), (500, 'stable'), (500, 'oldstable'), (1, 'experimental-debug'), (1, 'buildd-experimental'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386, arm64

Kernel: Linux 6.4.0-1-amd64 (SMP w/8 CPU threads; PREEMPT)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages libpfm4 depends on:
ii  libc6  2.37-6

libpfm4 recommends no packages.

libpfm4 suggests no packages.

-- no debconf information
Cope with empty /proc/cpuinfo file

--- a/lib/pfmlib_common.c
+++ b/lib/pfmlib_common.c
@@ -791,7 +791,8 @@ pfmlib_getl(char **buffer, size_t *len,
 		if (c == '\n')
 			break;
 	}
-	b[i] = '\0';
+       if (c != EOF)
+               b[i] = '\0';
 	return c != EOF ? 0 : -1;
 }
 
--- a/lib/pfmlib_arm.c
+++ b/lib/pfmlib_arm.c
@@ -97,6 +97,8 @@ pfmlib_getcpuinfo_attr(const char *attr,
 		if (!strncmp(attr, buffer, attr_len))
 			break;
 	}
+       if (!value)
+               goto error;
 	strncpy(ret_buf, value, maxlen-1);
 	ret_buf[maxlen-1] = '\0';
 	ret = 0;

--- End Message ---
--- Begin Message ---
Source: libpfm4
Source-Version: 4.13.0+git15-gefd10fb-2
Done: Andreas Beckmann <anbe@debian.org>

We believe that the bug you reported is fixed in the latest version of
libpfm4, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 1043238@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Andreas Beckmann <anbe@debian.org> (supplier of updated libpfm4 package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Format: 1.8
Date: Tue, 05 Sep 2023 15:41:15 +0200
Source: libpfm4
Architecture: source
Version: 4.13.0+git15-gefd10fb-2
Distribution: unstable
Urgency: medium
Maintainer: Debian HPC Team <debian-hpc@lists.debian.org>
Changed-By: Andreas Beckmann <anbe@debian.org>
Closes: 1043238
Changes:
 libpfm4 (4.13.0+git15-gefd10fb-2) unstable; urgency=medium
 .
   [ Samuel Thibault ]
   * Do not crash on empty /proc/cpuinfo.  (Closes: #1043238)
Checksums-Sha1:
 b432639c00a4e2560e8b5d5a98a00dab62c5cc5c 2149 libpfm4_4.13.0+git15-gefd10fb-2.dsc
 b07f34a0831dc654706463788521af490562b273 11828 libpfm4_4.13.0+git15-gefd10fb-2.debian.tar.xz
 5cb6c683c089386be2859ab88402c4f05607fe8c 5727 libpfm4_4.13.0+git15-gefd10fb-2_source.buildinfo
Checksums-Sha256:
 86e1dfa98aefd0eb593c70378b2b1bbec1ad2afe9f54f1959ee5490fbe0ed9d8 2149 libpfm4_4.13.0+git15-gefd10fb-2.dsc
 14a7dcb5b1a24e65523de31e2e614b9fcad3a9ac26a96ce9932b15284944496b 11828 libpfm4_4.13.0+git15-gefd10fb-2.debian.tar.xz
 6ef4a6cbf6706b7215e787ef6f91697a637465dd2cb52f2775da195a0ac7a5e0 5727 libpfm4_4.13.0+git15-gefd10fb-2_source.buildinfo
Files:
 b967a675021ad39afb48b3f1dcf89e72 2149 libs optional libpfm4_4.13.0+git15-gefd10fb-2.dsc
 947000e9240e26cb422fe6064089b73a 11828 libs optional libpfm4_4.13.0+git15-gefd10fb-2.debian.tar.xz
 6643f6b50057148bd184680bd722098b 5727 libs optional libpfm4_4.13.0+git15-gefd10fb-2_source.buildinfo

-----BEGIN PGP SIGNATURE-----

iQJEBAEBCAAuFiEE6/MKMKjZxjvaRMaUX7M/k1np7QgFAmT3MF4QHGFuYmVAZGVi
aWFuLm9yZwAKCRBfsz+TWentCGfcEACDJbXlI+wQ32cFMOAI8ZhPFd/XSpoOiLmY
RErI8nrSGlZ+Ufqyz9eLvodq2g0lIIWYNjTZPNwOM2o1heepxk/I2va2Noc4Tdh2
2aITTSS1eTAexdFLZXoIF3wxM6fomATH4MPfj+aWStMaejT7nDhJOq7gXaFHFQOH
2qGIEOQ1ZuHjXPeXm0Hk85ZCr1AuR5pH6nvJWan94xJM1+gqETdNEuQ2R67aetIl
ptXDBFDcAsssM7l7tCYamMBFmiynftivkUqUnRuBbzK5KQfOACXjLga3c4i6FEeM
ce4K7/nmOCU7dVcMj0GkCJ2hDVsXHqZhDM6ZeNLbR9UTtsxPUyLLgLJks6LsSCm7
nMt6RELp/Jcqa7Ffub2wxdCvZoL0W+8lyoJeCrBq6Lk7uBXjFrHkk1r2UGy3OJRV
lC2AwvKTptoSId/dbfU0rpox5t0SjYcqh4AIDAhZ2Iki9nivKbJListKSuqmgRSV
f4ArizCYAnenSlXh4MJgJl2DI0p0lnSWcjO3IyxvvPCod6IAgVdZ4Jc2mdTRWSA9
hnMp/eqdsGEbTCiiGE0WaYWRuigAQXbK+//WXIl9emV3+dMiZgfSd30Yu1ftZfrX
K0CKv7CcX9MbPaOf5f6dWmJufo3bNZIR+Wp/180QE4vxuScnUvXFue1SV3J0v7oN
XW8Hp/WfYA==
=3FEZ
-----END PGP SIGNATURE-----

--- End Message ---

Reply to: