Closed hugoam closed 6 years ago
Some update on the investigation from the user that had the second stacktrace : setting VG_CONFIG_ENABLE_SIMD=0
fixes the problem. So it's most probably an issue in vg SIMD implementation ?
Thanks for the report.
Short answer: Yes, this code seems to be problematic on GCC/Clang (tested on godbolt) because assigning an m128 to an m128 produces an aligned store and the memory isn't guaranteed to be aligned at that point. MSVC seems to always produce unaligned loads/stores that's why I haven't seen the bug.
Long answer: This code is my (apparently failed) attempt to convice the compiler to avoid emmiting memcpy's for small number of vertices. I think the main problem is bx::memCopy() which cannot be turned into an inlined memcpy. I either have to fix the __m128 loads/stores to explicetely use _mm_loadu_ps/_mm_storeu_ps or replace bx::memCopy with memcpy hoping it will be inlined by the compiler in the small cases of N.
Will try to fix asap and report back for further testing on your side.
Decided to replace bx::memCopy with the compiler's memcpy and removed the special cases from all the related functions (addPos(), addPosColor() and addIndices()).
Please check the latest code and report back as soon as you find the time.
For the record, I tested it with my game with no noticable performance difference, so I don't know what I saw that made me write that code in the first place :) Most probably I saw calls to memcpy/bx::memMove/MoveSmall in the profiler and I tried to eliminate them.
Thanks for the quick fix :)
I'll report back, but since the memcpy path (with VG_CONFIG_ENABLE_SIMD=0
) apparently wasn't failing, the fix should work !
I think we can close this issue now
A few people have been reporting a segmentation faults when using toy/mud, on some specific platforms, happening inside
stroker.cpp
. https://github.com/hugoam/mud-sample/issues/1 This error dates from before you made some changes to that code recently, but I also have a more recent stacktrace from after your recent changes tostroker.cpp
(see after). The first one seems like a Ubuntu 16.04 64 bits build, and the second is a macOS 64 bits build.It's hard for me to guess what's going wrong (there's a looot of potentially unsafe manual pointer operations in there), but my first feeling is that for something like that to happen, while mud otherwise works fine on other platforms/architecture, it's probably a problem internal to vg-renderer and not an issue in the calling code. But it's hard to know for sure though, so I'd be happy to get your input on this :)
Do you know how we could investigate why this error is happening ?