Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Problem running the address sanitizer on MacOs
QtWS25 Last Chance

Problem running the address sanitizer on MacOs

Scheduled Pinned Locked Moved Solved Installation and Deployment
6 Posts 2 Posters 1.1k Views
  • 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.
  • D Offline
    D Offline
    davidesalvetti
    wrote on last edited by davidesalvetti
    #1

    Hi,

    I'm working on a project onMacOs 10.13.6 with Qt 5.12.2 clang64. Since my application may have problem with memory management I'm trying to set the address sanitizer to see if I can understand something. more (this is the post where I talk about my problem and where I've been suggested to use the address sanitizer). I followed this link to try to set it up: https://www.qt.io/blog/2013/04/17/using-gccs-4-8-0-address-sanitizer-with-qt

    I'm pretty new to Qt and I don't know really well where to put all the command mentioned in the link. What I've done so far is:

    • I put QMAKE_CXXFLAGS+="-fsanitize=address -fno-omit-frame-pointer" QMAKE_CFLAGS+="-fsanitize=address -fno-omit-frame-pointer" QMAKE_LFLAGS+="-fsanitize=address" in Projects->Build->Additional arguments

    • I tried to run the program in debug mode but I get this error:

    qt.qpa.plugin: Could not find the Qt platform plugin "cocoa" in ""
    This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
    
    • I've seen in a post that enabling the QT_DEBUG_PLUGINS would help on this error so I put QT_DEBUG_PLUGINS=1 in Projects->Run->Command line arguments

    But I still have the same error with no more information. Can somebody please tell me what I'm doing wrong?

    Thanks in advance!

    D 1 Reply Last reply
    0
    • D davidesalvetti

      Hi,

      I'm working on a project onMacOs 10.13.6 with Qt 5.12.2 clang64. Since my application may have problem with memory management I'm trying to set the address sanitizer to see if I can understand something. more (this is the post where I talk about my problem and where I've been suggested to use the address sanitizer). I followed this link to try to set it up: https://www.qt.io/blog/2013/04/17/using-gccs-4-8-0-address-sanitizer-with-qt

      I'm pretty new to Qt and I don't know really well where to put all the command mentioned in the link. What I've done so far is:

      • I put QMAKE_CXXFLAGS+="-fsanitize=address -fno-omit-frame-pointer" QMAKE_CFLAGS+="-fsanitize=address -fno-omit-frame-pointer" QMAKE_LFLAGS+="-fsanitize=address" in Projects->Build->Additional arguments

      • I tried to run the program in debug mode but I get this error:

      qt.qpa.plugin: Could not find the Qt platform plugin "cocoa" in ""
      This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
      
      • I've seen in a post that enabling the QT_DEBUG_PLUGINS would help on this error so I put QT_DEBUG_PLUGINS=1 in Projects->Run->Command line arguments

      But I still have the same error with no more information. Can somebody please tell me what I'm doing wrong?

      Thanks in advance!

      D Offline
      D Offline
      davidesalvetti
      wrote on last edited by
      #2

      I manage to use QT_DEBUG_PLUGINS putting this line before QApplication:

      qDebug() << qputenv("QT_DEBUG_PLUGINS", "1");
      

      And I can correctly see the debug plugin. Moreover I deleted the build folder and launched the program again with this option and the address sanitizer as said in the post above and now I don't get errors, that's strange since I only made a rebuild and inserted the line above. But let's suppose it's correct, how can I be sure the address sanitizer is working?

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        See this blog post. It should help you get started.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        D 1 Reply Last reply
        1
        • SGaistS SGaist

          Hi,

          See this blog post. It should help you get started.

          D Offline
          D Offline
          davidesalvetti
          wrote on last edited by
          #4

          @SGaist thanks for your answer but I think there is a misunderstanding.

          @davidesalvetti said in Problem running the address sanitizer on MacOs:

          I followed this link to try to set it up: https://www.qt.io/blog/2013/04/17/using-gccs-4-8-0-address-sanitizer-with-qt

          That's exactly the link I followed to set it up without success.

          Does the address sanitizer work both in debug and release mode?

          SGaistS 1 Reply Last reply
          0
          • D Offline
            D Offline
            davidesalvetti
            wrote on last edited by
            #5

            Finally I managed to use the address sanitizer. I don't really know what makes it work correctly. I put this line in the .pro file:

            CONFIG += sanitizer sanitize_address sanitize_leak sanitize_undefined
            

            and I deleted the debug folder to make a full build and it works!

            1 Reply Last reply
            2
            • D davidesalvetti

              @SGaist thanks for your answer but I think there is a misunderstanding.

              @davidesalvetti said in Problem running the address sanitizer on MacOs:

              I followed this link to try to set it up: https://www.qt.io/blog/2013/04/17/using-gccs-4-8-0-address-sanitizer-with-qt

              That's exactly the link I followed to set it up without success.

              Does the address sanitizer work both in debug and release mode?

              SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @davidesalvetti said in Problem running the address sanitizer on MacOs:

              @SGaist thanks for your answer but I think there is a misunderstanding.

              @davidesalvetti said in Problem running the address sanitizer on MacOs:

              I followed this link to try to set it up: https://www.qt.io/blog/2013/04/17/using-gccs-4-8-0-address-sanitizer-with-qt

              That's exactly the link I followed to set it up without success.

              Does the address sanitizer work both in debug and release mode?

              My bad, I managed to miss that link in your original post.

              I thought I wrote about the use of the CONFIG variable...

              Anyway, glad you got it working !

              Happy coding ! :-)

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              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 Extensions
              • Unsolved