gptscript-ai / desktop

MIT License
19 stars 13 forks source link

JavaScript heap out of memory error when trying to stream a large file. #265

Closed sangee2004 closed 6 days ago

sangee2004 commented 3 weeks ago

Electron build - bf86f18e1

Steps to reproduce the problem:

  1. Chat with Tildy
  2. Go to "Manage workspace" and add this file myjson.json
  3. In chat message ask to read this file.

When the chat response starts streaming , app quits and following out of memory error errors are seen in the terminal:

<--- JS stacktrace --->

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
----- Native stack trace -----

 1: 0x114cd30f0 node::OnFatalError(char const*, char const*) [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 2: 0x10f16dc20 _$LT$font_types..tag..Tag$u20$as$u20$core..cmp..PartialEq$LT$$u5b$u8$u3b$$u20$4$u5d$$GT$$GT$::eq::hd4676fde7a82a4e1 [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 3: 0x10f16dbb4 _$LT$font_types..tag..Tag$u20$as$u20$core..cmp..PartialEq$LT$$u5b$u8$u3b$$u20$4$u5d$$GT$$GT$::eq::hd4676fde7a82a4e1 [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 4: 0x10f32b950 v8::CppHeap::wrapper_descriptor() const [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 5: 0x10f30b578 v8::CppHeap::wrapper_descriptor() const [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 6: 0x10df04098 uv_tcp_simultaneous_accepts [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 7: 0x10f61c10c v8::Platform::SystemClockTimeMillis() [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 8: 0x10f187d54 v8::String::Utf8Length(v8::Isolate*) const [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
 9: 0x114ca9740 node::Buffer::New(v8::Isolate*, char*, unsigned long) [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
10: 0x157e10794 
11: 0x150b91a60 
12: 0x150a9c498 
13: 0x150aa1b04 
14: 0x150cb63c0 
15: 0x150a064ec 
16: 0x150cabc38 
17: 0x15090ecac 
18: 0x15042f094 
19: 0x150cb65bc 
20: 0x150b92278 
21: 0x15066cf80 
22: 0x150d7ed2c 
23: 0x150a99c30 
24: 0x157e0b848 
25: 0x157e0b494 
26: 0x10f28b98c v8::Unwinder::PCIsInV8(unsigned long, v8::MemoryRange const*, void*) [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
27: 0x10f186608 v8::Function::Call(v8::Local<v8::Context>, v8::Local<v8::Value>, int, v8::Local<v8::Value>*) [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
28: 0x114c22bc8 node::CallbackScope::~CallbackScope() [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
29: 0x114c2e04c node::EmitAsyncDestroy(node::Environment*, node::async_context) [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
30: 0x114dc71e4 node::PromiseRejectCallback(v8::PromiseRejectMessage) [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
31: 0x114dc72b8 node::PromiseRejectCallback(v8::PromiseRejectMessage) [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
32: 0x114dc7610 node::PromiseRejectCallback(v8::PromiseRejectMessage) [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
33: 0x114dcb9e8 node::PromiseRejectCallback(v8::PromiseRejectMessage) [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
34: 0x114dcc284 node::PromiseRejectCallback(v8::PromiseRejectMessage) [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
35: 0x10df529d8 uv_signal_stop [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
36: 0x10df51f1c uv_signal_stop [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
37: 0x10df58ffc uv_free_interface_addresses [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
38: 0x10df48974 uv_run [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
39: 0x10e0f0128 node::FreeArrayBufferAllocator(node::ArrayBufferAllocator*) [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
40: 0x1112a5398 std::sys::pal::unix::os::errno::h9b4b6e1b7af28e15 [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
41: 0x1112c54e8 std::sys::pal::unix::os::errno::h9b4b6e1b7af28e15 [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
42: 0x11130d12c std::process::id::hb9fbed0f3f7b0c03 [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
43: 0x10debf8b8  [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
44: 0x11130c1c8 std::process::id::hb9fbed0f3f7b0c03 [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
45: 0x1833d79dc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
46: 0x1833d7970 __CFRunLoopDoSource0 [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
47: 0x1833d76e0 __CFRunLoopDoSources0 [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
48: 0x1833d62d0 __CFRunLoopRun [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
49: 0x1833d593c CFRunLoopRunSpecific [/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation]
50: 0x18d99e448 RunCurrentEventLoopInMode [/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox]
51: 0x18d99e284 ReceiveNextEventCommon [/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox]
52: 0x18d99dfdc _BlockUntilNextEventMatchingListInModeWithFilter [/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox]
53: 0x186bb4ed0 _DPSNextEvent [/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit]
54: 0x18739feec -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] [/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit]
55: 0x186ba837c -[NSApplication run] [/System/Library/Frameworks/AppKit.framework/Versions/C/AppKit]
56: 0x11130da20 std::process::id::hb9fbed0f3f7b0c03 [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
57: 0x11130bb88 std::process::id::hb9fbed0f3f7b0c03 [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
58: 0x1112c5dd4 std::sys::pal::unix::os::errno::h9b4b6e1b7af28e15 [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
59: 0x11128c7c4 std::sys::pal::unix::os::errno::h9b4b6e1b7af28e15 [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
60: 0x110461928 v8::internal::compiler::CompilationDependencies::FieldTypeDependencyOffTheRecord(v8::internal::compiler::MapRef, v8::internal::compiler::MapRef, v8::internal::InternalIndex, v8::internal::compiler::ObjectRef) const [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
61: 0x110462fcc v8::internal::compiler::CompilationDependencies::FieldTypeDependencyOffTheRecord(v8::internal::compiler::MapRef, v8::internal::compiler::MapRef, v8::internal::InternalIndex, v8::internal::compiler::ObjectRef) const [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
62: 0x11045f86c v8::internal::compiler::CompilationDependencies::FieldTypeDependencyOffTheRecord(v8::internal::compiler::MapRef, v8::internal::compiler::MapRef, v8::internal::InternalIndex, v8::internal::compiler::ObjectRef) const [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
63: 0x10e28f894 v8::CodeEvent::GetScriptLine() [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
64: 0x10e290b98 v8::CodeEvent::GetScriptLine() [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
65: 0x10e29074c v8::CodeEvent::GetScriptLine() [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
66: 0x10e28f09c v8::CodeEvent::GetScriptLine() [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
67: 0x10e28f300 v8::CodeEvent::GetScriptLine() [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
68: 0x10df596cc ElectronMain [/Users/sangeethahariharan/acorn/desktop/node_modules/electron/dist/Electron.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Electron Framework]
69: 0x182f790e0 start [/usr/lib/dyld]
/Users/sangeethahariharan/acorn/deskto

Note: I was running the app in dev mode when I met with this issue.

cjellick commented 2 weeks ago

@g-linville im assigning you a whole suite of bugs that result in a context blowout. Im not sure what we'll do with these, so lets chat before you know them out

cjellick commented 1 week ago

cc @thedadams - same thing...another oom

cjellick commented 1 week ago

No more OOM, but #108 is still present. Since we have a bug for that, im kicking this bug to testing

sangee2004 commented 6 days ago

Tested with a66cd29e

OMM erros is not seen when tring to work with very large files.