Bug 826397 - QString Segfaults on appending string at line 274 in the QString Library
QString Segfaults on appending string at line 274 in the QString Library
Status: CLOSED WONTFIX
Product: Fedora
Classification: Fedora
Component: qt (Show other bugs)
17
x86_64 Linux
unspecified Severity unspecified
: ---
: ---
Assigned To: Ngo Than
Fedora Extras Quality Assurance
: Reopened
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-05-30 02:34 EDT by lukewolf101010
Modified: 2013-08-01 14:08 EDT (History)
8 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-08-01 14:08:52 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
strace of binary (37.56 KB, text/plain)
2012-05-30 02:34 EDT, lukewolf101010
no flags Details
header file (3.05 KB, text/x-chdr)
2012-05-30 02:34 EDT, lukewolf101010
no flags Details
implementation file (8.92 KB, text/x-c++src)
2012-05-30 02:36 EDT, lukewolf101010
no flags Details
qrc file used (101 bytes, text/plain)
2012-05-30 21:38 EDT, lukewolf101010
no flags Details
Sample resource file, created for use as a test case (313 bytes, text/plain)
2012-05-30 21:40 EDT, lukewolf101010
no flags Details
Qt .pro file, modified for use with the testcase (1.43 KB, text/plain)
2012-05-30 22:03 EDT, lukewolf101010
no flags Details
Qt .pro file modified for use with the test case (1.43 KB, application/octet-stream)
2012-05-30 22:23 EDT, lukewolf101010
no flags Details
nodemanager header for use with the node class (1.07 KB, application/octet-stream)
2012-05-30 22:23 EDT, lukewolf101010
no flags Details
Nodemanager implementation (5.02 KB, application/octet-stream)
2012-05-30 22:24 EDT, lukewolf101010
no flags Details
all thats required to build and test (8.51 KB, application/octet-stream)
2012-05-30 22:33 EDT, lukewolf101010
no flags Details

  None (edit)
Description lukewolf101010 2012-05-30 02:34:14 EDT
Created attachment 587599 [details]
strace of binary

Description of problem:

When I try to compile and run an application I'm developing, I'm getting segmentation faults from the QString library.  This same bit of code compiled and ran fine under Slackware, Windows, and openSUSE.  The problem initially showed up a month or two ago if I remember correctly in Fedora 16, I thought that my libraries had just gotten screwed up somehow, and so I waited until 17 to come out to reinstall, and I tested it on that on a clean system and it's still broken.  

Version-Release number of selected component (if applicable):
Qt 4.8.x

How reproducible:
I have yet to actually reproduce the error itself in independent code however however I am attaching the file that causes the QString libraries to break.

Steps to Reproduce:
1. use Qt Creator and create a basic project
2. take the attached node class and hook it into this basic project
3. compile and try to run
  
Actual results:
Segmentation Fault

Expected results:
Program runs, just as it does under wine, windows, slackware, and openSUSE.

Additional info:
License on the class itself is intended to be either GPL or LGPL, and I'm still undecided on which version.
Comment 1 lukewolf101010 2012-05-30 02:34:49 EDT
Created attachment 587600 [details]
header file
Comment 2 lukewolf101010 2012-05-30 02:36:16 EDT
Created attachment 587601 [details]
implementation file

Line 20 in the file is set up in the stack that causes the segfault according to the debugger.
Comment 3 Kevin Kofler 2012-05-30 10:42:12 EDT
Comment on attachment 587599 [details]
strace of binary

