escargot
escargot copied to clipboard
[Debugger] Issues
Escargot (please complete the following information):
- OS: Ubuntu 22.04
- Revision : 1982e20 (latest version)
Describe the bug
1. ~Get crashed when running a large-scale code~ [Fixed]
Debugger get crashed when running for a large-scaled source code. To reproduce the error, run web-tooling-benchmark source as below.
./escargot --start-debug-server test/web-tooling-benchmark/dist/cli.js # start debugger server for web-tooling-benchmark
./tools/debugger/debugger.py # run debugger tool
A crash occurred as follow
Connecting to: localhost:6501
Connection created!!!
Traceback (most recent call last):
File "/usr/lib/python3.8/encodings/utf_16_le.py", line 16, in decode
return codecs.utf_16_le_decode(input, errors, True)
TypeError: don't know how to handle UnicodeDecodeError in error callback
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "./debugger.py", line 293, in <module>
main()
File "./debugger.py", line 279, in main
result = debugger.process_messages()
File "/escargot/tools/debugger/debugger_core.py", line 398, in process_messages
result = self._parse_source(data)
File "/escargot/tools/debugger/debugger_core.py", line 865, in _parse_source
source += self.decode16(data[1:])
File "/escargot/tools/debugger/debugger_core.py", line 369, in decode16
return string.decode("UTF-16LE" if self.little_endian else "UTF-16BE", "namereplace")
TypeError: decoding with 'UTF-16LE' codec failed (TypeError: don't know how to handle UnicodeDecodeError in error callback)
2. Debugger for multiple processes/threads
For cases when multiple processes or threads are running (e.g. WebWorker) Could debugger and vscode-extension still support these cases? If not, what should we do more to provide debugging for multiple of Escargot instances?
Please check #1300 Note: the test stops when it runs the third test even without debugger for me.
@zherczeg Thank you for the quick patch! I'll try other apps to check if there are other issues in the debugger
the test stops when it runs the third test even without debugger for me.
What did you mean above? Running web-tooling-benchmark failed even without debugger?
@zherczeg I updated a new issue about debugger (please see the second one about multple processes/threads). Would you please check it?
- Multi process support.
The debugger uses TCP/IP for communication, and the port can be set. However, the port is currently not passed: https://github.com/Samsung/escargot/blob/master/src/shell/Shell.cpp#L1090
This should be easy to change.
In the python debugger, the port can be set with --address
option:
https://github.com/Samsung/escargot/blob/master/tools/debugger/debugger_core.py#L136
In vscode extension, the port can be set in launch.json
. The readme describes this:
https://github.com/Samsung/escargot-vscode-extension/blob/master/README.md
The summary is, that as long as each process creates a different tcp/ip port for communication, multiple processes can be debugged at the same time.
- Multi thread support.
Unfortunately the debugger is not created with multi-threading in mind. It uses a single channel (tcp stream) for communication. If each thread uses a different socket, this should not cause any problem, since each context has an own debugger: https://github.com/Samsung/escargot/blob/master/src/runtime/Context.h#L384
However, if we would want to use a single socket for communication, that would be a challenging task. We should interleave the messages for different threads, and we need to know which thread is running, and which one is stopped.
What do you think? How Escargot does support multithreading? Does each worker have its own escargot instance?
@zherczeg Thanks for the quick reply!
The current Escargot is essentially a single-process/thread engine, not employing multi-process/thread explicitly.
However, in reality, third-party projects such as lwnode have already adopted a multi-process architecture.
It appears that lwnode utilizes extra processes through the Worker
feature, with each process assigned one Escargot instance. I will look into this further and provide a summary at a later time.
In my opinion, we need to enhance the Escargot debugger for multi-process cases; (currently, I think that multi-thread support is unnecessary because there is no use case yet for this).
This is not an urgent issue, so I will inform you once everything becomes clear. Thank you!
No problem. I think the key issue for multi process systems is finding / enumerating available socket ports. Each process should be able to automatically find a port where they can listen, and clients should be able to enumerate these ports to find which escargot they want to connect. There are many ways to do this, and we can discuss which one is preferred.