View Issue Details

IDProjectCategoryView StatusLast Update
0013408ScribusUser Interfacepublic2015-11-03 00:59
ReporterjurajF Assigned Tocbradney  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformqemuOSLinuxOS VersionDebian 8/Jessie
Product Version1.5.0 
Fixed in Version1.5.1svn 
Summary0013408: [CLI] --prefs option without provided file causes crash
DescriptionScribus crashes with Signal 0000006 when file argument is not provided to --prefs
or --python-script options

$ scribus-1.5.1.svn -pr
ASSERT failure in QList<T>::operator[]: "index out of range", file
/usr/include/x86_64-linux-gnu/qt5/QtCore/qlist.h, line 487
Scribus Crash
-------------
Scribus crashes due to Signal 0000006
Steps To Reproduce$ scribus-1.5.1.svn -pr
$ scribus-1.5.1.svn -py
Additional Informationticket was split in to 4 tickets
0013413
0013414
0013415
TagsNo tags attached.
PatchYes

Relationships

related to 0013414 closedcbradney [CLI] --lang issues 
related to 0013413 closedcbradney [CLI] Error-message-wrong-and-too-verbose 
related to 0013415 closedcbradney [CLI] Changing multiple flag rules 
related to 0013452 closedfschmid Can not open ".autosave" file: "is not in an acceptable format" 

Activities

jurajF

2015-10-10 13:42

reporter  

0001-prefs-option-without-provided-file-causes-crash.patch (1,826 bytes)   
From 96b19a1c30be9df3da090dabba048b602e48371c Mon Sep 17 00:00:00 2001
From: Juraj Fedel <wtxnh-scribus@yahoo.com.au>
Date: Sat, 10 Oct 2015 11:22:00 +0200
Subject: [PATCH 1/7] --prefs option without provided file causes crash

Scribus crashes with Signal #6 when file argument is not provided to --prefs
or --python-script

$ scribus-1.5.1.svn -pr
ASSERT failure in QList<T>::operator[]: "index out of range", file
/usr/include/x86_64-linux-gnu/qt5/QtCore/qlist.h, line 487
Scribus Crash
-------------
Scribus crashes due to Signal #6
---
 scribus/scribusapp.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/scribus/scribusapp.cpp b/scribus/scribusapp.cpp
