Closed Bug 418558 Opened 17 years ago Closed 6 years ago

Detect use of memcpy/memset on non-POD types

Categories

(Developer Infrastructure :: Source Code Analysis, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1411029

People

(Reporter: kinetik, Unassigned)

Details

Attachments

(1 file)

While working on bug #418172, it occurred to me that being able to detect and warn about some unsafe operations on non-POD types would be very useful.  This seems like a useful check that our static analysis tools could perform.

Specifically I was thinking about detecting when a non-POD type is used as the source or destination of a memcpy (what happened in bug #418172 was that a class containing an nsCOMPtr was copying using memcpy, causing a ref counting problem), but there are other cases that would be equally useful to detect (e.g. memset, probably others too).
Status: NEW → ASSIGNED
Matthew, 
Dehydra GCC should be pretty good at detecting these already. Let me know if you want some help in drafting up a script for it.
Attached file first attempt (deleted) —
Assignee: nobody → kinetik
Looks good. Feel free to file a bug for the member access information or the crashes. The GCC ICEs are probably segfaults within the plugin--at least that's what they always were when I was working on my plugin.
Oops, looked like Taras already put in the isStatic attributes.
Actually the comment about ICEs in the script is a bit out of date. I was seeing them with an earlier version of the script, but I rewrote the script to be a bit more efficient and haven't seen them since, so I was probably running out of heap with the earlier version.  I've run a complete clobber build with the plugin and my script successfully (although I did have to make two Dehydra asserts non-fatal).

I'll be busy for a few days before the freeze, but I'll file bugs on the member access, asserts, and location info soon afterwards.
Assignee: kinetik → nobody
Product: Core → Firefox Build System
I believe this has mostly been accomplished by bug 1411029, via gcc-8 complaining about such memcpys.
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → DUPLICATE
Product: Firefox Build System → Developer Infrastructure
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: