On Sunday, March 3, 2019 at 12:50:42 PM UTC+1, Jeroen Demeyer wrote:
> But maybe it's not closed *immediately*. It would be interesting to do
> the same experiment with a time.sleep(0.1) or a gc.collect() in the loop.
>
I tried that
sage: for k in range(10000):
....: gp = Gp()
....: gp.read(SAGE_EXTCODE + "/pari/simon/qfsolve.gp")
....: k
....: if k % 1000 == 0:
....: gc.collect()
And indeed this time it worked for the first 3266 loops (instead of just
1800) and then sage crashes with
--------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-4-2a823e1e337d> in <module>()
1 for k in range(Integer(10000)):
2 gp = Gp()
----> 3 gp.read(SAGE_EXTCODE + "/pari/simon/qfsolve.gp")
4 k
5 if k % Integer(1000) == Integer(0):
/home/simon/sage/local/lib/python2.7/site-packages/sage/interfaces/interface
.pyc in read(self, filename)
222 sage: os.unlink(filename)
223 """
--> 224 self.eval(self._read_in_file_command(filename))
225
226 def _read_in_file_command(self, filename):
/home/simon/sage/local/lib/python2.7/site-packages/sage/interfaces/expect.pyc
in eval(self, code, strip, synchronize, locals, allow_use_file,
split_lines, **kwds)
1349 elif split_lines:
1350 return '\n'.join([self._eval_line(L,
allow_use_file=allow_use_file, **kwds)
-> 1351 for L in code.split('\n')
if L != ''])
1352 else:
1353 return self._eval_line(code,
allow_use_file=allow_use_file, **kwds)
/home/simon/sage/local/lib/python2.7/site-packages/sage/interfaces/gp.pyc
in _eval_line(self, line, allow_use_file, wait_for_prompt,
restart_if_needed)
443 a = Expect._eval_line(self, line,
444 allow_use_file=allow_use_file,
--> 445 wait_for_prompt=wait_for_prompt)
446 if a.find("the PARI stack overflows") != -1:
447 verbose("automatically doubling the PARI stack and
re-executing
current input line")
/home/simon/sage/local/lib/python2.7/site-packages/sage/interfaces/expect.pyc
in _eval_line(self, line, allow_use_file, wait_for_prompt,
restart_if_needed)
914 try:
915 if self._expect is None:
--> 916 self._start()
917 E = self._expect
918 try:
/home/simon/sage/local/lib/python2.7/site-packages/sage/interfaces/gp.pyc
in _start(self, alt_message, block_during_init)
241
242 def _start(self, alt_message=None, block_during_init=True):
--> 243 Expect._start(self, alt_message, block_during_init)
244 # disable memory debugging: those warnings can only confuse
our
245 # interface
/home/simon/sage/local/lib/python2.7/site-packages/sage/interfaces/expect.pyc
in _start(self, alt_message, block_during_init)
501 # Work around
https://bugs.python.org/issue1652
502 preexec_fn=lambda:
signal.signal(signal.SIGPIPE, signal.SIG_DFL),
--> 503 quit_string=self._quit_string())
504 except (ExceptionPexpect, pexpect.EOF) as e:
505 # Change pexpect errors to RuntimeError
/home/simon/sage/local/lib/python2.7/site-packages/sage/interfaces/sagespawn.pyx
in sage.interfaces.sagespawn.SageSpawn.__init__
(build/cythonized/sage/interfaces/sagespawn.c:1948)()
63 kwds.setdefault("maxread", 4194304)
64
---> 65 with ContainChildren(silent=True):
66 spawn.__init__(self, *args, **kwds)
67
/home/simon/sage/local/lib/python2.7/site-packages/sage/interfaces/sagespawn.pyx
in sage.interfaces.sagespawn.SageSpawn.__init__
(build/cythonized/sage/interfaces/sagespawn.c:1902)()
64
65 with ContainChildren(silent=True):
---> 66 spawn.__init__(self, *args, **kwds)
67
68 self.delaybeforesend = None
/home/simon/sage/local/lib/python2.7/site-packages/pexpect/pty_spawn.pyc in
__init__(self, command, args, timeout, maxread, searchwindowsize, logfile,
cwd, env, ignore_sighup, echo, preexec_fn, encoding, codec_errors,
dimensions, use_poll)
202 self.name = '<pexpect factory incomplete>'
203 else:
--> 204 self._spawn(command, args, preexec_fn, dimensions)
205 self.use_poll = use_poll
206
/home/simon/sage/local/lib/python2.7/site-packages/pexpect/pty_spawn.pyc in
_spawn(self, command, args, preexec_fn, dimensions)
301
302 self.ptyproc = self._spawnpty(self.args, env=self.env,
--> 303 cwd=self.cwd, **kwargs)
304
305 self.pid = self.ptyproc.pid
/home/simon/sage/local/lib/python2.7/site-packages/sage/interfaces/sagespawn.pyx
in sage.interfaces.sagespawn.SageSpawn._spawnpty
(build/cythonized/sage/interfaces/sagespawn.c:2133)()
80 SagePtyProcess.spawn(...)
81 """
---> 82 ptyproc = SagePtyProcess.spawn(args, **kwds)
83 ptyproc.quit_string = self.quit_string
84 return ptyproc
/home/simon/sage/local/lib/python2.7/site-packages/ptyprocess/ptyprocess.pyc
in spawn(cls, argv, cwd, env, echo, preexec_fn, dimensions)
218
219 if use_native_pty_fork:
--> 220 pid, fd = pty.fork()
221 else:
222 # Use internal fork_pty, for Solaris
/home/simon/sage/local/lib/python2.7/pty.pyc in fork()
106
107 master_fd, slave_fd = openpty()
--> 108 pid = os.fork()
109 if pid == CHILD:
110 # Establish a new session.
OSError: [Errno 11] Resource temporarily unavailable
sage:
^[[35;1R
**********************************************************************
Oops, Sage crashed. We do our best to make it stable, but...
A crash report was automatically generated wdth the following information:
- A verbatim copy of the crash traceback.
- A copy of your input history during this session.
- Data on your current Sage configuration.
It was left in the file named:
'/home/simon/.sage/ipython-5.0.0/Sage_crash_report.txt'
If you can email this file to the developers, the information in it will
help
them in understanding and correcting the problem.
You can mail it to: sage-support at [email protected]
with the subject 'Sage Crash Report'.
If you want to do it now, the following command will work (under Unix):
mail -s 'Sage Crash Report' [email protected] < /home/simon/.
sage/ipython-5.0.0/Sage_crash_report.txt
In your email, please also include information about:
- The operating system under which the crash happened: Linux, macOS, Windows
,
other, and which exact version (for example: Ubuntu 16.04.3, macOS 10.13.2
,
Windows 10 Pro), and whether it is 32-bit or 64-bit;
- How Sage was installed: using pip or conda, from GitHub, as part of
a Docker container, or other, providing more detail if possible;
- How to reproduce the crash: what exact sequence of instructions can one
input to get the same crash? Ideally, find a minimal yet complete sequence
of instructions that yields the crash.
To ensure accurate tracking of this issue, please file a report about it at:
http://trac.sagemath.org
Hit <Enter> to quit (your terminal may close):
--
You received this message because you are subscribed to the Google Groups
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.
***************************************************************************
IPython post-mortem report
{'commit_hash': u'033ab93c7',
'commit_source': 'installation',
'default_encoding': 'UTF-8',
'ipython_path': '/home/simon/sage/local/lib/python2.7/site-packages/IPython',
'ipython_version': '5.8.0',
'os_name': 'posix',
'platform': 'Linux-4.15.0-45-generic-x86_64-with-debian-buster-sid',
'sys_executable': '/home/simon/sage/local/bin/python2',
'sys_platform': 'linux2',
'sys_version': '2.7.15 (default, Feb 25 2019, 11:43:50) \n[GCC 7.3.0]'}
***************************************************************************
***************************************************************************
Crash traceback:
---------------------------------------------------------------------
---------------------------------------------------------------------
error Python 2.7.15: /home/simon/sage/local/bin/python2
Sun Mar 3 13:11:56 2019
A problem occurred executing Python code. Here is the sequence of function
calls leading up to the error, with the most recent (innermost) call last.
/home/simon/sage/src/bin/sage-ipython in <module>()
1 #!/usr/bin/env sage-python23
2 # -*- coding: utf-8 -*-
3 """
4 Sage IPython startup script.
5 """
6
7 # Display startup banner. Do this before anything else to give the user
8 # early feedback that Sage is starting.
9 from sage.misc.banner import banner
10 banner()
11
12 from sage.repl.interpreter import SageTerminalApp
13
14 app = SageTerminalApp.instance()
15 app.initialize()
---> 16 app.start()
global app.start = <bound method SageTerminalApp.start of
<sage.repl.interpreter.SageTerminalApp object at 0x7f44d14f0c90>>
/home/simon/sage/local/lib/python2.7/site-packages/IPython/terminal/ipapp.pyc
in start(self=<sage.repl.interpreter.SageTerminalApp object>)
340 if self.log_level <= logging.INFO: print()
341
342 def _pylab_changed(self, name, old, new):
343 """Replace --pylab='inline' with --pylab='auto'"""
344 if new == 'inline':
345 warnings.warn("'inline' not available as pylab backend, "
346 "using 'auto' instead.")
347 self.pylab = 'auto'
348
349 def start(self):
350 if self.subapp is not None:
351 return self.subapp.start()
352 # perform any prexec steps:
353 if self.interact:
354 self.log.debug("Starting IPython's mainloop...")
--> 355 self.shell.mainloop()
self.shell.mainloop = <bound method
SageTerminalInteractiveShell.mainloop of
<sage.repl.interpreter.SageTerminalInteractiveShell object at 0x7f44cbd4d910>>
356 else:
357 self.log.debug("IPython not interactive...")
358
359 def load_default_config(ipython_dir=None):
360 """Load the default config file from the default ipython_dir.
361
362 This is useful for embedded shells.
363 """
364 if ipython_dir is None:
365 ipython_dir = get_ipython_dir()
366
367 profile_dir = os.path.join(ipython_dir, 'profile_default')
368 app = TerminalIPythonApp()
369 app.config_file_paths.append(profile_dir)
370 app.load_config_file()
/home/simon/sage/local/lib/python2.7/site-packages/IPython/terminal/interactiveshell.pyc
in mainloop(self=<sage.repl.interpreter.SageTerminalInteractiveShell object>,
display_banner=<object object>)
480 if (not self.confirm_exit) \
481 or self.ask_yes_no('Do you really want to exit
([y]/n)?','y','n'):
482 self.ask_exit()
483
484 else:
485 if code:
486 self.run_cell(code, store_history=True)
487
488 def mainloop(self, display_banner=DISPLAY_BANNER_DEPRECATED):
489 # An extra layer of protection in case someone mashing Ctrl-C
breaks
490 # out of our internal code.
491 if display_banner is not DISPLAY_BANNER_DEPRECATED:
492 warn('mainloop `display_banner` argument is deprecated
since IPython 5.0. Call `show_banner()` if needed.', DeprecationWarning,
stacklevel=2)
493 while True:
494 try:
--> 495 self.interact()
self.interact = <bound method SageTerminalInteractiveShell.interact of
<sage.repl.interpreter.SageTerminalInteractiveShell object at 0x7f44cbd4d910>>
496 break
497 except KeyboardInterrupt as e:
498 print("\n%s escaped interact()\n" % type(e).__name__)
499 finally:
500 # An interrupt during the eventloop will mess up the
501 # internal state of the prompt_toolkit library.
502 # Stopping the eventloop fixes this, see
503 # https://github.com/ipython/ipython/pull/9867
504 if hasattr(self, '_eventloop'):
505 self._eventloop.stop()
506
507 _inputhook = None
508 def inputhook(self, context):
509 if self._inputhook is not None:
510 self._inputhook(context)
/home/simon/sage/local/lib/python2.7/site-packages/IPython/terminal/interactiveshell.pyc
in interact(self=<sage.repl.interpreter.SageTerminalInteractiveShell object>,
display_banner=<object object>)
463 # Older version of prompt_toolkit; it's OK to set the
document
464 # directly here.
465 set_doc()
466 self.rl_next_input = None
467
468 def interact(self, display_banner=DISPLAY_BANNER_DEPRECATED):
469
470 if display_banner is not DISPLAY_BANNER_DEPRECATED:
471 warn('interact `display_banner` argument is deprecated
since IPython 5.0. Call `show_banner()` if needed.', DeprecationWarning,
stacklevel=2)
472
473 self.keep_running = True
474 while self.keep_running:
475 print(self.separate_in, end='')
476
477 try:
--> 478 code = self.prompt_for_code()
code = u'for k in range(10000):\n gp = Gp()\n
gp.read(SAGE_EXTCODE + "/pari/simon/qfsolve.gp")\n k\n if k % 1000 ==
0:\n gc.collect()\n '
self.prompt_for_code = <bound method
SageTerminalInteractiveShell.prompt_for_code of
<sage.repl.interpreter.SageTerminalInteractiveShell object at 0x7f44cbd4d910>>
479 except EOFError:
480 if (not self.confirm_exit) \
481 or self.ask_yes_no('Do you really want to exit
([y]/n)?','y','n'):
482 self.ask_exit()
483
484 else:
485 if code:
486 self.run_cell(code, store_history=True)
487
488 def mainloop(self, display_banner=DISPLAY_BANNER_DEPRECATED):
489 # An extra layer of protection in case someone mashing Ctrl-C
breaks
490 # out of our internal code.
491 if display_banner is not DISPLAY_BANNER_DEPRECATED:
492 warn('mainloop `display_banner` argument is deprecated
since IPython 5.0. Call `show_banner()` if needed.', DeprecationWarning,
stacklevel=2)
493 while True:
/home/simon/sage/local/lib/python2.7/site-packages/IPython/terminal/interactiveshell.pyc
in prompt_for_code(self=<sage.repl.interpreter.SageTerminalInteractiveShell
object>)
357
processor=HighlightMatchingBracketProcessor(chars='[](){}'),
358 filter=HasFocus(DEFAULT_BUFFER) & ~IsDone() &
359 Condition(lambda cli:
self.highlight_matching_brackets))],
360 }
361
362 def _update_layout(self):
363 """
364 Ask for a re computation of the application layout, if for
example ,
365 some configuration options have changed.
366 """
367 if self._pt_app:
368 self._pt_app.layout =
create_prompt_layout(**self._layout_options())
369
370 def prompt_for_code(self):
371 document = self.pt_cli.run(
--> 372 pre_run=self.pre_prompt, reset_current_buffer=True)
global pre_run = undefined
self.pre_prompt = <bound method SageTerminalInteractiveShell.pre_prompt
of <sage.repl.interpreter.SageTerminalInteractiveShell object at
0x7f44cbd4d910>>
global reset_current_buffer = undefined
global True = undefined
373 return document.text
374
375 def enable_win_unicode_console(self):
376 if sys.version_info >= (3, 6):
377 # Since PEP 528, Python uses the unicode APIs for the
Windows
378 # console by default, so WUC shouldn't be needed.
379 return
380
381 import win_unicode_console
382
383 if PY3:
384 win_unicode_console.enable()
385 else:
386 # https://github.com/ipython/ipython/issues/9768
387 from win_unicode_console.streams import (TextStreamWrapper,
/home/simon/sage/local/lib/python2.7/site-packages/prompt_toolkit/interface.pyc
in run(self=<prompt_toolkit.interface.CommandLineInterface object>,
reset_current_buffer=True, pre_run=<bound method
SageTerminalInteractiveShell.pre_p...interpreter.SageTerminalInteractiveShell
object>>)
400
401 try:
402 self._is_running = True
403
404 self.on_start.fire()
405 self.reset()
406
407 # Call pre_run.
408 self._pre_run(pre_run)
409
410 # Run eventloop in raw mode.
411 with self.input.raw_mode():
412 self.renderer.request_absolute_cursor_position()
413 self._redraw()
414
--> 415 self.eventloop.run(self.input,
self.create_eventloop_callbacks())
self.eventloop.run = <bound method PosixEventLoop.run of
<prompt_toolkit.eventloop.posix.PosixEventLoop object at 0x7f44c0c52cd0>>
self.input = StdinInput(stdin=<open file '<stdin>', mode 'r' at
0x7f44d3ee10c0>)
self.create_eventloop_callbacks = <bound method
CommandLineInterface.create_eventloop_callbacks of
<prompt_toolkit.interface.CommandLineInterface object at 0x7f44c0c67a90>>
416 finally:
417 # Clean up renderer. (This will leave the alternate screen,
if we use
418 # that.)
419
420 # If exit/abort haven't been called set, but another
exception was
421 # thrown instead for some reason, make sure that we redraw
in exit
422 # mode.
423 if not self.is_done:
424 self._exit_flag = True
425 self._redraw()
426
427 self.renderer.reset()
428 self.on_stop.fire()
429 self._is_running = False
430
/home/simon/sage/local/lib/python2.7/site-packages/prompt_toolkit/eventloop/posix.pyc
in run(self=<prompt_toolkit.eventloop.posix.PosixEventLoop object>,
stdin=StdinInput(stdin=<open file '<stdin>', mode 'r' at 0x7f44d3ee10c0>),
callbacks=<prompt_toolkit.interface._InterfaceEventLoopCallbacks object>)
87 # Quit when the input stream was closed.
88 if stdin_reader.closed:
89 self.stop()
90
91 self.add_reader(stdin, read_from_stdin)
92 self.add_reader(self._schedule_pipe[0], None)
93
94 with ctx:
95 while self._running:
96 # Call inputhook.
97 if self._inputhook_context:
98 with TimeIt() as inputhook_timer:
99 def ready(wait):
100 " True when there is input ready. The
inputhook should return control. "
101 return
self._ready_for_reading(current_timeout[0] if wait else 0) != []
--> 102 self._inputhook_context.call_inputhook(ready)
self._inputhook_context.call_inputhook = <bound method
InputHookContext.call_inputhook of
<prompt_toolkit.eventloop.inputhook.InputHookContext object at 0x7f44c0c67990>>
ready = <function ready at 0x7f436e0e3140>
103 inputhook_duration = inputhook_timer.duration
104 else:
105 inputhook_duration = 0
106
107 # Calculate remaining timeout. (The inputhook consumed
some of the time.)
108 if current_timeout[0] is None:
109 remaining_timeout = None
110 else:
111 remaining_timeout = max(0, current_timeout[0] -
inputhook_duration)
112
113 # Wait until input is ready.
114 fds = self._ready_for_reading(remaining_timeout)
115
116 # When any of the FDs are ready. Call the appropriate
callback.
117 if fds:
/home/simon/sage/local/lib/python2.7/site-packages/prompt_toolkit/eventloop/inputhook.pyc
in call_inputhook(self=<prompt_toolkit.eventloop.inputhook.InputHookContext
object>, input_is_ready_func=<function ready>)
56 File descriptor that will become ready when the event loop
needs to go on.
57 """
58 return self._r
59
60 def call_inputhook(self, input_is_ready_func):
61 """
62 Call the inputhook. (Called by a prompt-toolkit eventloop.)
63 """
64 self._input_is_ready = input_is_ready_func
65
66 # Start thread that activates this pipe when there is input to
process.
67 def thread():
68 input_is_ready_func(wait=True)
69 os.write(self._w, b'x')
70
---> 71 threading.Thread(target=thread).start()
global threading.Thread = <class 'threading.Thread'>
global target = undefined
thread.start = undefined
72
73 # Call inputhook.
74 self.inputhook(self)
75
76 # Flush the read end of the pipe.
77 try:
78 # Before calling 'os.read', call select.select. This is
required
79 # when the gevent monkey patch has been applied. 'os.read'
is never
80 # monkey patched and won't be cooperative, so that would
block all
81 # other select() calls otherwise.
82 # See: http://www.gevent.org/gevent.os.html
83
84 # Note: On Windows, this is apparently not an issue.
85 # However, if we would ever want to add a select
call, it
86 # should use `windll.kernel32.WaitForMultipleObjects`,
/home/simon/sage/local/lib/python2.7/threading.pyc in
start(self=<Thread(Thread-879, initial)>)
721 object's run() method to be invoked in a separate thread of
control.
722
723 This method will raise a RuntimeError if called more than once
on the
724 same thread object.
725
726 """
727 if not self.__initialized:
728 raise RuntimeError("thread.__init__() not called")
729 if self.__started.is_set():
730 raise RuntimeError("threads can only be started once")
731 if __debug__:
732 self._note("%s.start(): starting thread", self)
733 with _active_limbo_lock:
734 _limbo[self] = self
735 try:
--> 736 _start_new_thread(self.__bootstrap, ())
global _start_new_thread = <built-in function start_new_thread>
self.__bootstrap = undefined
737 except Exception:
738 with _active_limbo_lock:
739 del _limbo[self]
740 raise
741 self.__started.wait()
742
743 def run(self):
744 """Method representing the thread's activity.
745
746 You may override this method in a subclass. The standard run()
method
747 invokes the callable object passed to the object's constructor
as the
748 target argument, if any, with sequential and keyword arguments
taken
749 from the args and kwargs arguments, respectively.
750
751 """
error: can't start new thread
***************************************************************************
History of session input:from sage.env import SAGE_EXTCODEimport gcfor k in
range(Integer(10000)):
gp = Gp()
gp.read(SAGE_EXTCODE + "/pari/simon/qfsolve.gp")
if k % Integer(1000) == Integer(0):
gc.collect()
for k in range(Integer(10000)):
gp = Gp()
gp.read(SAGE_EXTCODE + "/pari/simon/qfsolve.gp")
k
if k % Integer(1000) == Integer(0):
gc.collect()
*** Last line of input (may not be in above history):
import gc