index bbc7357..f9b0eec 100644
--- a/scribus/scribusapp.cpp
+++ b/scribus/scribusapp.cpp
@@ -229,6 +229,10 @@ void ScribusQApp::parseCommandLine()
 			// last argument. FIXME: Qt only understands -display not --display and -d , we need to work
 			// around this.
 		} else if (arg == ARG_PREFS || arg == ARG_PREFS_SHORT) {
+			if (argi+1 == argsc) {
+				std::cout << tr("Option %1 require an argument.").arg(arg).toLocal8Bit().data() << std::endl;
+				std::exit(EXIT_FAILURE);
+			}
 			prefsUserFile = QFile::decodeName(args[argi + 1].toLocal8Bit());
 			if (!QFileInfo(prefsUserFile).exists()) {
 				showError(prefsUserFile);
@@ -240,6 +244,10 @@ void ScribusQApp::parseCommandLine()
 		{
 			// Andreas Vox: Qt/Mac has -psn_blah flags that must be accepted.
 		} else if (arg == ARG_PYTHONSCRIPT || arg == ARG_PYTHONSCRIPT_SHORT) {
+			if (argi+1 == argsc) {
+				std::cout << tr("Option %1 require an argument.").arg(arg).toLocal8Bit().data() << std::endl;
+				std::exit(EXIT_FAILURE);
+			}
 			pythonScript = QFile::decodeName(args[argi + 1].toLocal8Bit());
 			if (!QFileInfo(pythonScript).exists()) {
 				showError(pythonScript);
-- 
2.1.4

Kunda

2015-10-10 22:34

updater   ~0036605

Coolness. Thanks Juraj. We should get Berteh in to this conversation as well. I'll try to ping him.

berteh

2015-10-10 23:37

reporter   ~0036610

Last edited: 2015-10-10 23:40

Hi Juraj, thanks for the various improvements you brought esp. improving the feedback when arguments are missing a required value (filename in these cases).

just one note regarding your use of "--". I think it's wrong to allow multiple use of it. It usually (as in "in other places where it's used) denotes the end of options and the beginning of positional arguments... and I think it should stay that way.

The reason you mention for needing to enable multiple use was actually not needed, as -pa works just fine if you provide it with just a flag name and then follow with more options (it will detect the starting "-" of the following option and skip looking for its (optional) argument value)... so the only place you needed the "--" is indeed at the very end of options sequence, to make sure the positional arguments (scribus files) are not consumed by -pa.

[it was handled in the line
if (++argi < argsc && !args[argi].startsWith("-")) { // arg value
that you removed in your patch "strange use of delimiter") ]



That being said, I agree with you that forcing -pa to be the last option and consume all that's left of command line (before an optional --) would be less verbose. It's just that othes preferred not having that mechanism, see aoloe at https://github.com/scribusproject/scribus/pull/19#issuecomment-128313027, and cbradney at http://bugs.scribus.net/view.php?id=13311#c36165

... so I guess that part is not an option for the core devs of scribus.

Kunda

2015-10-12 00:15

updater   ~0036641

Tested 0001-prefs-option-without-provided-file-causes-crash.patch
and it fixes crash.

Kunda

2015-10-19 06:35

updater   ~0036697

Patch tested and successfully fixes crash.

Kunda

2015-11-03 00:59

updater   ~0037159

Committed by Craig in r20512
Patch by Juraj
Thanks

Issue History

Date Modified Username Field Change
2015-10-10 13:42 jurajF New Issue
2015-10-10 13:42 jurajF File Added: 0001-prefs-option-without-provided-file-causes-crash.patch
2015-10-10 13:43 jurajF File Added: 0002-Error-message-wrong-and-too-verbose.patch
2015-10-10 13:44 jurajF File Added: 0003-Remove-duplicated-code.patch
2015-10-10 13:44 jurajF File Added: 0004-Wrong-error-when-lang-does-not-have-an-argument.patch
2015-10-10 13:44 jurajF File Added: 0005-Strange-use-of-delimiter.patch
2015-10-10 13:45 jurajF File Added: 0006-Merge-ARG_SCRIPTARG-with-ARG_PYTHONSCRIPT.patch
2015-10-10 13:45 jurajF File Added: 0007-Allow-sla-files-to-be-intermixed-with-other-options.patch
2015-10-10 22:34 Kunda Note Added: 0036605
2015-10-10 23:37 berteh Note Added: 0036610
2015-10-10 23:40 berteh Note Edited: 0036610
2015-10-11 22:50 Kunda Issue cloned: 0013413
2015-10-11 22:50 Kunda Relationship added related to 0013413
2015-10-11 23:41 Kunda Relationship added related to 0013415
2015-10-11 23:42 Kunda Description Updated
2015-10-11 23:42 Kunda Steps to Reproduce Updated
2015-10-11 23:42 Kunda Additional Information Updated
2015-10-11 23:43 Kunda Relationship added related to 0013414
2015-10-11 23:43 Kunda File Deleted: 0007-Allow-sla-files-to-be-intermixed-with-other-options.patch
2015-10-11 23:43 Kunda File Deleted: 0006-Merge-ARG_SCRIPTARG-with-ARG_PYTHONSCRIPT.patch
2015-10-11 23:43 Kunda File Deleted: 0005-Strange-use-of-delimiter.patch
2015-10-11 23:43 Kunda File Deleted: 0004-Wrong-error-when-lang-does-not-have-an-argument.patch
2015-10-11 23:44 Kunda File Deleted: 0003-Remove-duplicated-code.patch
2015-10-11 23:44 Kunda File Deleted: 0002-Error-message-wrong-and-too-verbose.patch
2015-10-11 23:44 Kunda Summary --prefs option without provided file causes crash => [CLI] --prefs option without provided file causes crash
2015-10-12 00:15 Kunda Note Added: 0036641
2015-10-12 00:56 Kunda Status new => confirmed
2015-10-19 06:35 Kunda Note Added: 0036697
2015-10-20 17:23 Kunda Patch No => Yes
2015-10-29 04:44 Kunda Relationship added related to 0013452
2015-11-02 09:55 cbradney Status confirmed => resolved
2015-11-02 09:55 cbradney Fixed in Version => 1.5.1svn
2015-11-02 09:55 cbradney Resolution open => fixed
2015-11-02 09:55 cbradney Assigned To => cbradney
2015-11-03 00:59 Kunda Note Added: 0037159
2015-11-03 00:59 Kunda Status resolved => closed