Submitter | Matt Mackall |
---|---|
Date | Aug. 28, 2015, 10:17 p.m. |
Message ID | <c5d7e20b1af27b040a5e.1440800268@ruin.waste.org> |
Download | mbox | patch |
Permalink | /patch/10324/ |
State | Accepted |
Headers | show |
Comments
On 8/28/15 3:17 PM, Matt Mackall wrote: > # HG changeset patch > # User Matt Mackall <mpm@selenic.com> > # Date 1440799171 18000 > # Fri Aug 28 16:59:31 2015 -0500 > # Node ID c5d7e20b1af27b040a5eae0e1439e7675c695762 > # Parent ab66c1dee405aca0c51b8f76eab255d805c194d7 > contrib: add showstack extension > > This allows getting a Python stack trace at any time on Unix by > hitting Ctrl-\ (or Ctrl-T on BSDs). Useful for debugging mysterious > hangs on the fly. Sample output: > That's pretty slick. It seems to drop me back to the command prompt though, while the hg instance continues running in the background (occasionally writing stdout back to me while I'm typing). I'm on linux. Do you see that behavior too?
On Mon, 2015-08-31 at 15:32 -0700, Durham Goode wrote: > > On 8/28/15 3:17 PM, Matt Mackall wrote: > > # HG changeset patch > > # User Matt Mackall <mpm@selenic.com> > > # Date 1440799171 18000 > > # Fri Aug 28 16:59:31 2015 -0500 > > # Node ID c5d7e20b1af27b040a5eae0e1439e7675c695762 > > # Parent ab66c1dee405aca0c51b8f76eab255d805c194d7 > > contrib: add showstack extension > > > > This allows getting a Python stack trace at any time on Unix by > > hitting Ctrl-\ (or Ctrl-T on BSDs). Useful for debugging mysterious > > hangs on the fly. Sample output: > > > That's pretty slick. It seems to drop me back to the command prompt > though, while the hg instance continues running in the background > (occasionally writing stdout back to me while I'm typing). I'm on > linux. Do you see that behavior too? Haven't seen that one, no. I have seen it interrupt a select() syscall, and thus abort the process which is suboptimal. But if we're delivering signals to multiple threads, things could get ugly. Maybe your hg wrapper is causing trouble.
On 8/31/15 3:40 PM, Matt Mackall wrote: > On Mon, 2015-08-31 at 15:32 -0700, Durham Goode wrote: >> On 8/28/15 3:17 PM, Matt Mackall wrote: >>> # HG changeset patch >>> # User Matt Mackall <mpm@selenic.com> >>> # Date 1440799171 18000 >>> # Fri Aug 28 16:59:31 2015 -0500 >>> # Node ID c5d7e20b1af27b040a5eae0e1439e7675c695762 >>> # Parent ab66c1dee405aca0c51b8f76eab255d805c194d7 >>> contrib: add showstack extension >>> >>> This allows getting a Python stack trace at any time on Unix by >>> hitting Ctrl-\ (or Ctrl-T on BSDs). Useful for debugging mysterious >>> hangs on the fly. Sample output: >>> >> That's pretty slick. It seems to drop me back to the command prompt >> though, while the hg instance continues running in the background >> (occasionally writing stdout back to me while I'm typing). I'm on >> linux. Do you see that behavior too? > Haven't seen that one, no. I have seen it interrupt a select() syscall, > and thus abort the process which is suboptimal. But if we're delivering > signals to multiple threads, things could get ugly. Maybe your hg > wrapper is causing trouble. > Yep, that's it. I ran hg directly and it works.
On Fri, Aug 28, 2015 at 05:17:48PM -0500, Matt Mackall wrote: > # HG changeset patch > # User Matt Mackall <mpm@selenic.com> > # Date 1440799171 18000 > # Fri Aug 28 16:59:31 2015 -0500 > # Node ID c5d7e20b1af27b040a5eae0e1439e7675c695762 > # Parent ab66c1dee405aca0c51b8f76eab255d805c194d7 > contrib: add showstack extension queued with delight, thanks! > > This allows getting a Python stack trace at any time on Unix by > hitting Ctrl-\ (or Ctrl-T on BSDs). Useful for debugging mysterious > hangs on the fly. Sample output: > > $ hg log -k nosuchmessage > ^\ > File "/home/mpm/hg/mercurial/revset.py", line 3089, in _iterfilter > if cond(x): > File "/home/mpm/hg/mercurial/util.py", line 415, in f > cache[arg] = func(arg) > File "/home/mpm/hg/mercurial/revset.py", line 1215, in matches > for t in c.files() + [c.user(), c.description()]) > File "/home/mpm/hg/mercurial/context.py", line 525, in files > return self._changeset[3] > File "/home/mpm/hg/mercurial/util.py", line 531, in __get__ > result = self.func(obj) > File "/home/mpm/hg/mercurial/context.py", line 498, in _changeset > return self._repo.changelog.read(self.rev()) > File "/home/mpm/hg/mercurial/changelog.py", line 338, in read > text = self.revision(node) > File "/home/mpm/hg/mercurial/revlog.py", line 1092, in revision > bins = self._chunks(chain) > File "/home/mpm/hg/mercurial/revlog.py", line 1013, in _chunks > ladd(decompress(buffer(data, chunkstart - offset, chunklength))) > File "/home/mpm/hg/mercurial/revlog.py", line 91, in decompress > return _decompress(bin) > ---- > > diff -r ab66c1dee405 -r c5d7e20b1af2 contrib/showstack.py > --- /dev/null Thu Jan 01 00:00:00 1970 +0000 > +++ b/contrib/showstack.py Fri Aug 28 16:59:31 2015 -0500 > @@ -0,0 +1,17 @@ > +# showstack.py - extension to dump a Python stack trace on signal > +# > +# binds to both SIGQUIT (Ctrl-\) and SIGINFO (Ctrl-T on BSDs) > + > +import sys, signal, traceback > + > +def sigshow(*args): > + sys.stderr.write("\n") > + traceback.print_stack(args[1], limit=10, file=sys.stderr) > + sys.stderr.write("----\n") > + > +def extsetup(ui): > + signal.signal(signal.SIGQUIT, sigshow) > + try: > + signal.signal(signal.SIGINFO, sigshow) > + except AttributeError: > + pass > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@selenic.com > https://selenic.com/mailman/listinfo/mercurial-devel
Patch
diff -r ab66c1dee405 -r c5d7e20b1af2 contrib/showstack.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/contrib/showstack.py Fri Aug 28 16:59:31 2015 -0500 @@ -0,0 +1,17 @@ +# showstack.py - extension to dump a Python stack trace on signal +# +# binds to both SIGQUIT (Ctrl-\) and SIGINFO (Ctrl-T on BSDs) + +import sys, signal, traceback + +def sigshow(*args): + sys.stderr.write("\n") + traceback.print_stack(args[1], limit=10, file=sys.stderr) + sys.stderr.write("----\n") + +def extsetup(ui): + signal.signal(signal.SIGQUIT, sigshow) + try: + signal.signal(signal.SIGINFO, sigshow) + except AttributeError: + pass