QCAD Bugtracker

  • Status Closed
  • Percent Complete
    100%
  • Task Type Bug Report
  • Category QCAD (main)
  • Assigned To
    Andrew
  • Operating System Linux (All / Other)
  • Severity Low
  • Priority Very Low
  • Reported Version 3 Beta 3
  • Due in Version 3.0.0
  • Due Date Undecided
  • Votes
  • Private
Attached to Project: QCAD Bugtracker
Opened by Peter - 15.10.2011
Last edited by Andrew - 17.10.2011

FS#317 - Debugger with -always-load-scripts

Starting qcad Beta 3 with command line argument -always-load-scripts will bring up debugger:

Uncaught exception at /opt/qcad-3.0.0-beta3-prof-linux/scripts/library.js:2: RangeError: Maximum call stack size exceeded.
2 include(”sprintf.js”);

Closed by  Andrew
17.10.2011 19:05
Reason for closing:  Deferred
Additional comments about closing:  

Somewhat out of the scope for now. Not sure how recursions could be avoided with -always-load-scripts

Admin
Andrew commented on 15.10.2011 17:02

Not reproducible under Mac OS X. Will test under Linux.

Peter commented on 15.10.2011 17:18

Does not look like a loop, rather some arbitrary limit of 25?

qsdb> .bt
#0  <eval>() at /opt/qcad-3.0.0-beta3-prof-linux/scripts/library.js:2
#1  <native>('library.js') at -1
#2  <eval>() at /opt/qcad-3.0.0-beta3-prof-linux/scripts/WidgetFactory.js:1
#3  <native>('WidgetFactory.js') at -1
#4  <eval>() at /opt/qcad-3.0.0-beta3-prof-linux/scripts/Plugin.js:1
#5  <native>('Plugin.js') at -1
#6  <eval>() at /opt/qcad-3.0.0-beta3-prof-linux/scripts/EAction.js:2
#7  <native>('scripts/EAction.js') at -1
#8  <eval>() at /opt/qcad-3.0.0-beta3-prof-linux/scripts/File/DrawingPreferences/PageSettings/PageSettings.js:1
#9  <native>('scripts/File/DrawingPreferences/PageSettings/PageSettings.js') at -1
#10  <eval>() at /opt/qcad-3.0.0-beta3-prof-linux/scripts/File/PrintPreview/Print.js:2
#11  <native>('scripts/File/PrintPreview/Print.js') at -1
#12  <eval>() at /opt/qcad-3.0.0-beta3-prof-linux/scripts/ImportExport/SvgExporter/SvgExporter.js:3
#13  <native>('SvgExporter.js') at -1
#14  <eval>() at /opt/qcad-3.0.0-beta3-prof-linux/scripts/ImportExport/SvgExporter/SvgExporterPG.js:1
#15  <native>('scripts/ImportExport/SvgExporter/SvgExporterPG.js') at -1
#16  <eval>() at /opt/qcad-3.0.0-beta3-prof-linux/scripts/BST/Schrank/SchrankVorlage.js:34
#17  <native>('SchrankVorlage.js') at -1
#18  <eval>() at /opt/qcad-3.0.0-beta3-prof-linux/scripts/BST/Schrank/SchrankDesign.js:39
#19  <native>('SchrankDesign.js') at -1
#20  <eval>() at /opt/qcad-3.0.0-beta3-prof-linux/scripts/BST/Schrank/Schrank.js:21
#21  <native>('scripts/BST/Schrank/Schrank.js') at -1
#22  <anonymous>() at /opt/qcad-3.0.0-beta3-prof-linux/scripts/Plugin.js:127
#23  loadPlugins(plugins = Plugin(  [ ... snip ... ]  ), splash = QSplashScreen) at scripts/autostart.js:305
#24  main() at scripts/autostart.js:477
#25  <global>() at scripts/autostart.js:557
Peter commented on 15.10.2011 17:21

Ooops, reading it, there are some scripts of mine in there... How come, I don't understand.

Peter commented on 15.10.2011 17:23

When I remove my scripts from QCAD the error the application starts without debugger. What may I do wrong?

Admin
Andrew commented on 15.10.2011 18:19

Nothing obvious, but it must have to do with one or more includes. You can try to wrap one include after another in your script plugin with a condition (only include if the class is not defined yet).
This is essentially what QCAD is doing without -always-load-scripts.

For example, for SvgExporterPG:

if (isNull(SvgExporterPG)) {
  include("scripts/ImportExport/SvgExporter/SvgExporterPG.js");
}

Of course that will make the -always-load-scripts option useless but it might help to pinpoint the problem to one particular include.

Peter commented on 16.10.2011 12:02

It actually helps to only conditionally include SvgExporterPG.js. Funny thing is: including NewFile.js in the same frame will not exceed call stack size. And also including SvgExporterPG.js from the parent frame will not do so.

A simple recursion on the other hand can run 47618 times.

var counter = 0;
(function bomb() {
	qDebug("Bomb: " + counter++);
	bomb();
})();

How is the limit calculated? http://doc.qt.nokia.com/latest/qthread.html#setStackSize says, its up to the operating system, unless set explicitly.

Peter commented on 18.10.2011 11:44

I am fine with deferral. The workaround is simple and does not impose much of an inconvenience and "always-load-scripts" is a developper extension anyways. Please note though, that its not about recursion, at least not infinite one: The stack trace does not show that. Instead its about loading, what otherwise would already have been loaded and thereby increasing stack size beyond some limit. The message of the error thrown is remarkably clear on that.

With the recursion sample I only wanted to address, that the limit is not the number of frames. The documented QThread structure is not exposed to scripting, or only in an obscure place. I Hope I dont steal your time with such a fringe problem.

Loading...

Available keyboard shortcuts

Tasklist

Task Details

Task Editing