Results 1 to 20 of 30

Thread: Cannot access memory at address 0x0

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2008
    Posts
    21
    Thanks
    3

    Default Re: Cannot access memory at address 0x0

    behold:
    (gdb) bt
    #0 main (argc=Cannot access memory at address 0x0
    ) at main.cpp:7
    ^done
    Last edited by defumar; 25th January 2008 at 16:02.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Cannot access memory at address 0x0

    How exactly did you compile the application? What happens if you change "*argv[]" to "**argv"? I know the former should work but it should all work and it doesn't so I'm curious to see the result.

  3. #3
    Join Date
    Jan 2008
    Posts
    21
    Thanks
    3

    Default Re: Cannot access memory at address 0x0

    Firstly I went into the src directory of my Simple Qt project and I ran qmake -project and qmake, then I opened up KDevelop again and had it Build Project using all the default settings for a qmake project. (g++)
    I tried changing it to ** but still got the same error.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Cannot access memory at address 0x0

    What is the contents of the .pro file?

  5. #5
    Join Date
    Jan 2008
    Posts
    21
    Thanks
    3

    Default Re: Cannot access memory at address 0x0

    Qt Code:
    1. SUBDIRS += src
    2. TEMPLATE = subdirs
    3. CONFIG += warn_on \
    4. qt \
    5. thread
    To copy to clipboard, switch view to plain text mode 

    I read that the -fstack-check option may cause an error like this. I have no idea of where to find it in my KDevelop though.
    The page I read this --> http://lists.trolltech.com/qt-intere.../msg00731.html
    Last edited by defumar; 26th January 2008 at 10:37.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Cannot access memory at address 0x0

    What's the contents of the .pro file inside the src subdirectory?

    Oh, and please rebuild your project without KDevelop. Open the console, cd into src, run qmake, make distclean, qmake, make.

  7. #7
    Join Date
    Jan 2008
    Posts
    21
    Thanks
    3

    Default Re: Cannot access memory at address 0x0

    oh right, here it is:
    Qt Code:
    1. ######################################################################
    2. # Automatically generated by qmake (2.01a) Fri Jan 25 13:56:09 2008
    3. ######################################################################
    4.  
    5. TEMPLATE = app
    6. TARGET =
    7. DEPENDPATH += .
    8. INCLUDEPATH += .
    9.  
    10. # Input
    11. SOURCES += main.cpp
    To copy to clipboard, switch view to plain text mode 

    Right I made it without KDevelop and this is what gdb gave me when stepping through code.
    Qt Code:
    1. ~/MToDo/src$ gdb src
    2. GNU gdb 6.6-debian
    3. Copyright (C) 2006 Free Software Foundation, Inc.
    4. GDB is free software, covered by the GNU General Public License, and you are
    5. welcome to change it and/or distribute copies of it under certain conditions.
    6. Type "show copying" to see the conditions.
    7. There is absolutely no warranty for GDB. Type "show warranty" for details.
    8. This GDB was configured as "i486-linux-gnu"...
    9. Using host libthread_db library "/lib/tls/i686/cmov/libthread_db.so.1".
    10. (gdb) break main
    11. Breakpoint 1 at 0x8048596: file main.cpp, line 5.
    12. (gdb) run
    13. Starting program: /home/defumar/MToDo/src/src
    14. [Thread debugging using libthread_db enabled]
    15. [New Thread -1224051008 (LWP 6910)]
    16. [Switching to Thread -1224051008 (LWP 6910)]
    17.  
    18. Breakpoint 1, main (argc=1, argv=0xbfb26af4) at main.cpp:5
    19. 5 QApplication app(argc, argv);
    20. (gdb) n
    21. Qt: gdb: -nograb added to command-line options.
    22. Use the -dograb option to enforce grabbing.
    23. 7 return 0;
    24. (gdb) n
    25. 8 }
    26. (gdb) n
    27. 0xb743b050 in __libc_start_main () from /lib/tls/i686/cmov/libc.so.6
    28. (gdb) n
    29. Single stepping until exit from function __libc_start_main,
    30. which has no line number information.
    31.  
    32. Program exited normally.
    33. (gdb) q
    To copy to clipboard, switch view to plain text mode 

    backtrace after executing line 5 (evil line, ain't it) returns the same as before (argc=Cannot access mem at 0x0)
    Last edited by defumar; 26th January 2008 at 11:55.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Cannot access memory at address 0x0

    From the above output it seems the program executes correctly. Or am I wrong?

  9. #9
    Join Date
    Jan 2008
    Posts
    21
    Thanks
    3

    Default Re: Cannot access memory at address 0x0

    The above output shows that the program seems to execute correctly but in a different gdb session I backtraced a couple of times and noticed that after line 5 argc=Cannot access mem at 0x0
    Which doesn't seem correct to me though. argc should still be valid as it was at line 5. Instead it shows that apparantly it got corrupted :\ Correct me if I'm wrong.
    Last edited by defumar; 26th January 2008 at 14:13.

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Cannot access memory at address 0x0

    Could you show us a print from a gdb session that segfaults the project? And are you sure this is not actually gdb that segfaults and not the project?

  11. #11
    Join Date
    Jan 2008
    Posts
    21
    Thanks
    3

    Default Re: Cannot access memory at address 0x0

    Qt Code:
    1. ~/MToDo/src$ gdb src
    2. GNU gdb 6.6-debian
    3. Copyright (C) 2006 Free Software Foundation, Inc.
    4. GDB is free software, covered by the GNU General Public License, and you are
    5. welcome to change it and/or distribute copies of it under certain conditions.
    6. Type "show copying" to see the conditions.
    7. There is absolutely no warranty for GDB. Type "show warranty" for details.
    8. This GDB was configured as "i486-linux-gnu"...
    9. Using host libthread_db library "/lib/tls/i686/cmov/libthread_db.so.1".
    10. (gdb) break main
    11. Breakpoint 1 at 0x8048596: file main.cpp, line 5.
    12. (gdb) run
    13. Starting program: /home/defumar/MToDo/src/src
    14. [Thread debugging using libthread_db enabled]
    15. [New Thread -1224476992 (LWP 6527)]
    16. [Switching to Thread -1224476992 (LWP 6527)]
    17.  
    18. Breakpoint 1, main (argc=1, argv=0xbf9218f4) at main.cpp:5
    19. 5 QApplication app(argc, argv);
    20. (gdb) bt
    21. #0 main (argc=1, argv=0xbf9218f4) at main.cpp:5
    22. (gdb) n
    23. Qt: gdb: -nograb added to command-line options.
    24. Use the -dograb option to enforce grabbing.
    25. 7 return 0;
    26. (gdb) bt
    27. #0 main (argc=Cannot access memory at address 0x0
    28. ) at main.cpp:7
    29. (gdb) p argc
    30. Cannot access memory at address 0x0
    31. (gdb) n
    32. 8 }
    33. (gdb) bt
    34. #0 main (argc=0, argv=0xa9) at main.cpp:8
    35. (gdb) n
    36. 0xb73d3050 in __libc_start_main () from /lib/tls/i686/cmov/libc.so.6
    37. (gdb) n
    38. Single stepping until exit from function __libc_start_main,
    39. which has no line number information.
    40.  
    41. Program exited normally.
    To copy to clipboard, switch view to plain text mode 

    I am not sure whether the debugger messes up or the project itself, frankly I have no idea. Are there other debuggers I could try?

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Cannot access memory at address 0x0

    It's not the QApplication constructor that segfaults, look that something happens at line 7. argc changes from 1 to 0. Do examples bundles with Qt build and run correctly? Are you able to run any Qt4 based application?

Similar Threads

  1. Memory leak weirdness
    By Darhuuk in forum General Programming
    Replies: 10
    Last Post: 10th January 2008, 18:51
  2. Memory Leak in my Application :-(
    By Svaths in forum Qt Programming
    Replies: 4
    Last Post: 27th July 2007, 19:42
  3. what is free store in C++ memory?
    By Masih in forum General Programming
    Replies: 6
    Last Post: 2nd July 2007, 22:25
  4. Qt 4.1.1 linker warnings
    By Matt Smith in forum Installation and Deployment
    Replies: 0
    Last Post: 26th February 2006, 22:14

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
  •  
Qt is a trademark of The Qt Company.