Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: segfault when getting memory info on M1 #816

Closed
jqnatividad opened this issue Aug 21, 2022 · 8 comments · Fixed by #828
Closed

BUG: segfault when getting memory info on M1 #816

jqnatividad opened this issue Aug 21, 2022 · 8 comments · Fixed by #828

Comments

@jqnatividad
Copy link

jqnatividad commented Aug 21, 2022

This code segfaults on sysinfo 0.25.3. It worked without issues previously on earlier versions of sysinfo:

    const MEMORY_LIMITED_BUFFER: u64 = 100 * 1_000_000; // 100 MB

    let mem_limited_buffer = if System::IS_SUPPORTED {
         let mut sys = System::new_all();
         sys.refresh_memory();
         (sys.total_memory() * 1000) / 10 // 10 percent of total memory
     } else {
         MEMORY_LIMITED_BUFFER
     };
jqnatividad added a commit to dathere/qsv that referenced this issue Aug 21, 2022
as it was causing a segfault on `extsort` on macOS running on Apple Silicon

see GuillaumeGomez/sysinfo#816
@GuillaumeGomez
Copy link
Owner

Thanks for the report! Since I don't have a mac M1 myself, I'll need someone else with one to either try to fix it or provide a lot more information. Luckily, there weren't many PRs:

Can you provide information from a memory tool so we can see which part of the code is causing this new bug?

@jqnatividad
Copy link
Author

Hi @GuillaumeGomez , would love to provide the information you need.

I know you said you don't have access to a mac M1, but do you have a specific memory tool in mind?

Alternatively, is there a way I can build my project to get the information you need?

FYI, I use sysinfo to check for available memory with the qsv extsort command here, and to do a hardware survey here.

@GuillaumeGomez
Copy link
Owner

I don't know which tools exist on mac. The goal is to get the stacktrace and possibly which buffer was wrongly accessed so by default I'd say valgrind but any tool that can get such information is just as good.

@jqnatividad
Copy link
Author

Hmmm... it's not segfaulting anymore @GuillaumeGomez . I added tests in my CI to exercise sysinfo and its now working as expected.
When I filed the report, I can reproduce it reliably just by using 0.25.3 and checking for memory....
But now, it's working OK

@jqnatividad
Copy link
Author

Oooppsss.... I take that back.
Ran the test without doing cargo update. It's still segfaulting... continuing to investigate...

@schell
Copy link

schell commented Aug 23, 2022

I just git bisect'd a segfault on my M1 down to bumping sysinfo to 0.25.3. This is the relevant crashed thread in my crash report:

Thread 14 Crashed::  Dispatch queue: com.apple.root.default-qos.overcommit
0   libobjc.A.dylib               	       0x1b39989c0 objc_release + 16
1   CoreFoundation                	       0x1b3b86370 cow_cleanup + 172
2   CoreFoundation                	       0x1b3b86274 -[__NSDictionaryM dealloc] + 148
3   IOKit                         	       0x1b65d4208 __IOHIDEventSystemClientIntRelease + 220
4   IOKit                         	       0x1b65d0f3c _IOHIDObjectRetainCount + 416
5   libdispatch.dylib             	       0x1b394c1b4 _dispatch_client_callout + 20
6   libdispatch.dylib             	       0x1b395da04 _dispatch_root_queue_drain + 680
7   libdispatch.dylib             	       0x1b395e104 _dispatch_worker_thread2 + 164
8   libsystem_pthread.dylib       	       0x1b3b0c324 _pthread_wqthread + 228
9   libsystem_pthread.dylib       	       0x1b3b0b080 start_wqthread + 8

@jqnatividad
Copy link
Author

Just wanted to confirm that this is still a problem with sysinfo v 0.26.0...

@GuillaumeGomez
Copy link
Owner

Yes, no changes on my end to fix this. @lqd nicely proposed to take a look whenever he has time for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants