Skip to content

Commit e803bbc

Browse files
committed
Modernize viewer alignment macros to use alignas and fix misaligned class issues reported by ubsan/asan
Signed-off-by: Rye <[email protected]>
1 parent b1a9688 commit e803bbc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+114
-143
lines changed

indra/llappearance/llavatarjoint.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ extern const F32 DEFAULT_AVATAR_JOINT_LOD;
4141
//-----------------------------------------------------------------------------
4242
// class LLViewerJoint
4343
//-----------------------------------------------------------------------------
44-
class LLAvatarJoint :
44+
class alignas(16) LLAvatarJoint :
4545
public LLJoint
4646
{
47+
LL_ALIGN_NEW
4748
public:
4849
LLAvatarJoint();
4950
LLAvatarJoint(S32 joint_num);
@@ -121,8 +122,9 @@ class LLAvatarJoint :
121122
S32 mMeshID;
122123
};
123124

124-
class LLAvatarJointCollisionVolume : public LLAvatarJoint
125+
class alignas(16) LLAvatarJointCollisionVolume : public LLAvatarJoint
125126
{
127+
LL_ALIGN_NEW
126128
public:
127129
LLAvatarJointCollisionVolume();
128130
virtual ~LLAvatarJointCollisionVolume() {};

indra/llappearance/llavatarjointmesh.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ class LLSkinJoint
5959
//-----------------------------------------------------------------------------
6060
// class LLViewerJointMesh
6161
//-----------------------------------------------------------------------------
62-
class LLAvatarJointMesh : public virtual LLAvatarJoint
62+
class alignas(16) LLAvatarJointMesh : public virtual LLAvatarJoint
6363
{
64+
LL_ALIGN_NEW
6465
protected:
6566
LLColor4 mColor; // color value
6667
// LLColor4 mSpecular; // specular color (always white for now)

indra/llappearance/lldriverparam.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class alignas(16) LLDriverParam : public LLViewerVisualParam
128128
void setDrivenWeight(LLDrivenEntry* driven, F32 driven_weight);
129129

130130

131-
LL_ALIGN_16(LLVector4a mDefaultVec); // temp holder
131+
LLVector4a mDefaultVec; // temp holder
132132
entry_list_t mDriven;
133133
LLViewerVisualParam* mCurrentDistortionParam{ nullptr };
134134
// Backlink only; don't make this an LLPointer.

indra/llappearance/llpolymorph.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class alignas(16) LLPolyMorphData
7171

7272
private:
7373
void freeData();
74-
} LL_ALIGN_POSTFIX(16);
74+
};
7575

7676

7777
//-----------------------------------------------------------------------------

indra/llappearance/llpolyskeletaldistortion.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,13 @@ class alignas(16) LLPolySkeletalDistortion : public LLViewerVisualParam
111111
protected:
112112
LLPolySkeletalDistortion(const LLPolySkeletalDistortion& pOther);
113113

114-
LL_ALIGN_16(LLVector4a mDefaultVec);
114+
LLVector4a mDefaultVec;
115115
typedef std::map<LLJoint*, LLVector3> joint_vec_map_t;
116116
joint_vec_map_t mJointScales;
117117
joint_vec_map_t mJointOffsets;
118118
// Backlink only; don't make this an LLPointer.
119119
LLAvatarAppearance *mAvatar;
120-
} LL_ALIGN_POSTFIX(16);
120+
};
121121

122122
#endif // LL_LLPOLYSKELETALDISTORTION_H
123123

indra/llappearance/lltexlayerparams.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ class LLTexLayerParam : public LLViewerVisualParam
6363
// LLTexLayerParamAlpha
6464
//
6565
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
66-
LL_ALIGN_PREFIX(16)
6766
class alignas(16) LLTexLayerParamAlpha : public LLTexLayerParam
6867
{
6968
LL_ALIGN_NEW
@@ -103,7 +102,7 @@ class alignas(16) LLTexLayerParamAlpha : public LLTexLayerParam
103102
LLPointer<LLImageRaw> mStaticImageRaw;
104103
std::atomic<bool> mNeedsCreateTexture;
105104
bool mStaticImageInvalid;
106-
LL_ALIGN_16(LLVector4a mAvgDistortionVec);
105+
LLVector4a mAvgDistortionVec;
107106
F32 mCachedEffectiveWeight;
108107

109108
public:
@@ -113,7 +112,7 @@ class alignas(16) LLTexLayerParamAlpha : public LLTexLayerParam
113112

114113
typedef std::list< LLTexLayerParamAlpha* > param_alpha_ptr_list_t;
115114
static param_alpha_ptr_list_t sInstances;
116-
} LL_ALIGN_POSTFIX(16);
115+
};
117116
class LLTexLayerParamAlphaInfo : public LLViewerVisualParamInfo
118117
{
119118
friend class LLTexLayerParamAlpha;

indra/llappearance/llviewervisualparam.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ class LLViewerVisualParamInfo : public LLVisualParamInfo
6565
// VIRTUAL CLASS
6666
// a viewer side interface class for a generalized parametric modification of the avatar mesh
6767
//-----------------------------------------------------------------------------
68-
LL_ALIGN_PREFIX(16)
69-
class LLViewerVisualParam : public LLVisualParam
68+
class alignas(16) LLViewerVisualParam : public LLVisualParam
7069
{
7170
public:
7271
LLViewerVisualParam();
@@ -107,6 +106,6 @@ class LLViewerVisualParam : public LLVisualParam
107106

108107
protected:
109108
LLViewerVisualParam(const LLViewerVisualParam& pOther);
110-
} LL_ALIGN_POSTFIX(16);
109+
};
111110

112111
#endif // LL_LLViewerVisualParam_H

indra/llappearanceutility/llbakingavatar.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,7 @@ class LLBakingAvatar : public LLAvatarAppearance
3838
** INITIALIZATION
3939
**/
4040
public:
41-
void* operator new(size_t size)
42-
{
43-
return ll_aligned_malloc_16(size);
44-
}
45-
46-
void operator delete(void* ptr)
47-
{
48-
ll_aligned_free_16(ptr);
49-
}
41+
LL_ALIGN_NEW
5042

5143
LLBakingAvatar(LLWearableData* wearable_data, S32 bakeTextureSize = 512);
5244
virtual ~LLBakingAvatar();

indra/llappearanceutility/llbakingjoint.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929

3030
#include "llavatarjoint.h"
3131

32-
class LLBakingJoint : public virtual LLAvatarJoint
32+
class alignas(16) LLBakingJoint : public virtual LLAvatarJoint
3333
{
34+
LL_ALIGN_NEW
3435
public:
3536
LLBakingJoint();
3637
LLBakingJoint(S32 joint_num);

indra/llappearanceutility/llbakingjointmesh.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@
3030
#include "llavatarjointmesh.h"
3131
#include "llbakingjoint.h"
3232

33-
class LLBakingJointMesh : public LLAvatarJointMesh, public LLBakingJoint
33+
class alignas(16) LLBakingJointMesh : public LLAvatarJointMesh, public LLBakingJoint
3434
{
35+
LL_ALIGN_NEW
3536
public:
3637
LLBakingJointMesh();
3738
LLBakingJointMesh(S32 joint_num);

0 commit comments

Comments
 (0)