Giter Club home page Giter Club logo

Comments (6)

RSC-Games avatar RSC-Games commented on August 23, 2024 1

Alright! Sounds good! I'll get to compiling it straight away.

from libcpuid.

RSC-Games avatar RSC-Games commented on August 23, 2024

I know you assigned yourself and you were going to look into it but maybe I can provide some insight. I took the backtrace and found the offending code:

cpuid_main.c:

    /* Update logical and physical CPU counters in system->cpu_types on the last iteration or when purpose is different than previous core */
    if (raw_array->with_affinity && (is_last_item || (is_new_cpu_type && (system->num_cpu_types > 1)))) {
        cpu_type_index   = is_new_cpu_type ? system->num_cpu_types - 2 : system->num_cpu_types - 1;
	copy_affinity_mask(&system->cpu_types[cpu_type_index].affinity_mask, &affinity_mask);  // <-- 
	if (!is_last_item) {
		init_affinity_mask(&affinity_mask);
		set_affinity_mask_bit(logical_cpu, &affinity_mask);
	}
	if (is_apic_supported) {
		system->cpu_types[cpu_type_index].num_cores                = cores_type.instances;
		system->cpu_types[cpu_type_index].l1_instruction_instances = caches_type.instances[L1I];
		system->cpu_types[cpu_type_index].l1_data_instances        = caches_type.instances[L1D];
		system->cpu_types[cpu_type_index].l2_instances             = caches_type.instances[L2];
		system->cpu_types[cpu_type_index].l3_instances             = caches_type.instances[L3];
		system->cpu_types[cpu_type_index].l4_instances             = caches_type.instances[L4];
		if (!is_last_item) {
			core_instances_t_constructor(&cores_type);
			cache_instances_t_constructor(&caches_type);
			update_core_instances(&cores_type, &apic_info);
			update_cache_instances(&caches_type, &apic_info, &id_info, true);
			update_cache_instances(&caches_all,  &apic_info, &id_info, false);
		}
	}
        // Code segment containing SMT recognition removed for smaller snippet.
	prev_package_id = cur_package_id;

Then in libcpuid_util.c:

void copy_affinity_mask(cpu_affinity_mask_t *dest_affinity_mask, cpu_affinity_mask_t *src_affinity_mask)
{
	memcpy(dest_affinity_mask->__bits, src_affinity_mask->__bits, __MASK_SETSIZE);
}

I can't help but wonder why the name of the function in the backtrace says __memcpy_avx_unaligned_erms. Is your CPU AVX-capable or is there something that I'm missing? Because I'm pretty sure Core 2 doesn't support AVX (or SSE4.2 for that matter). That wouldn't cause a segfault though...

Should I run the program on my PC and attempt to extract a backtrace via valgrind or gdb? That may give more insight.

If CPU-related information helps, here's my CPU:

Intel Celeron 900
2.2 GHz
0 MB L3 Cache
1 MB L2 Cache
32 kB L1i Cache
32 kB L1d Cache
1 core, 1 thread (not SMT-capable)
SSE, SSE2, SSE3, SSSE3, MMX
Virtualization not supported.
Locked multiplier, no support for SpeedStep.
No support for Turbo Boost.

from libcpuid.

TheTumultuousUnicornOfDarkness avatar TheTumultuousUnicornOfDarkness commented on August 23, 2024

@RSC-Games do not worry, it is likely bad arguments passed from copy_affinity_mask() to memcpy().

from libcpuid.

TheTumultuousUnicornOfDarkness avatar TheTumultuousUnicornOfDarkness commented on August 23, 2024

Yeah just like I thought: cpu_type_index = is_new_cpu_type ? system->num_cpu_types - 2 : system->num_cpu_types - 1;
cpu_type_index=255 in that case so it is definitely out of bounds.

from libcpuid.

RSC-Games avatar RSC-Games commented on August 23, 2024

So should I compile from source or is a new version available on debian repositories?

from libcpuid.

TheTumultuousUnicornOfDarkness avatar TheTumultuousUnicornOfDarkness commented on August 23, 2024

Conclusion about this segfault: we did not have any single-core CPU using the new raw format in the tests directory, that is why I did not spot this issue during v0.6.0 development. It is a case (rare nowadays) when both is_new_cpu_type and is_last_item are true at the same time (i.e. single-core CPU).
Also, I added your Celeron 900 in database and in tests directory in 6c9798c, so it is the first one now.

So should I compile from source or is a new version available on debian repositories?

Well, this fix will be in next release (v0.6.2?), so I have no idea when it will be fixed in Debian repositories, sorry.
You can still build libcpuid from source, then ensure that you overwrite the previous library (e.g. /usr/lib/x86_64-linux-gnu/libcpuid.so.16.0.0 on Debian amd64).

from libcpuid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.