-
Notifications
You must be signed in to change notification settings - Fork 54
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
Linux GETTID
syscall problem on OpenWrt
#98
Comments
@XuefengHuang, could you please test this on your OpenWrt install? |
Sure! I get the same exception on TL-WDR3600 OpenWrt router.
|
It seems that OpenWrt doesn't have
Ubuntu:
|
OK, that's interesting. Can you check the contents of the procfs directory for a running sandbox and see if it contains anything in its |
On OpenWrt, the pid is the same as thread id. If I change this line to |
Hmmm.
While this runs, |
Yes, it has two threads. This link is helpful to explain why |
That's one relatively deep issue it seems. Their observation is that Python's However, let's consider a comprehensive fix for this later (if at all --- @python's bug tracker has just too many The easy patch I would propose is this: Just report the total CPU time as the thread's CPU time for now. This errs on the safe side in that it reports a higher number than the actual consumption was. A not much more difficult way to work around the
Then, when (In the long run, my bet would be we should phase out |
@XuefengHuang, how is this progressing? |
I tried to use Python + I also tried to update OpenWrt firmware from Barrier Breaker 14.07 to Chaos Calmer15.05 to see whether |
I can imagine that the proposed fix for However, I think you should be OK just patching (Edit: Fixed linked line number.) |
I dug through However, 25c25,31
< libc = ctypes.CDLL(ctypes.util.find_library("c"))
---
> path_to_libc = ctypes.util.find_library("c")
> if path_to_libc is None:
> # `find_library` failed to find `libc`. Use the hardcoded location
> # valid on OpenWrt.
> path_to_libc = "/lib/libc.so.0"
> libc = ctypes.CDLL(path_to_libc) This makes |
Yes, I also can find |
If you |
I tried
|
Very interesting. I do the precise same thing on OpenWrt-x86, and it works. So we're back to "patch out thread accounting", I guess... |
Since this issue (SeattleTestbed/repy_v2#98), we decide to patch out thread accounting.
Since this issue (SeattleTestbed/repy_v2#98), we decide to patch out thread accounting.
Confirming your negative result on my TP-Link MR3020 (MIPS 32-bit) running a custom Chaos Calmer image. However, I started to think more about how Relevant header file reference:
We need to hardcode the path to |
For reference, you can hardcode the 25c25,31
< libc = ctypes.CDLL(ctypes.util.find_library("c"))
---
> path_to_libc = ctypes.util.find_library("c")
> if path_to_libc is None:
> # `find_library` failed. Use the hardcoded location
> # valid on OpenWrt.
> path_to_libc = "/lib/libc.so.0"
> libc = ctypes.CDLL(path_to_libc)
> |
This commit fixes an issue with the GETTID syscall on MIPS-based systems such as most of our OpenWrt routers. At the same time, it *creates* an issue on non-x86 and non-MIPS systems, as I don't know and can't test the GETTID for, say, ARMs right now. A friendly TODO comment points out this situation.
This is a follow-up commit to 643b912 which fixed SeattleTestbed#98 (GETTID on MIPS) but broke it for ARMs at the same time. GETTID's syscall number on ARM is identical with x86_32's, or so my testing on a Raspberry Pi Model B Rev 2 with BCM2835 SoC with an ARM CPU core indicates. This commit also adds raising an exception to signal that we have no GETTID number in case we are running on a platform other than x86_32/64, MIPS, or ARM.
I saw this exception running RepyV2 code in a vessel on Guilherme Martin's WNDR3800 OpenWrt router. My program calls
getresources()
. Thenlinux_api.py
tries to read the current task's CPU consumption, but the_get_current_thread_id()
call returns-1
. This leadsget_current_thread_cpu_time()
into a non-existing dir, crashing the Repy program.The text was updated successfully, but these errors were encountered: