Closed bbonev closed 1 year ago
Many thanks for the info.
To make this much more useful, I would need the exact commit in which you find both the compilation and runtime errors (e.g., the line if(logo->color_ascii[i] == NULL) break;
does not exist in src/common/printer.c
in the last commit). To find the commit of the program giving you the runtime error, you should be fine running ./cpufetch -V
.
Compile error is from 1.3 release (can be ignored). Valgrind is on git HEAD.
Ah, okay.
Do you mind running valgrind again but with cpufetch compiled with make debug
to enable debug information? Valgrind says the issue is in get_topology_info
, but that is a quite long function.
Sure:
$ make clean
$ make debug
cc -Wall -Wextra -pedantic -DARCH_PPC -std=gnu99 -fstack-protector-all -Wno-language-extension-token -g -O0 -Wfloat-equal -Wshadow -Wpointer-arith -Wstrict-prototypes -DGIT_FULL_VERSION=\""v1.03-49-gbec4"\" src/common/main.c src/common/cpu.c src/common/udev.c src/common/printer.c src/common/args.c src/common/global.c src/ppc/ppc.c src/ppc/uarch.c src/ppc/udev.c -o cpufetch
$ valgrind ./cpufetch
==145729== Memcheck, a memory error detector
==145729== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==145729== Using Valgrind-3.19.0 and LibVEX; rerun with -h for copyright info
==145729== Command: ./cpufetch
==145729==
==145729== Invalid read of size 4
==145729== at 0x18961C: get_topology_info (ppc.c:77)
==145729== by 0x189D23: get_cpu_info (ppc.c:179)
==145729== by 0x182253: main (main.c:101)
==145729== Address 0x4c9590c is 4 bytes before a block of size 640 alloc'd
==145729== at 0x48A5418: malloc (vg_replace_malloc.c:381)
==145729== by 0x188E43: emalloc (global.c:132)
==145729== by 0x18959F: get_topology_info (ppc.c:72)
==145729== by 0x189D23: get_cpu_info (ppc.c:179)
==145729== by 0x182253: main (main.c:101)
==145729==
==145729== Invalid write of size 4
==145729== at 0x189624: get_topology_info (ppc.c:77)
==145729== by 0x189D23: get_cpu_info (ppc.c:179)
==145729== by 0x182253: main (main.c:101)
==145729== Address 0x4c9590c is 4 bytes before a block of size 640 alloc'd
==145729== at 0x48A5418: malloc (vg_replace_malloc.c:381)
==145729== by 0x188E43: emalloc (global.c:132)
==145729== by 0x18959F: get_topology_info (ppc.c:72)
==145729== by 0x189D23: get_cpu_info (ppc.c:179)
==145729== by 0x182253: main (main.c:101)
==145729==
==145729== Conditional jump or move depends on uninitialised value(s)
==145729== at 0x4945D20: ____strtol_l_internal (strtol_l.c:431)
==145729== by 0x4945B8B: strtol (strtol.c:106)
==145729== by 0x18469B: get_num_caches_from_files (udev.c:217)
==145729== by 0x184B47: get_num_caches_by_level (udev.c:273)
==145729== by 0x18921B: get_cache_info (ppc.c:25)
==145729== by 0x189D37: get_cpu_info (ppc.c:180)
==145729== by 0x182253: main (main.c:101)
==145729==
Microarchitecture: POWER8
Technology: 22nm
Max Frequency: Unknown
Cores: 0 cores
Altivec: Yes
L1i Size: 32KB (640KB Total)
L1d Size: 64KB (1.25MB Total)
L2 Size: 512KB (10MB Total)
L3 Size: 8MB (160MB Total)
Peak Performance: Unknown
==145729==
==145729== HEAP SUMMARY:
==145729== in use at exit: 2,676,735 bytes in 2,060 blocks
==145729== total heap usage: 6,243 allocs, 4,183 frees, 4,295,783 bytes allocated
==145729==
==145729== LEAK SUMMARY:
==145729== definitely lost: 2,648,433 bytes in 659 blocks
==145729== indirectly lost: 28,302 bytes in 1,401 blocks
==145729== possibly lost: 0 bytes in 0 blocks
==145729== still reachable: 0 bytes in 0 blocks
==145729== suppressed: 0 bytes in 0 blocks
==145729== Rerun with --leak-check=full to see details of leaked memory
==145729==
==145729== Use --track-origins=yes to see where uninitialised values come from
==145729== For lists of detected and suppressed errors, rerun with: -s
==145729== ERROR SUMMARY: 2880 errors from 3 contexts (suppressed: 0 from 0)
If that will help, I can provide you access
Okay, I was suspecting the error was in ppc.c:77
and there it is.
I have pushed a new commit in the bugfix2
branch. Can you run ./cpufetch -v
? It should give an error message somewhere, probably in check_package_ids_integrity
. If it does not, I would really appreciate access to your machine to figure out what's wrong.
$ valgrind ./cpufetch
==147126== Memcheck, a memory error detector
==147126== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==147126== Using Valgrind-3.19.0 and LibVEX; rerun with -h for copyright info
==147126== Command: ./cpufetch
==147126==
==147126== Invalid read of size 4
==147126== at 0x18961C: get_topology_info (ppc.c:77)
==147126== by 0x189D23: get_cpu_info (ppc.c:179)
==147126== by 0x182253: main (main.c:101)
==147126== Address 0x4c9590c is 4 bytes before a block of size 640 alloc'd
==147126== at 0x48A5418: malloc (vg_replace_malloc.c:381)
==147126== by 0x188E43: emalloc (global.c:132)
==147126== by 0x18959F: get_topology_info (ppc.c:72)
==147126== by 0x189D23: get_cpu_info (ppc.c:179)
==147126== by 0x182253: main (main.c:101)
==147126==
==147126== Invalid write of size 4
==147126== at 0x189624: get_topology_info (ppc.c:77)
==147126== by 0x189D23: get_cpu_info (ppc.c:179)
==147126== by 0x182253: main (main.c:101)
==147126== Address 0x4c9590c is 4 bytes before a block of size 640 alloc'd
==147126== at 0x48A5418: malloc (vg_replace_malloc.c:381)
==147126== by 0x188E43: emalloc (global.c:132)
==147126== by 0x18959F: get_topology_info (ppc.c:72)
==147126== by 0x189D23: get_cpu_info (ppc.c:179)
==147126== by 0x182253: main (main.c:101)
==147126==
==147126== Conditional jump or move depends on uninitialised value(s)
==147126== at 0x4945D20: ____strtol_l_internal (strtol_l.c:431)
==147126== by 0x4945B8B: strtol (strtol.c:106)
==147126== by 0x18469B: get_num_caches_from_files (udev.c:217)
==147126== by 0x184B47: get_num_caches_by_level (udev.c:273)
==147126== by 0x18921B: get_cache_info (ppc.c:25)
==147126== by 0x189D37: get_cpu_info (ppc.c:180)
==147126== by 0x182253: main (main.c:101)
==147126==
Microarchitecture: POWER8
Technology: 22nm
Max Frequency: Unknown
Cores: 0 cores
Altivec: Yes
L1i Size: 32KB (640KB Total)
L1d Size: 64KB (1.25MB Total)
L2 Size: 512KB (10MB Total)
L3 Size: 8MB (160MB Total)
Peak Performance: Unknown
==147126==
==147126== HEAP SUMMARY:
==147126== in use at exit: 2,676,735 bytes in 2,060 blocks
==147126== total heap usage: 6,243 allocs, 4,183 frees, 4,295,783 bytes allocated
==147126==
==147126== LEAK SUMMARY:
==147126== definitely lost: 2,648,433 bytes in 659 blocks
==147126== indirectly lost: 28,302 bytes in 1,401 blocks
==147126== possibly lost: 0 bytes in 0 blocks
==147126== still reachable: 0 bytes in 0 blocks
==147126== suppressed: 0 bytes in 0 blocks
==147126== Rerun with --leak-check=full to see details of leaked memory
==147126==
==147126== Use --track-origins=yes to see where uninitialised values come from
==147126== For lists of detected and suppressed errors, rerun with: -s
==147126== ERROR SUMMARY: 2880 errors from 3 contexts (suppressed: 0 from 0)
Everything should be working now.
The problem was caused due to virtualization. Like in x86, Linux also exports less information via /sys
, which can fool cpufetch into very weird behaviors. I have fixed it to protect it against this situation. Additionally, I have added support for:
/proc
So the output is much better now. Please let me know if you find any issues with the last patches (I have merged everything into master).
Yes, it looks better - no crash and saner results.
Still valgrind reports Conditional jump or move depends on uninitialised value(s)
- not sure if that is a false positive, but it looks like not to be...
Thanks for the info, it wasn't a false positive. I have fixed it in the last commit. I'm closing the issue and marking this as completed, feel free to open another one if you have further comments.
As always, thanks for your suggestions!
IBM POWER8, Debian testing, gcc version 12.2.0
HTH
PS. Just checked that latest git compiles, but does not work: (maybe that is related to #153).
valgrind says: