
Dear OpenMesh Devs, It appears now to me that there is a problem when using IO::write concurrently, from different threads even though these write operations should be independent as they operate on separate meshes and separate streams. When I move the writing operations outside my parallel section, it works fine. When inside the parallel section, I'm getting the double free error quite randomly so I assume that whenever writing is attempted at the same time from multiple threads, it fails. Any idea about why this is happening or any fix would be greatly appreciated. Thank you, Botond

Hi Botond, I'd recommend trying to use ASAN, the address sanitizer compiler extension (available in the major compilers) on a debug build. With a little bit of luck, it might exactly pinpoint the issue. There are also other sanitizers which might be fruitful in this scenario, e.g. ThreadSanitizer (tsan), possibly UndefinedBehaviorSanitizer (UBsan). Best Regards Martin Heistermann On 2/1/21 5:09 PM, btyukodi@brandeis.edu wrote:
Dear OpenMesh Devs,
It appears now to me that there is a problem when using IO::write concurrently, from different threads even though these write operations should be independent as they operate on separate meshes and separate streams. When I move the writing operations outside my parallel section, it works fine. When inside the parallel section, I'm getting the double free error quite randomly so I assume that whenever writing is attempted at the same time from multiple threads, it fails. Any idea about why this is happening or any fix would be greatly appreciated.
Thank you, Botond _______________________________________________ OpenMesh mailing list -- openmesh@lists.rwth-aachen.de To unsubscribe send an email to openmesh-leave@lists.rwth-aachen.de https://lists.rwth-aachen.de/postorius/lists/openmesh.lists.rwth-aachen.de
-- Martin Heistermann Universitaet Bern, Institut fuer Informatik Neubrueckstr. 10, CH-3012 Bern Tel +41 31 511 76 06

Hi Botond, from your backtrace it looks like the crash happens in omlog(). I'm not familiar with the logging code but it seems there is code in place to make logging thread safe if you are using c++11. However, it seems that the code within the "if (!initialized) {...}" block (line 64 of OpenMesh/Core/System/omstream.cc) could be executed by multiple threads if they arrive concurrently the first time omlog() is called. Could you try to call omlog() before spawning your threads to see if this fixes the problem? Kind regards, Max On 2/1/21 5:28 PM, Martin Heistermann wrote:
Hi Botond,
I'd recommend trying to use ASAN, the address sanitizer compiler extension (available in the major compilers) on a debug build. With a little bit of luck, it might exactly pinpoint the issue.
There are also other sanitizers which might be fruitful in this scenario, e.g. ThreadSanitizer (tsan), possibly UndefinedBehaviorSanitizer (UBsan).
Best Regards
Martin Heistermann
On 2/1/21 5:09 PM, btyukodi@brandeis.edu wrote:
Dear OpenMesh Devs,
It appears now to me that there is a problem when using IO::write concurrently, from different threads even though these write operations should be independent as they operate on separate meshes and separate streams. When I move the writing operations outside my parallel section, it works fine. When inside the parallel section, I'm getting the double free error quite randomly so I assume that whenever writing is attempted at the same time from multiple threads, it fails. Any idea about why this is happening or any fix would be greatly appreciated.
Thank you, Botond _______________________________________________ OpenMesh mailing list -- openmesh@lists.rwth-aachen.de To unsubscribe send an email to openmesh-leave@lists.rwth-aachen.de https://lists.rwth-aachen.de/postorius/lists/openmesh.lists.rwth-aachen.de
-- Max Lyon, M.Sc. Department of Computer Sciences 8 RWTH Aachen University Ahornstrasse 55, 52074 Aachen, Germany

Dear Max, Thank you very much for your input! Apparently your solution fixes the problem: I call omlog() before spawning the threads and I haven't got the double free error ever since. Thanks again, Botond

Hi Martin, Thanks a lot for your answer! I don't have much experience with multithreading and I will look into the tools you recommended. For the record, this particular problem seems to have been solved by Max's suggestion above. Thanks and all the best, Botond
participants (3)
-
btyukodi@brandeis.edu
-
Martin Heistermann
-
Max Lyon