-
Notifications
You must be signed in to change notification settings - Fork 525
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
100% cpu usage! #81
Comments
Can't reproduce this, do you have more details? What exact process is causing this load ? |
Confirm. Process: /usr/local/bin/P4wnP1_service. 100% load only if aloa connected to existing wi-fi network |
Me too. /usr/local/bin/P4wnP1_service 100% load when wlan0 is working on client mode.(connected to my wifi) |
I get extremely high usage as soon as WiFi connects to my WiFi AP, often leading to over-current and shutdown. (The board becomes hot to the touch.) Mostly consumption comes from P4wnP1_service; briefly I saw a few others, like apt-related processes. So I tried to block Internet from my router. But the same thing happens. In another community, I learned that an older driver for a commonly used WiFi chip was faulty, leading to this kind of behavior. (The driver was fixed in mainstream Debian although not in the custom distro we were using.) But there, the consuming processes are directly related to data transmission in the kernel; extreme CPU consumption occurs only during intensive transmission (e.g., |
Going to investigate this, thx for reporting |
Did it fixed? (I have same issue) |
Same here. |
Some tools as wifite or same can't work properly and just kills RPi |
Same here - Nano Pi - with an without WIFI connection - 100% CPU with P4wnP1_service. Using the Nano Pi is close to impossible - very slow SSH... due to the high load... |
Issue could be reproduced:
In result The root cause has to be investigated using remote debugging for the P4wnP1_service (over USB, to avoid WiFi interference). This is likely caused by a non blocking loop for sub-process monitoring (wpa_supplicant, dhcpcd, hostapd ...) and maybe could be found using pure code audit. |
The root cause of the problem was found. Here are some notes on how it was approached, which are meant to be read by the new maintainer of this repo. Cause of the error is here:
The code above is a function attached to the structure excursus 1: on object oriented programming in Go:In Go this "attached function" could be compared to a member function of a class-based object, where the structure To sum up: The code snippet above shows the public member-function excursus 2: Interfaces in goIn Go, interfaces could be declared, but a structure (rember, this could roughly be compared to a class) implementing an interface isn't marked with special syntax (like f.e. In this case, the method This interface is pretty common in Go's standard packages and could be compared to a C-style write looking like this:
The C-function would accept a binary buffer The Go function is very similar, it accepts a variable length byte array (slice) named the bugAs highlighted above, the
The code doesn't check further conditions of the process' output, once it knows that the AP is disabled or enabled (indicated by As mentioned earlier, this interface is common and in this case it is used to process low-level functionality (writes to stdout of a child process). Returning a successful write with a length 0 to the caller, means the caller still has output data to write in its queue - no matter how often the function is called, the caller never manages to write more than 0 bytes. The fix is pretty simple, the return value of the "early out" has to be changed from Note: |
How this bug has been debuggedThe recommended solution for remote debugging of Go code is to use Delve. Unfortunately Delve only support 64bit architectures at time of this writing, which doesn't get us very far on a Raspberry Pi 0. So I opted to use Another issue with debugging of P4wnP1 ALOA's systemd service binary So the idea here was to build a version of Step 1 - cross compile P4wnP1_service from github repo source and copy it to P4wnP1 using USB ethernetI assume that P4wnP1 is accessible on
Step 2 - SSH into P4wnP1, kill the old service and start a gdb session with the new oneAfter bringing up a SSH connection to P4wnP1 via USB with
step 3 - Trigger the bug using the web clientThe bug occurs once P4wnP1 successfully connects to an existing WiFi AP in STA (or failover) mode. We configure P4wnP1 to do so, using the webclient which should be reachable on Once this is done, an addtional SSH session could be used to inspect CPU load f.e. with a tool like step 4 - Examining the root causeOnce CPU load is at 100 percent, we could head bake to the gdb session and send a soft interrupt to the attached
After the SIGINT was send to the process, we are back in gdb's interface. The
This was a "lucky hit" as we did no interactive debugging at all, but it occurs almost everytime if the process is interrupted like this. This alone is indication of this being cause for the high CPU load (under normaly circumstances the `Write call should happen in-frequently and last only for a very short time - which means chances to spot this call here should be very low). Additionally, there should be no processing of hostapd stdout at all, as P4wnP1 is running in STA mode which means the hostapd process gets terminated in this case. From this point on, the search for the root cause was done in code again, where
nice to knowBefore fixing the bug, it was confirmed by adding some test output to the "early out" part of the
In result the following was printed to stdout by the
I assume this is caused by an output queue in Go's low level implementation for sub processes, which tries to flush its output endlessly (but can't because the Write() always returns 0 bytes written) or maybe by some of my own code. In the end it doesn't matter as the simple fix described above brings CPU load back below 2 percent and the debug output |
I check cpu usage with htop, and it always 100%. Any solution?
The text was updated successfully, but these errors were encountered: