Results 1 to 8 of 8

Thread: program close unexpectedly after adding QHttpMultiPart in my software

  1. #1
    Join Date
    Jan 2014
    Location
    Iran
    Posts
    15
    Thanks
    9
    Qt products
    Platforms
    Unix/X11 Windows

    Default program close unexpectedly after adding QHttpMultiPart in my software

    Hello
    I'm newbie,so sorry if my question is simple
    I had some problem for uploading file through HTTP,finally I got the solution,here is a working example
    then I just change my code to work with QHttpMultiPart,when I was done,I run my program to see if everything is fine,but after adding a file to upload,my software close unexpectedly (no raising error,just crash)
    here is a basic working example of my code
    problem is in Uploader class,the upload method.
    I can't understand what I'm doing wrong,can some one give me hint or a solution ?
    I ask this question in qt forum but no answer,here is last place which can answer my question,so please help me on this one
    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: program close unexpectedly after adding QHttpMultiPart in my software

    You need to have a look at the stack trace from when the crash happens.

    For example by running the program in a debugger or checking the backtrace on crash, etc.

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    Mohammadhzp (18th January 2014)

  4. #3
    Join Date
    Jan 2014
    Location
    Iran
    Posts
    15
    Thanks
    9
    Qt products
    Platforms
    Unix/X11 Windows

    Default Re: program close unexpectedly after adding QHttpMultiPart in my software

    I did check the program in debugger but it gave me nothing and unfortunately I don't know how to check backtrace
    edit: I'm downloading gdb to debugging,I'll post result as soon as I get them


    Added after 35 minutes:


    try to debugging with gdb but just gdb gave me this
    Segmentation fault (core dumped)
    I have no idea what's this
    after trying more I got this too
    Program received signal SIGSEGV, Segmentation fault.
    0xb5a9ed1b in ?? () from /usr/lib/i386-linux-gnu/libQtNetwork.so.4
    Last edited by Mohammadhzp; 18th January 2014 at 20:04.

  5. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,620
    Thanks
    13
    Thanked 1,592 Times in 1,520 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: program close unexpectedly after adding QHttpMultiPart in my software

    Gdb will not help you debug a Python program.

    You can single step through a python program with pdb (the python debugger) ...do that until you find out where it dies.

    Edit: you edited while i was writing. A segmentation fault typically indicates a null or invalid pointer in a C++ program. If python in crashing in this way with your program then I think it is likely to be a PyQt/pySide installation problem

  6. The following user says thank you to ChrisW67 for this useful post:

    Mohammadhzp (18th January 2014)

  7. #5
    Join Date
    Jan 2014
    Location
    Iran
    Posts
    15
    Thanks
    9
    Qt products
    Platforms
    Unix/X11 Windows

    Default Re: program close unexpectedly after adding QHttpMultiPart in my software

    I tried gdb
    I now which line this error occur,it's when I'm posting data
    self._reply = self.parent().post(request, self._multiPart)
    I'm now sure about it since got this error with gdb(I'll try pdb to see if I can get more information)
    Program received signal SIGSEGV, Segmentation fault.
    0xb5a9ed1b in ?? () from /usr/lib/i386-linux-gnu/libQtNetwork.so.4
    but I can't understand why this is happening(other example in my first post is working,but mine example does not)


    Added after 12 minutes:


    I installed requirement with this command
    sudo apt-get install build-essential python3-dev libqt4-dev
    then I installed both SIB and PyQt which this command
    python3.3 configure.py
    make
    sudo make install

    did I installed it in wrong way ? if not,is possible that maybe a file is broken ?

    edit : pdb give me nothing
    Can someone please test my basic code of my program to see if it crash or not ?

    edit2 : I think my PyQt is just fine,because this code is working fine
    Last edited by Mohammadhzp; 18th January 2014 at 23:53.

  8. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,620
    Thanks
    13
    Thanked 1,592 Times in 1,520 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: program close unexpectedly after adding QHttpMultiPart in my software

    Ahh, there was a second link in your first post to your code.

    Here is what I think is happening (I am not a Python master).

    In handleAddUpload() you create a local variable QFile called stream. You pass that to uploader.upload() which stashes a reference to that QIODevice in your multipart message structures and calls post() to queue the transmission before returning. At this time the stream variable goes out of scope. When the Qt network code goes to send the actual POST and payload it tries to build the payload using the defunct stream. I suspect that causes the crash.

  9. The following user says thank you to ChrisW67 for this useful post:

    Mohammadhzp (19th January 2014)

  10. #7
    Join Date
    Jan 2014
    Location
    Iran
    Posts
    15
    Thanks
    9
    Qt products
    Platforms
    Unix/X11 Windows

    Default Re: program close unexpectedly after adding QHttpMultiPart in my software

    Thanks Chris for reply

    Quote Originally Posted by ChrisW67 View Post

    At this time the stream variable goes out of scope
    I was suspected too but docs is saying that you need to call close(),because of that I thought it might not be the stream,unfortunately I'm new to python/PyQt,How do you think I can handle stream?(I mean if I need to change my code,how you suggest me to read data ?) ?
    thanks
    Last edited by Mohammadhzp; 19th January 2014 at 00:43.

  11. #8
    Join Date
    Jan 2014
    Location
    Iran
    Posts
    15
    Thanks
    9
    Qt products
    Platforms
    Unix/X11 Windows

    Default Re: program close unexpectedly after adding QHttpMultiPart in my software

    I got the solution(the problem was I have no experience lol)
    Basically the segfault happened because the qt objects were not deleted before the last reference to the instance of the upload was deleted
    e.g in my code in uploader.upload() we assign data like this self._data = data and then in uploader.handleFinished() we delete self.__data like this : self._data.deleteLater() before self.__reply
    hope it help some newbie like me
    thanks guys for reply

Similar Threads

  1. The program has unexpectedly finished.
    By smemamian in forum Newbie
    Replies: 4
    Last Post: 1st April 2013, 00:44
  2. Replies: 4
    Last Post: 17th September 2012, 15:23
  3. the program has unexpectedly finished
    By narlapavan in forum Qt Programming
    Replies: 9
    Last Post: 9th July 2012, 09:04
  4. Program quits unexpectedly
    By MCFormax in forum Newbie
    Replies: 2
    Last Post: 9th November 2011, 02:31
  5. Program has unexpectedly finished
    By Maluko_Da_Tola in forum Newbie
    Replies: 5
    Last Post: 1st December 2010, 09:54

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.