diff --git a/gen_wrap.py b/gen_wrap.py
index d057d30a41681c3926330106b8ab6a1a19e807a5..9e949ccc0bd3a645fa49449854f5b8eb5c5f4fec 100644
--- a/gen_wrap.py
+++ b/gen_wrap.py
@@ -1520,8 +1520,11 @@ def write_method_wrapper(gen, cls_name, meth):
                     # This should never happen.
                     sys.stderr.write("*** islpy was interrupted while collecting "
                         "a result. "
-                        "System state is inconsistent as a result, aborting.\n")
+                        "System state is inconsistent as a result, will print "
+                        "traceback and abort.\n")
                     sys.stderr.flush()
+                    import traceback
+                    traceback.print_stack()
                     import os
                     os._exit(-1)
                 """)