Getting a backtrace out of the sandbox
Hi everyone, I'm using the pypy sandbox, with a slightly modified pypy_interact.py script. Basically, I'm starting pypy-c with a '-c "from foo import bar\nbar()' command line argument instead of running a script directly. After that, I do sandproc.communicate("") to get the result of the script. Now, this all works fine. I only have a problem if there's a problem in the sandboxed script. If there's an exception, the only thing I get is a
OSError: the sandboxed subprocess exited with code 1
Is there any way of actually getting the backtrace? Thanks a lot, Lukas
Hi! As far as I know, there is no built-in way, but you can catch all exceptions and send them to the parent process in the same way you send the result - this is what we do for our sandbox usecase. 2015-06-05 4:03 GMT+03:00 Lukas Barth <lists@tinloaf.de>:
Hi everyone,
I'm using the pypy sandbox, with a slightly modified pypy_interact.py script. Basically, I'm starting pypy-c with a '-c "from foo import bar\nbar()' command line argument instead of running a script directly. After that, I do sandproc.communicate("") to get the result of the script.
Now, this all works fine. I only have a problem if there's a problem in the sandboxed script. If there's an exception, the only thing I get is a
OSError: the sandboxed subprocess exited with code 1
Is there any way of actually getting the backtrace?
Thanks a lot,
Lukas _______________________________________________ pypy-dev mailing list pypy-dev@python.org https://mail.python.org/mailman/listinfo/pypy-dev
Hi, On 5 June 2015 at 09:22, Костя Лопухин <kostia.lopuhin@gmail.com> wrote:
As far as I know, there is no built-in way, but you can catch all exceptions and send them to the parent process in the same way you send the result - this is what we do for our sandbox usecase.
The subprocess should print the exception to it captured stderr, which the parent reads and returns in communicate(), no? Maybe I'm missing something. A bientôt, Armin.
Yes, indeed, this is the easiest way, sorry for confusion! We process exception inside the sandbox in order to fix line numbers and remove some frames, so that information corresponds to what is seen by the author of the script - this is slightly easier to do inside the sandbox (no need to parse anything). 2015-06-05 10:59 GMT+03:00 Armin Rigo <arigo@tunes.org>:
Hi,
On 5 June 2015 at 09:22, Костя Лопухин <kostia.lopuhin@gmail.com> wrote:
As far as I know, there is no built-in way, but you can catch all exceptions and send them to the parent process in the same way you send the result - this is what we do for our sandbox usecase.
The subprocess should print the exception to it captured stderr, which the parent reads and returns in communicate(), no? Maybe I'm missing something.
A bientôt,
Armin.
Hi Kostia, On 5 June 2015 at 11:31, Костя Лопухин <kostia.lopuhin@gmail.com> wrote:
Yes, indeed, this is the easiest way, sorry for confusion! We process exception inside the sandbox in order to fix line numbers and remove some frames, so that information corresponds to what is seen by the author of the script - this is slightly easier to do inside the sandbox (no need to parse anything).
Ok, I see! Thanks for the explanation. Armin
participants (3)
-
Armin Rigo
-
Lukas Barth
-
Костя Лопухин