JavaScript heap out of memory with AbstractEventLoop and call_soon_threadsafe
- Dominant language
- Python
- Stars
- 15.6k
- Forks
- 1.8k
- Avg merge
- 12h 13m
- Merged PRs (30d)
- 52
Description
Hello I run into a memory problem with Pyright. here is the description
**Describe the bug**
Fatal Error with OOMFailure :
```
<--- Last few GCs --->
[58852:0x17c27260] 625424 ms: Mark-Compact 4042.9 (4129.2) -> 4027.0 (4129.2) MB, 2227.44 / 0.00 ms (average mu = 0.085, current mu = 0.007) allocation failure; scavenge might not succeed
[58852:0x17c27260] 627617 ms: Mark-Compact 4042.9 (4129.2) -> 4027.2 (4129.4) MB, 2173.88 / 0.00 ms (average mu = 0.048, current mu = 0.009) allocation failure; scavenge might not succeed
<--- JS stacktrace --->
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
----- Native stack trace -----
1: 0xca5430 node::Abort() [/usr/local/bin/node]
2: 0xb7807d [/usr/local/bin/node]
3: 0xeca0b0 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [/usr/local/bin/node]
4: 0xeca397 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [/usr/local/bin/node]
5: 0x10dc0e5 [/usr/local/bin/node]
6: 0x10dc674 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [/usr/local/bin/node]
7: 0x10f3564 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::internal::GarbageCollectionReason, char const*) [/usr/local/bin/node]
8: 0x10f3d7c v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]
9: 0x10ca081 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
10: 0x10cb215 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/local/bin/node]
11: 0x10a8866 v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/usr/local/bin/node]
12: 0x15035f6 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/usr/local/bin/node]
13: 0x716ee6e99ef6
```
Minimal code to reproduce
```
from asyncio import AbstractEventLoop
def io_bound_method() -> None:
pass
async def do_something_with_loop(loop: AbstractEventLoop) -> None:
delay = 5
_ = loop.call_soon_threadsafe(loop.call_later, delay, loop.run_in_executor, None, io_bound_method)
```
Python version : 3.13.5
pyright versions : 1.1.403 and 1.1.400
pyright configuration :
```
pythonVersion = "3.13"
root = "src"
strictDictionaryInference = true
strictListInference = true
strictSetInference = true
strictParameterNoneValue = true
analyzeUnannotatedFunctions = true
deprecateTypingAliases = true
reportArgumentType = "warning"
reportOptionalMemberAccess = "warning"
reportAssignmentType = "warning"
reportOptionalSubscript = "warning"
reportAttributeAccessIssue = "error"
reportMissingModuleSource = "error"
reportIncompatibleMethodOverride = "warning"
reportMissingImports = "error"
reportImportCycles = "error"
reportUnusedImport = "error"
reportUnusedFunction = "error"
reportUnusedClass = "error"
reportUnusedVariable = "error"
reportDuplicateImport = "error"
reportUntypedFunctionDecorator = "warning"
reportUntypedClassDecorator = "warning"
reportUntypedBaseClass = "error"
reportUntypedNamedTuple = "error"
reportConstantRedefinition = "error"
reportPrivateUsage = "error"
reportWildcardImportFromLibrary = "error"
reportOptionalOperand = "warning"
reportInconsistentConstructor = "error"
reportUninitializedInstanceVariable = "error"
reportUnknownParameterType = "warning"
reportUnknownArgumentType = "warning"
reportUnknownLambdaType = "warning"
reportUnknownVariableType = "warning"
reportUnknownMemberType = "warning"
reportMissingParameterType = "warning"
reportMissingTypeArgument = "warning"
reportMissingTypeStubs = "warning"
reportDeprecated = "warning"
reportUnnecessaryIsInstance = "warning"
reportCallIssue = "warning"
reportUnnecessaryCast = "error"
reportUnnecessaryComparison = "warning"
reportUnnecessaryContains = "error"
reportAssertAlwaysTrue = "error"
reportImplicitStringConcatenation = "error"
reportUnusedCallResult = "error"
reportUnusedCoroutine = "error"
reportUnusedExcept = "error"
reportMatchNotExhaustive = "error"
reportSelfClsParameterName = "error"
reportUnusedExpression = "error"
reportImplicitOverride = "warning"
reportMissingSuperCall = "warning"
reportPropertyTypeMismatch = "error"
reportCallInDefaultInitializer = "error"
reportShadowedImports = "error"
reportUnnecessaryTypeIgnoreComment = "error"
enableReachabilityAnalysis = true
pythonPlatform = "Linux"
typeCheckingMode = "strict"
```
Contributor guide
Research direction
Start by running the supplied Python snippet with Pyright 1.1.403 and Python 3.13, then compare it with 1.1.400 while monitoring Node.js heap use. Trace the AbstractEventLoop and call_soon_threadsafe handling implicated by the reproduction; done means the minimal case no longer grows to a JavaScript OOM and a regression check covers it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100