strict aliasing bugs in LDAP C SDK

RESOLVED FIXED in 5.11

Status

Directory
LDAP C SDK
P2
normal
RESOLVED FIXED
15 years ago
15 years ago

People

(Reporter: Brian Ryner (not reading), Assigned: mcs)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: tm511)

Attachments

(1 attachment)

(Reporter)

Description

15 years ago
cvs builds of gcc give the following warnings for the LDAP SDK
(ldapcsdk_50_client_branch):

memcache.c:1416: warning: dereferencing type-punned pointer will break
strict-aliasing rules
memcache.c:1446: warning: dereferencing type-punned pointer will break
strict-aliasing rules
memcache.c:1520: warning: dereferencing type-punned pointer will break
strict-aliasing rules

Since strict aliasing is now enabled by default for gcc with -O2, we should fix
this.  Strict aliasing bugs can cause all sorts of weird problems; for some
background see http://gcc.gnu.org/ml/gcc/1999-08n/msg00646.html .  It looks like
the fix in this case is to use an explicit temporary void* pointer.
(Reporter)

Comment 1

15 years ago
Created attachment 103565 [details] [diff] [review]
proposed patch
(Assignee)

Updated

15 years ago
Attachment #103565 - Flags: review+
(Assignee)

Comment 2

15 years ago
Comment on attachment 103565 [details] [diff] [review]
proposed patch

r=mcs.

Intersting. Although I did not write it, I am not sure how the existing code in
libldap/memcache.c could cause any real problems. But I don't write compilers
for a living either.
(Reporter)

Comment 3

15 years ago
I think in this case the warnings are harmless.  I don't see the potential for
any problems with aliasing unless a struct is written to and read as two
different (unrelated) pointer types within the same function.
(Assignee)

Updated

15 years ago
Status: NEW → ASSIGNED
Whiteboard: tm511
(Assignee)

Comment 4

15 years ago
Set priority.
Priority: -- → P2
(Assignee)

Comment 5

15 years ago
Fix committed to the trunk:

mozilla/directory/c-sdk/ldap/libraries/libldap/memcache.c
  new revision: 5.2; previous revision: 5.1
    Fix bug # 175727 - strict aliasing bugs in LDAP C SDK.
        Avoid casts like (void**)&pRes; use temporary local variables
        instead.

Do we also want this fixed on ldapcsdk_50_client_branch right away?
(Reporter)

Comment 6

15 years ago
There's no huge rush.  All we're really doing here is working around the
warnings; I don't think this is causing any actual bugs.
(Assignee)

Comment 7

15 years ago
Marking bug as fixed. We will pick this up in the Mozilla client builds when
those builds move to an update LDAP C SDK branch.
Status: ASSIGNED → RESOLVED
Last Resolved: 15 years ago
Resolution: --- → FIXED
(Assignee)

Updated

15 years ago
Target Milestone: --- → 5.11

Comment 8

15 years ago
Spam for bug 129472
QA Contact: nobody → nobody
You need to log in before you can comment on or make changes to this bug.