Spaces:
Running on Zero
Running on Zero
Upload sandbox.py with huggingface_hub
Browse files- sandbox.py +13 -14
sandbox.py
CHANGED
|
@@ -146,20 +146,19 @@ def _preexec():
|
|
| 146 |
resource.setrlimit(resource.RLIMIT_AS, (mem, mem))
|
| 147 |
resource.setrlimit(resource.RLIMIT_FSIZE, (64 * 1024 * 1024, 64 * 1024 * 1024))
|
| 148 |
|
| 149 |
-
# RLIMIT_NPROC
|
| 150 |
-
#
|
| 151 |
-
#
|
| 152 |
-
#
|
| 153 |
-
#
|
| 154 |
-
#
|
| 155 |
-
#
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
pass # not fatal - CPU time, memory, and the wall-clock kill still apply
|
| 163 |
# New process group so a timeout kill takes any children with it.
|
| 164 |
os.setsid()
|
| 165 |
|
|
|
|
| 146 |
resource.setrlimit(resource.RLIMIT_AS, (mem, mem))
|
| 147 |
resource.setrlimit(resource.RLIMIT_FSIZE, (64 * 1024 * 1024, 64 * 1024 * 1024))
|
| 148 |
|
| 149 |
+
# RLIMIT_NPROC is deliberately NOT set.
|
| 150 |
+
#
|
| 151 |
+
# It counts processes per *user*, not per process tree, so any cap here also
|
| 152 |
+
# counts every thread the host container already runs under this uid. In
|
| 153 |
+
# practice that starved the compilers of threads:
|
| 154 |
+
# rustc: Os { code: 11, kind: WouldBlock, ... }
|
| 155 |
+
# g++: cannot execute cc1plus: vfork: Resource temporarily unavailable
|
| 156 |
+
# Both are EAGAIN from the fork itself. Because the limit is shared with
|
| 157 |
+
# processes we did not start and cannot count, any value is either too low
|
| 158 |
+
# to compile or too high to matter - it is not a usable control here.
|
| 159 |
+
#
|
| 160 |
+
# A fork bomb is still bounded by RLIMIT_CPU, RLIMIT_AS, and the wall-clock
|
| 161 |
+
# kill, which terminates the entire process group.
|
|
|
|
| 162 |
# New process group so a timeout kill takes any children with it.
|
| 163 |
os.setsid()
|
| 164 |
|