Closed Bug 481939 Opened 17 years ago Closed 16 years ago

_PR_ImplicitInitialization sends uninitialized bytes to getsockopt

Categories

(NSPR :: NSPR, defect)

x86
macOS
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED INVALID

People

(Reporter: jruderman, Assigned: wtc)

Details

(Keywords: valgrind)

Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2a1pre) Gecko/20090304 Minefield/3.2a1pre Starting Firefox (Mac, mozilla-central, opt) under Valgrind gives me: ==4831== Syscall param socketcall.getsockopt(optlen) points to uninitialised byte(s) ==4831== at 0x7C7302: getsockopt (in /usr/lib/libSystem.B.dylib) ==4831== by 0x57BFD: _PR_ImplicitInitialization (in /Users/jruderman/central/opt-obj/nsprpub/pr/src/libnspr4.dylib) ==4831== by 0x4D721: PR_NewLogModule (in /Users/jruderman/central/opt-obj/nsprpub/pr/src/libnspr4.dylib) ==4831== by 0x20080CB: __static_initialization_and_destruction_0(int, int) (in /Users/jruderman/central/opt-obj/toolkit/library/XUL) ==4831== by 0x8FE12F35: ImageLoaderMachO::doModInitFunctions(ImageLoader::LinkContext const&) (in /usr/lib/dyld) ==4831== by 0x8FE0E7E2: ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int) (in /usr/lib/dyld) ==4831== by 0x8FE0E774: ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&, unsigned int) (in /usr/lib/dyld) ==4831== by 0x8FE0E8C8: ImageLoader::runInitializers(ImageLoader::LinkContext const&) (in /usr/lib/dyld) ==4831== by 0x8FE04101: dyld::initializeMainExecutable() (in /usr/lib/dyld) ==4831== by 0x8FE07BCE: dyld::_main(mach_header const*, unsigned long, int, char const**, char const**, char const**) (in /usr/lib/dyld) ==4831== by 0x8FE01871: dyldbootstrap::start(mach_header const*, int, char const**, long) (in /usr/lib/dyld) ==4831== by 0x8FE01036: _dyld_start (in /usr/lib/dyld) ==4831== Address 0xbfffe25c is on thread 1's stack ==4831== Uninitialised value was created by a stack allocation ==4831== at 0x62A00: _PR_InitIO (in /Users/jruderman/central/opt-obj/nsprpub/pr/src/libnspr4.dylib)
Here is the code in question: 1161 #ifdef _PR_IPV6_V6ONLY_PROBE 1162 /* In Mac OS X v10.3 Panther Beta the IPV6_V6ONLY socket option 1163 * is turned on by default, contrary to what RFC 3493, Section 1164 * 5.3 says. So we have to turn it off. Find out whether we 1165 * are running on such a system. 1166 */ 1167 { 1168 int osfd; 1169 osfd = socket(AF_INET6, SOCK_STREAM, 0); 1170 if (osfd != -1) { 1171 int on; <=== UNINITIALIZED 1172 int optlen = sizeof(on); 1173 if (getsockopt(osfd, IPPROTO_IPV6, IPV6_V6ONLY, 1174 &on, &optlen) == 0) { 1175 _pr_ipv6_v6only_on_by_default = on; 1176 } 1177 close(osfd); 1178 } 1179 } 1180 #endif The variable 'on' is uninitialized because it will receive output from getsockopt. Does Valgrind blindly require all output arguments to be initialized?
Sorry, I didn't read the Valgrind message carefully. Valgrind says: Syscall param socketcall.getsockopt(optlen) points to uninitialised byte(s) But optlen is initialized!
Nicholas, can you help wtc figure this out?
It might be a bug in Valgrind. I'll take a closer look on Tuesday (Monday's a public holiday in Australia...)
Sorry for the delay. It was a bug in Valgrind's getsockopt() wrapper for Darwin. If you update your version of Valgrind from the DARWIN branch it should be fixed.
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.