QCAD - 2D CAD System.

Click here for a documentation of the DokuWiki formatting syntax that can be used in reports

Please search for existing tasks (also closed ones) before opening a new task.

Please make sure that you are using the latest Version of QCAD before posting a bug (menu Help > Check for Updates)


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

Attached to Project: QCAD
Opened by Peter (hungerburg) - Saturday, 15 October 2011, 18:54 GMT+1
Last edited by Andrew (andrew) - Monday, 17 October 2011, 21:05 GMT+1
Task Type Bug Report
Category QCAD (main)
Status Closed
Assigned To Andrew (andrew)
Operating System Linux (All / Other)
Severity Low
Priority Normal
Reported Version 3 Beta 3
Due in Version 3.0.0
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


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”);

This task depends upon

Closed by  Andrew (andrew)
Monday, 17 October 2011, 21:05 GMT+1
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
Comment by Andrew (andrew) - Saturday, 15 October 2011, 19:02 GMT+1

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

Comment by Peter (hungerburg) - Saturday, 15 October 2011, 19:18 GMT+1

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
Comment by Peter (hungerburg) - Saturday, 15 October 2011, 19:21 GMT+1

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

Comment by Peter (hungerburg) - Saturday, 15 October 2011, 19:23 GMT+1

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

Comment by Andrew (andrew) - Saturday, 15 October 2011, 20:19 GMT+1

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)) {

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

Comment by Peter (hungerburg) - Sunday, 16 October 2011, 14:02 GMT+1

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++);

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

Comment by Peter (hungerburg) - Tuesday, 18 October 2011, 13:44 GMT+1

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.