NVIDIAGameWorks / PhysX-3.4

NVIDIA PhysX SDK 3.4
https://www.nvidia.com/
2.35k stars 273 forks source link

Fix undefined behavior in PxUnionCast #65

Open rsfb opened 6 years ago

rsfb commented 6 years ago

Fixes crash in linux with a new version of clang.

The C++ standard does not define behavior of accessing a different union member from the one that was last written. std::memcpy is a defined way to accomplish the same.

AlesBorovicka commented 6 years ago

Hi, please, can you give us the clang version so we can try to reproduce the crash on our side? Thanks a lot, regards Ales

rsfb commented 6 years ago

Hi Ales,

Thanks for the quick reply! LLVM versions r327616 and r327695 were the ones we tested.

A bit more detail:

In PsUnixSse2InlineAoS.h there's a gMaskXYZ constant which is initialised with the output of PxUnionCast - with these new compiler versions, the mask had all zeros on all 4 components (instead of all 1, all 1, all 1, all 0 as intended).

Cheers, Ricardo

rsfb commented 6 years ago

Hi again Ales,

Was this or a similar fix submitted? Currently we have fixed the gMaskXYZ = 0 problem with the change in this PR.

Regards, Ricardo

AlesBorovicka commented 6 years ago

Hi Ricardo, no, we have not fixed the issue yet. Still not resolved. Regards, Ales

AlesBorovicka commented 6 years ago

The issue should be resolved in next update. Thanks for the report!