Bug 13516 - more robust handling of ^C
Summary: more robust handling of ^C
Status: RESOLVED FIXED
Alias: None
Product: systemtap
Classification: Unclassified
Component: translator (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Chris Meek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-18 19:46 UTC by Frank Ch. Eigler
Modified: 2012-06-06 15:50 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Frank Ch. Eigler 2011-12-18 19:46:55 UTC
In many places in the translator, we check for pending_interrupts,
and simply return or quit nested loops early, being assured that
eventually we'll bubble back up to the top level and get a proper
rc=EXIT_FAILURE.

This is not quite good enough.  In some cases, an unfortunately
timed interrupt can result in an exit from a routine, with
expected post-conditions not met.  For example, elaborate.cxx
includes:

1665	
1666	      // Add created probe
1667	      p->body = b;
1668	      derive_probes (s, p, dps);
1669	      for (unsigned i = 0; i < dps.size(); i++)
1670		{
1671		  derived_probe* dp = dps[i];
1672		  s.probes.push_back (dp);
1673		  dp->join_group (s);
1674		}
1675	      // Repopulate symbol and type info
1676	      symresolution_info sym (s);
1677	      sym.current_function = 0;
1678	      sym.current_probe = dps[0];
1679	      dps[0]->body->visit (& sym);

If the interrupt was taken during the derive_probes() call, it
will have left the dps[] array empty, but will simply return.
On line 1678, dps[0] will be dereferenced, bang, segv.

The code could, I suppose, protect itself with more explicit
checks, but this seems to be more labour than necessary.  Let's
instead explore replacing all
       if (pending_interrupts) break;
or     if (pending_interrupts) return;
with   if (pending_interrupts) throw runtime_error("interrupt received");
and catch that in main() someplace.  This should make it unnecessary
to check & test in quite so many places.
Comment 1 Chris Meek 2012-06-06 15:50:38 UTC
Fixed in commit 985892de26421