That's an strace, not a stack trace. Unfortunately, the latter is what we really need.
Comment 4 Kevin Kofler 2012-05-30 10:47:24 EDT
FYI, QString is a very frequently used class. It's highly unlikely that it is really buggy. Crashes in QString are normally bugs in the application using it, due to use of an uninitialized, already deleted etc. QString.
Comment 5 Kevin Kofler 2012-05-30 10:48:30 EDT
And for a more useful debugging trace, please try using valgrind instead of strace. That will give us actual stack traces, not only of the crash, but also hopefully of its true cause.
Comment 6 Ngo Than 2012-05-30 11:33:01 EDT
(In reply to comment #2)
> Created attachment 587601 [details]
> implementation file
> 
> Line 20 in the file is set up in the stack that causes the segfault
> according to the debugger.

imo it's a bug in line 20. the empty stringlist causes the crash in this case. You have to check the qstringlist with isEmpty() before call last() function.
Comment 7 Kevin Kofler 2012-05-30 11:37:02 EDT
Oh right, last() on an empty list is not allowed in Qt 4. (It used to be allowed in Qt 3 and always returned a default-constructed object, but in Qt 4, this guarantee was removed for performance reasons. Even if it happened to work for you so far, you were relying on undefined behavior.)
Comment 8 Ngo Than 2012-05-30 11:41:49 EDT
it should crash on slackware/opensuse too if you compiles it without the flag
-DQT_NO_DEBUG
Comment 9 lukewolf101010 2012-05-30 18:43:17 EDT
Okay you're right in that it's crashing because the QStringlist is empty, and I will admit I should have provided at least a template of one of the resource files so that It could be better reproduced.  However what appears to be happening is that there's a qrc related bug, which is causing QDir not to populate the QStringList when it's querying for .hjt files, which was then is causing the crash.
Comment 10 Kevin Kofler 2012-05-30 19:40:09 EDT
So then a testcase actually using qrc is needed.
Comment 11 lukewolf101010 2012-05-30 21:38:28 EDT
Created attachment 587908 [details]
qrc file used
Comment 12 lukewolf101010 2012-05-30 21:40:36 EDT
Created attachment 587909 [details]
Sample resource file, created for use as a test case

There I've uploaded the qrc and a resource file that can be used as a test case.  Note that the .hjt file should go under a folder called Resources in the source code directory.
Comment 13 Kevin Kofler 2012-05-30 21:53:38 EDT
How do we compile the resources? Do you have a build script, .pro file, CMakeLists.txt file or whatever?
Comment 14 lukewolf101010 2012-05-30 22:03:55 EDT
Created attachment 587914 [details]
Qt .pro file, modified for use with the testcase

here's the .pro file, I've already commented out everything not related to the usecase so should be set up to go without need for extra modification.
Comment 15 Kevin Kofler 2012-05-30 22:11:59 EDT
main.cpp is also needed.
Comment 16 lukewolf101010 2012-05-30 22:23:11 EDT
Created attachment 587916 [details]
Qt .pro file modified for use with the test case

in that case I'm going to update the .pro file and give you the node manager class as well
Comment 17 lukewolf101010 2012-05-30 22:23:58 EDT
Created attachment 587917 [details]
nodemanager header for use with the node class
Comment 18 lukewolf101010 2012-05-30 22:24:38 EDT
Created attachment 587918 [details]
Nodemanager implementation
Comment 19 lukewolf101010 2012-05-30 22:33:57 EDT
Created attachment 587922 [details]
all thats required to build and test

Okay, I'm just going to be efficient here and just attach this as a tar.gz
Comment 20 lukewolf101010 2012-05-30 22:38:34 EDT
as a side note I removed the ':/' in the copy of the node.cpp I put in the tar.gz  so you're going to have to move the resources folder to the build location otherwise it won't work, and obviously put back the ':/' to for qrc testing
Comment 21 Ngo Than 2012-05-31 07:41:28 EDT
(In reply to comment #19)
> Created attachment 587922 [details]
> all thats required to build and test
> 
> Okay, I'm just going to be efficient here and just attach this as a tar.gz

it's a bug in your codes, you are using assignments at names scope, it's not allowed. you have to move them inside of your constructor node::node()
Comment 22 lukewolf101010 2012-05-31 19:33:14 EDT
(In reply to comment #21)
> (In reply to comment #19)
> > Created attachment 587922 [details]
> > all thats required to build and test
> > 
> > Okay, I'm just going to be efficient here and just attach this as a tar.gz
> 
> it's a bug in your codes, you are using assignments at names scope, it's not
> allowed. you have to move them inside of your constructor node::node()

If I'm understanding what you're saying right then you're wrong, those are static variables which must be initialized outside of the constructur or any function, and static variables as long as it's in the initialization statement can be assigned values outside of functions.
Comment 23 Fedora End Of Life 2013-07-04 02:34:17 EDT
This message is a reminder that Fedora 17 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 17. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '17'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 17's end of life.

Bug Reporter:  Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 17 is end of life. If you 
would still like  to see this bug fixed and are able to reproduce it 
against a later version  of Fedora, you are encouraged  change the 
'version' to a later Fedora version prior to Fedora 17's end of life.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.
Comment 24 Fedora End Of Life 2013-08-01 14:08:58 EDT
Fedora 17 changed to end-of-life (EOL) status on 2013-07-30. Fedora 17 is 
no longer maintained, which means that it will not receive any further 
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of 
Fedora please feel free to reopen this bug against that version.

Thank you for reporting this bug and we are sorry it could not be fixed.

Note You need to log in before you can comment on or make changes to this bug.