Public bug reported: Ubuntu release: 10.04 LTS Package: qjson Version: 0.7.1-1
The following test case produces a segmentation fault on Ubuntu: j.cpp: #include <QDebug> #include <QFile> #include <QVariant> #include <qjson/parser.h> int main() { QJson::Parser parser; QFile f("test.json"); bool ok; // Reading from a QByteArray works fine. f.open(QIODevice::ReadOnly); QByteArray data = f.readAll(); f.close(); QVariantMap result1 = parser.parse(data, &ok).toMap(); qDebug() << result1; // Reading from a QIODevice * segfaults f.open(QIODevice::ReadOnly); QVariantMap result2 = parser.parse(&f, &ok).toMap(); f.close(); qDebug() << result2; return 0; } Here's some test data and a qmake project file for the test case: test.json: { "a": "b" } j.pro: TEMPLATE = app TARGET = DEPENDPATH += . INCLUDEPATH += . SOURCES += j.cpp LIBS += -lqjson Running this code produces: $ ./j QMap(("a", QVariant(QString, "b") ) ) Segmentation fault whereas it should produce the same line of output twice. The gdb backtrace is: Program received signal SIGSEGV, Segmentation fault. 0x00849886 in QIODevice::read(char*, long long) () from /usr/lib/libQtCore.so.4 (gdb) bt #0 0x00849886 in QIODevice::read(char*, long long) () from /usr/lib/libQtCore.so.4 #1 0x0084a530 in QIODevice::getChar(char*) () from /usr/lib/libQtCore.so.4 #2 0x001360f2 in JSonScanner::yylex(QVariant*, yy::location*) () from /usr/lib/libqjson.so.0 #3 0x001389b3 in yy::yylex(QVariant*, yy::location*, QJson::ParserPrivate*) () from /usr/lib/libqjson.so.0 #4 0x0013ab91 in yy::json_parser::parse() () from /usr/lib/libqjson.so.0 #5 0x001352e6 in QJson::Parser::parse(QIODevice*, bool*) () from /usr/lib/libqjson.so.0 #6 0x0804c358 in main () (gdb) The same test case works fine with the same version of QJson on Mac OS X, so I am not sure this is a bug in QJson itself. ** Affects: qjson (Ubuntu) Importance: Undecided Status: New -- Segmentation fault in QJson::Parser when reading from a QIODevice https://bugs.launchpad.net/bugs/610656 You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs