Problem running the address sanitizer on MacOs
-
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!
-
-
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!
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?
-
-
@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?
-
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!
-
@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?
@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 ! :-)