Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. pointer changing, without using anything in code
Qt 6.12 LTS is out! See what's new in the release blog

pointer changing, without using anything in code

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 4 Posters 1.8k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    micha_eleric
    wrote on last edited by micha_eleric
    #5
    __name__
    CThreadController::CThreadController  () 
    main threcon = 0x564ac2f50fe0
    CGUI::CGUI() 
    CGUI::InitTestBoard 
    InitTestBoard try begin 
    InitTestBoard try 2 
    InitTestBoard try end 
    CGUI::InitDistance 
    CGUI::InitCalibration 
    CGUI::InitMotor 
    main gui = 0x564ac2f677c0
    main cont = 0x564ac3478010
    CThreadController gui = 0x564ac2f677c0
    CThreadController cont = 0x564ac3478010
    CGUI::SetController controller = 0x564ac2f50fe0
    CControls::SetController begin 
    CThreadController::startThreads begin
    CThreadController::startThreads m_controls = 0x564ac3478010
    CThreadController::startThreads m_gui = 0x564ac2f677c0
    CThreadController::startThreads this = 0x564ac2f50fe0
    CThreadController::startThreads m_controls = 0x564ac3478010
    CThreadController::startThreads m_gui = 0x564ac2f677c0
    CThreadController::startThreads() end
    CThreadController::ShowPointers m_controls = 0x564ac3478010
    CThreadController::ShowPointers m_gui = 0x564ac2f677c0
    Btn_motor_update_Clicked begin 
    CGUI::Btn_motor_update_Clicked pin = 12
    CControls::SetNumPinPerBoard this = 0x564ac3478010
    CControls::SetNumPinPerBoard n = 12
    CGUI::Btn_motor_update_Clicked step = 4
    CControls::SetStepMtrPst n = 4
    CControls::SetStepMtrPst this = 0x564ac3478010
    CControls::SetStepMtrPst m_iStepMtrPst = 4
    CGUI::Btn_motor_update_Clicked m_threadcontroller = 0x564ac2f50fe0
    CThreadController::SetNumMotorPos m_controls = 0x564ac3492190
    CThreadController::SetNumMotorPos m_gui = 0x564a800000ee
    CControls::SetNumMotorPos begin 
    CControls::SetNumMotorPos this = 0x564ac3492190
    CControls::SetNumMotorPos m_threadcontroller = 0x7f74f0b38980
    CControls::SetNumMotorPos m_iStepMtrPst = 0
    CMotor::SetNumMotorPos begin 
    num = 0
    error: CMotor.SetNumMotorPos() 
    Btn_motor_update_Clicked end 
    Press <RETURN> to close this window...
    
    

    where and why is class data m_controls and m_gui changing in class CThreadController?

    class data m_threadcontroller is not changing in class CGUI, but is changing in class CControls?

    Christian EhrlicherC 1 Reply Last reply
    0
    • M micha_eleric
      __name__
      CThreadController::CThreadController  () 
      main threcon = 0x564ac2f50fe0
      CGUI::CGUI() 
      CGUI::InitTestBoard 
      InitTestBoard try begin 
      InitTestBoard try 2 
      InitTestBoard try end 
      CGUI::InitDistance 
      CGUI::InitCalibration 
      CGUI::InitMotor 
      main gui = 0x564ac2f677c0
      main cont = 0x564ac3478010
      CThreadController gui = 0x564ac2f677c0
      CThreadController cont = 0x564ac3478010
      CGUI::SetController controller = 0x564ac2f50fe0
      CControls::SetController begin 
      CThreadController::startThreads begin
      CThreadController::startThreads m_controls = 0x564ac3478010
      CThreadController::startThreads m_gui = 0x564ac2f677c0
      CThreadController::startThreads this = 0x564ac2f50fe0
      CThreadController::startThreads m_controls = 0x564ac3478010
      CThreadController::startThreads m_gui = 0x564ac2f677c0
      CThreadController::startThreads() end
      CThreadController::ShowPointers m_controls = 0x564ac3478010
      CThreadController::ShowPointers m_gui = 0x564ac2f677c0
      Btn_motor_update_Clicked begin 
      CGUI::Btn_motor_update_Clicked pin = 12
      CControls::SetNumPinPerBoard this = 0x564ac3478010
      CControls::SetNumPinPerBoard n = 12
      CGUI::Btn_motor_update_Clicked step = 4
      CControls::SetStepMtrPst n = 4
      CControls::SetStepMtrPst this = 0x564ac3478010
      CControls::SetStepMtrPst m_iStepMtrPst = 4
      CGUI::Btn_motor_update_Clicked m_threadcontroller = 0x564ac2f50fe0
      CThreadController::SetNumMotorPos m_controls = 0x564ac3492190
      CThreadController::SetNumMotorPos m_gui = 0x564a800000ee
      CControls::SetNumMotorPos begin 
      CControls::SetNumMotorPos this = 0x564ac3492190
      CControls::SetNumMotorPos m_threadcontroller = 0x7f74f0b38980
      CControls::SetNumMotorPos m_iStepMtrPst = 0
      CMotor::SetNumMotorPos begin 
      num = 0
      error: CMotor.SetNumMotorPos() 
      Btn_motor_update_Clicked end 
      Press <RETURN> to close this window...
      
      

      where and why is class data m_controls and m_gui changing in class CThreadController?

      class data m_threadcontroller is not changing in class CGUI, but is changing in class CControls?

      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #6

      @micha_eleric said in pointer changing, without using anything in code:

      where and why is class data m_controls and m_gui changing in class CThreadController?

      Provide a minimal, compilable example instead posting the whole question over and over without any real information.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      M 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        @micha_eleric said in pointer changing, without using anything in code:

        where and why is class data m_controls and m_gui changing in class CThreadController?

        Provide a minimal, compilable example instead posting the whole question over and over without any real information.

        M Offline
        M Offline
        micha_eleric
        wrote on last edited by
        #7

        @Christian-Ehrlicher said in pointer changing, without using anything in code:

        @micha_eleric said in pointer changing, without using anything in code:

        where and why is class data m_controls and m_gui changing in class CThreadController?

        Provide a minimal, compilable example instead posting the whole question over and over without any real information.

        i assume the minimum would be no code, since i can not find anything in my code to create the error. i posted everything of my code, where the error showed up. i keep adding more std::cout, trying to figure out between my code and my code it is happening.

        Paul ColbyP 1 Reply Last reply
        0
        • M Offline
          M Offline
          micha_eleric
          wrote on last edited by
          #8

          added

          std::cout << "CControls::SetNumMotorPos m_threadcontroller = " << m_threadcontroller << '\n' << std::flush;
          

          causes it to crash with multiple tries.
          what i thought was a different m_threadcontroller in CControls, but was also a different CControls object, which i still question where the second CControls and CGUI object came from, when no new objects are created

          1 Reply Last reply
          0
          • M Offline
            M Offline
            micha_eleric
            wrote on last edited by
            #9

            finally got a try to not crash

            main threcon = 0x55b88df8dd00
            CGUI::CGUI() 
            CGUI::InitTestBoard 
            InitTestBoard try begin 
            InitTestBoard try 2 
            InitTestBoard try end 
            CGUI::InitDistance 
            CGUI::InitCalibration 
            CGUI::InitMotor 
            main gui = 0x55b88df72d40
            main cont = 0x55b88e483610
            CThreadController gui = 0x55b88df72d40
            CThreadController cont = 0x55b88e483610
            CGUI::SetController controller = 0x55b88df8dd00
            CControls::SetController begin 
            CThreadController::startThreads begin
            CThreadController::startThreads m_controls = 0x55b88e483610
            CThreadController::startThreads m_gui = 0x55b88df72d40
            CThreadController::startThreads this = 0x55b88df8dd00
            CThreadController::startThreads m_controls = 0x55b88e483610
            CThreadController::startThreads m_gui = 0x55b88df72d40
            CThreadController::startThreads() end
            CThreadController::ShowPointers m_controls = 0x55b88e483610
            CThreadController::ShowPointers m_gui = 0x55b88df72d40
            Btn_motor_update_Clicked begin 
            CGUI::Btn_motor_update_Clicked pin = 12
            CControls::SetNumPinPerBoard this = 0x55b88e483610
            CControls::SetNumPinPerBoard m_threadcontroller = 0x55b88df8dd00
            CControls::SetNumPinPerBoard n = 12
            CGUI::Btn_motor_update_Clicked step = 4
            CControls::SetStepMtrPst this = 0x55b88e483610
            CControls::SetStepMtrPst m_threadcontroller = 0x55b88df8dd00
            CControls::SetStepMtrPst n = 4
            CControls::SetStepMtrPst m_iStepMtrPst = 4
            CGUI::Btn_motor_update_Clicked m_threadcontroller = 0x55b88df8dd00
            CThreadController::SetNumMotorPos this = 0x55b88df8dd00
            CThreadController::SetNumMotorPos m_controls = 0x55b88e6bd590
            CThreadController::SetNumMotorPos m_gui = 0x55b8800000ef
            CControls::SetNumMotorPos begin 
            CControls::SetNumMotorPos this = 0x55b88e6bd590
            CControls::SetNumMotorPos m_threadcontroller = 0x7fe7fc8aa668
            CControls::SetNumMotorPos m_iStepMtrPst = -11711155
            CMotor::SetNumMotorPos begin 
            num = -11711155
            error: CMotor.SetNumMotorPos() 
            Btn_motor_update_Clicked end 
            Press <RETURN> to close this window...
            

            correct CThreadController points to wrong CControls points back to wrong CThreadControlls

            1 Reply Last reply
            0
            • M Offline
              M Offline
              micha_eleric
              wrote on last edited by
              #10

              change of pointers occur between

              void CThreadController::startThreads()
              

              and

              void CGUI::Btn_motor_update_Clicked()
              

              from what i can find

              1 Reply Last reply
              0
              • M Offline
                M Offline
                micha_eleric
                wrote on last edited by micha_eleric
                #11
                __name__
                CThreadController::CThreadController  () 
                main threcon = 0x561d71086500
                CGUI::CGUI 
                CGUI::InitTestBoard 
                InitTestBoard try begin 
                InitTestBoard try 2 
                InitTestBoard try end 
                CGUI::InitDistance 
                CGUI::InitCalibration 
                CGUI::InitMotor 
                main gui = 0x561d710809a0
                CControls::Constructor 
                main cont = 0x561d71590fd0
                CThreadController gui = 0x561d710809a0
                CThreadController cont = 0x561d71590fd0
                CGUI::SetController controller = 0x561d71086500
                CControls::SetController begin 
                CThreadController::startThreads begin
                CThreadController::startThreads m_controls = 0x561d71590fd0
                CThreadController::startThreads m_gui = 0x561d710809a0
                CThreadController::startThreads this = 0x561d71086500
                CThreadController::startThreads m_controls = 0x561d71590fd0
                CThreadController::startThreads m_gui = 0x561d710809a0
                CThreadController::startThreads() end
                CThreadController::ShowPointers m_controls = 0x561d71590fd0
                CThreadController::ShowPointers m_gui = 0x561d710809a0
                Btn_motor_update_Clicked begin 
                CThreadController::ShowPointers m_controls = 0x561d00000021
                CThreadController::ShowPointers m_gui = 0x561d7172ae70
                CGUI::Btn_motor_update_Clicked pin = 12
                CControls::SetNumPinPerBoard this = 0x561d71590fd0
                CControls::SetNumPinPerBoard m_threadcontroller = 0x561d71086500
                CControls::SetNumPinPerBoard n = 12
                CThreadController::ShowPointers m_controls = 0x561d00000021
                CThreadController::ShowPointers m_gui = 0x561d7172ae70
                CGUI::Btn_motor_update_Clicked step = 4
                CControls::SetStepMtrPst this = 0x561d71590fd0
                CControls::SetStepMtrPst m_threadcontroller = 0x561d71086500
                CControls::SetStepMtrPst n = 4
                CControls::SetStepMtrPst m_iStepMtrPst = 4
                CGUI::Btn_motor_update_Clicked m_threadcontroller = 0x561d71086500
                CThreadController::SetNumMotorPos this = 0x561d71086500
                CThreadController::SetNumMotorPos m_controls = 0x561d00000021
                CThreadController::SetNumMotorPos m_gui = 0x561d7172ae70
                CControls::SetNumMotorPos begin 
                CControls::SetNumMotorPos this = 0x561d00000021
                Press <RETURN> to close this window...
                

                from std::cout output, it is clear the my code in main calls

                threcon->startThreads();
                

                at the end of

                void CThreadController::startThreads()
                

                the only 3 pointers my code creates/calls constructors, are what they are suppose to be.
                next

                    threcon->ShowPointers();
                    gui->show();
                    return app.exec();
                

                then button is pushed, calling

                void CGUI::Btn_BoardUpdate_Clicked()
                

                which, without calling any constructors, there are 3 new pointers created out of thin air.
                what/where/why are the 3 new pointers coming from?
                only possible answers i come up with:
                does qt create, create pointers that do not call constructors?
                when

                connect(m_gui, &CNC::CGUI::emitRun, m_controls, &CNC::CControls::Run);
                

                does it create a duplicate pointers, which does not call constructors?

                dont know what else could be happening.
                if i reset the pointers in CThreadController, would whatever created new pointers, without calling a constructor, do it again. would i have to reset the pointers, every time a button is clicked?

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  micha_eleric
                  wrote on last edited by
                  #12

                  i tried a copy constructor, but it was not called

                  1 Reply Last reply
                  0
                  • M micha_eleric

                    @Christian-Ehrlicher said in pointer changing, without using anything in code:

                    @micha_eleric said in pointer changing, without using anything in code:

                    where and why is class data m_controls and m_gui changing in class CThreadController?

                    Provide a minimal, compilable example instead posting the whole question over and over without any real information.

                    i assume the minimum would be no code, since i can not find anything in my code to create the error. i posted everything of my code, where the error showed up. i keep adding more std::cout, trying to figure out between my code and my code it is happening.

                    Paul ColbyP Offline
                    Paul ColbyP Offline
                    Paul Colby
                    wrote on last edited by
                    #13

                    @micha_eleric said in pointer changing, without using anything in code:

                    i assume the minimum would be no code, since i can not find anything in my code to create the error.

                    Your assumption is very likely wrong. The thing is, with errors like this, it is very commonly the case that code elsewhere in your application has a memory error, but that the effect of that error is not visible until later (eg an earlier memory error could have overwritten your code segement, so your code no longer matches what you're reading in your editor). In other words, the bug might be nowhere near the crash (or pointer change) as far as lines of code goes.

                    There's a couple of approaches I've found to work in cases like this:

                    1. use a static analysis tool, like cppcheck (it's not going to pick up subtle things, but its so quick and easy to start with).
                    2. use a memory fencing tool, like valgrind
                    3. slowly remove as much code as possible, including (especially) code elsewhere that you assume couldn't possibly be related to this area of the code (I've been surprised plenty of times ;)

                    In particular, the exercise of cutting it down to "a minimal, compilable example", as @Christian-Ehrlicher suggested, will effectively force you to do #3 anyway, and often you'll discover the bug in that process, before you even get to posting the minimal example. But if you do get it down to a minimal compilable example, do share it! :D

                    Good luck!

                    1 Reply Last reply
                    2
                    • M Offline
                      M Offline
                      micha_eleric
                      wrote on last edited by micha_eleric
                      #14

                      well, if i comment out

                      m_controls->start();
                      

                      in

                      // function
                          void CThreadController::startThreads()
                          {
                              m_controls->start();
                          }
                      

                      then the pointers do not change

                      start();
                      

                      is not my code.

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt
                      • Unsolved