about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-08-24 20:13:32 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-08-24 20:13:32 -0700
commit0cfc678fdc686c0216ea238ff197e0e54e4a3f8c (patch)
treec02b00b4935867fc77962e2350cfdba8afda69f4
parent23eed027bc932c1cb51f261e061d384de7dec680 (diff)
downloadmu-0cfc678fdc686c0216ea238ff197e0e54e4a3f8c.tar.gz
2074 - don't die on over-long errors
-rw-r--r--043new.cc6
-rw-r--r--081run_interactive.cc17
2 files changed, 19 insertions, 4 deletions
diff --git a/043new.cc b/043new.cc
index a41f902f..42608264 100644
--- a/043new.cc
+++ b/043new.cc
@@ -118,7 +118,11 @@ case NEW: {
 
 :(code)
 void ensure_space(long long int size) {
-  assert(size <= Initial_memory_per_routine);
+  if (size > Initial_memory_per_routine) {
+    tb_shutdown();
+    cerr << "can't allocate " << size << " locations, that's too much.\n";
+    exit(0);
+  }
   if (Current_routine->alloc + size > Current_routine->alloc_max) {
     // waste the remaining space and create a new chunk
     Current_routine->alloc = Memory_allocated_until;
diff --git a/081run_interactive.cc b/081run_interactive.cc
index 67fba6e3..411b448a 100644
--- a/081run_interactive.cc
+++ b/081run_interactive.cc
@@ -303,9 +303,20 @@ long long int trace_contents(const string& layer) {
     out << p->contents;
     if (*--p->contents.end() != '\n') out << '\n';
   }
-  assert(!out.str().empty());
-//?   cerr << layer << ":\n" << out.str() << "\n--\n"; //? 1
-  return new_mu_string(out.str());
+  string result = out.str();
+  assert(!result.empty());
+//?   cerr << layer << ":\n" << result << "\n--\n"; //? 1
+  truncate(result);
+  return new_mu_string(result);
+}
+
+void truncate(string& x) {
+  if (SIZE(x) > 512) {
+    x.erase(512);
+    *x.rbegin() = '\n';
+    *++x.rbegin() = '.';
+    *++++x.rbegin() = '.';
+  }
 }
 
 //: simpler version of run-interactive: doesn't do any running, just loads