zeusdeux / re2

Automatically exported from code.google.com/p/re2
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Uninitialized memory in sparse_set.h #23

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I'm writing a Lua module for RE2. Matches weren't working and sometimes I'd get 
a crash. I fire up valgrind and I get a gazillion warnings about uninitialized 
reads in sparse_set.h. The contains() method was accessing uninitialized memory.

The constructor comments, "Don't need to zero the memory." Why exactly needn't 
dense_ and sparse_to_dense_ be initialized? It seems to me they do, but perhaps 
I'm missing something. FWIW, initializing those arrays makes valgrind happy and 
my code work.

Original issue reported on code.google.com by william%...@gtempaccount.com on 24 Jun 2010 at 11:12

GoogleCodeExporter commented 9 years ago
http://research.swtch.com/2008/03/using-uninitialized-memory-for-fun-and.html

It's actually fine, but Valgrind doesn't know.  
I may end up adding a memset in the allocation anyway
(it's already there if you compile in debug mode)
just to quiet this sort of complaint, but it's definitely
not necessary for correctness.

Original comment by rsc@swtch.com on 25 Jun 2010 at 2:43

GoogleCodeExporter commented 9 years ago
Perhaps you could add the attached Valgrind suppressions to the tree in lieu of 
changing the code.

Original comment by william%...@gtempaccount.com on 25 Jun 2010 at 9:09

Attachments: