View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0002674 | FSSCP | scripting | public | 2012-06-27 16:19 | 2012-07-15 15:54 |
| Reporter | m_m | Assigned To | m_m | ||
| Priority | normal | Severity | minor | Reproducibility | always |
| Status | resolved | Resolution | fixed | ||
| Product Version | 3.6.13 | ||||
| Target Version | 3.6.13 | Fixed in Version | 3.6.13 | ||
| Summary | 0002674: Lua Debug Call stacks are incomplete when too long | ||||
| Description | When an error happens inside a lua script and the stack is longer than four functions calls then some call stack information is dropped because the scripting system can only hold four different call locations at a time. The attached patch fixes that behavior by using the built-in debug.traceback function which has given very good results. If the debug library (for what reason ever) isn't available then the call stack is generated using the old way. | ||||
| Tags | No tags attached. | ||||
|
|
luaCallStack.patch (1,253 bytes)
Index: code/globalincs/windebug.cpp
===================================================================
--- code/globalincs/windebug.cpp (revision 8916)
+++ code/globalincs/windebug.cpp (working copy)
@@ -1105,12 +1105,35 @@
AssertText2[0] = '\0';
dumpBuffer.Printf(Separator);
- dumpBuffer.Printf("LUA Stack:\r\n");
- int i;
- for (i = 0; i < 4; i++) {
- if (debug_stack[i][0] != '\0')
- dumpBuffer.Printf("\t%s\r\n", debug_stack[i]);
+
+ // Get the stack via the debug.traceback() function
+ lua_getglobal(L, LUA_DBLIBNAME);
+
+ if (!lua_isnil(L, -1))
+ {
+ dumpBuffer.Printf( "\r\n" );
+ lua_getfield(L, -1, "traceback");
+ lua_remove(L, -2);
+
+ if (lua_pcall(L, 0, 1, 0) != 0)
+ dumpBuffer.Printf("Error while retrieving stack: %s", lua_tostring(L, -1));
+ else
+ dumpBuffer.Printf(lua_tostring(L, -1));
+
+ lua_pop(L, 1);
}
+ else
+ {
+ // If the debug library is nil then fall back to the default debug stack
+ dumpBuffer.Printf("LUA Stack:\r\n");
+ int i;
+ for (i = 0; i < 4; i++) {
+ if (debug_stack[i][0] != '\0')
+ dumpBuffer.Printf("\t%s\r\n", debug_stack[i]);
+ }
+ }
+ dumpBuffer.Printf( "\r\n" );
+
dumpBuffer.Printf(Separator);
ade_stackdump(L, AssertText2);
dumpBuffer.Printf( AssertText2 );
|
|
|
Committed to trunk, revision 9016. Thanks for the useful patch. |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2012-06-27 16:19 | m_m | New Issue | |
| 2012-06-27 16:19 | m_m | Status | new => assigned |
| 2012-06-27 16:19 | m_m | Assigned To | => m_m |
| 2012-06-27 16:19 | m_m | File Added: luaCallStack.patch | |
| 2012-06-27 16:19 | m_m | Status | assigned => feedback |
| 2012-06-27 16:20 | m_m | Status | feedback => code review |
| 2012-07-15 15:54 | Echelon9 | Note Added: 0013866 | |
| 2012-07-15 15:54 | Echelon9 | Status | code review => resolved |
| 2012-07-15 15:54 | Echelon9 | Fixed in Version | => 3.6.13 |
| 2012-07-15 15:54 | Echelon9 | Resolution | open => fixed |