Skip to content
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

[Debugger] Issues #1298

Open
clover2123 opened this issue Jan 8, 2024 · 6 comments
Open

[Debugger] Issues #1298

clover2123 opened this issue Jan 8, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@clover2123
Copy link
Contributor

clover2123 commented Jan 8, 2024

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?

@clover2123 clover2123 added the bug Something isn't working label Jan 8, 2024
@zherczeg
Copy link
Contributor

Please check #1300
Note: the test stops when it runs the third test even without debugger for me.

@clover2123
Copy link
Contributor Author

@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?

@clover2123 clover2123 changed the title [Debugger] Crash for large-scale code [Debugger] Issues Apr 23, 2024
@clover2123
Copy link
Contributor Author

@zherczeg
I updated a new issue about debugger (please see the second one about multple processes/threads).
Would you please check it?

@zherczeg
Copy link
Contributor

  • 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?

@clover2123
Copy link
Contributor Author

@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!

@zherczeg
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants