> The source of the error seems to be padding and data variables not used in my > particular scenario. While it's true they are passed, uninitialized, to > "sendto", the other end will parse them according to the same criteria, and > will also ignore them. > > Since the other end of this socket is a process also managed by the same > valgrind instance, it is theoretically possible for valgrind to postpone the > error report until actual use after the read. I'm not sure that is a useful > application of the developer's time, however.
According to the manual page (man 2 send), "The only difference between send() and write(2) is the presence of flags." Therefore memcheck correctly complains about uninitialized bytes among the data that is written into the socket. Once the bytes have been written there is no way to know how the values will be used or ignored by any receiver at the other end. Memcheck must assume that every byte is used. Socketcall() is particularly nasty. It multiplexes sa everal functions into one system call by passing a structure that contains a "control packet" with flags and variable bytes. Correctly interpreting the control packet requires pages of code which duplicate the kernel's logic for implementing socketcall. It is particularly difficult to discover the dataflow for error conditions. The easy way to avoid hassle is to clear any union (or struct which suffers alignment or padding) immediately after declaration: memset(&u, 0, sizeof(u)); In addition to keeping memcheck quiet, this tends to increase the reproducibility of any bugs, and to insulate the application from unpleasant interactions when the protocol gets enhanced or extended. Of course, the memset also tends to mask any actual uninit errors. But these tend to be caught by other means because typically they cause incorrect results. ------------------------------------------------------------------------------ "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE Instantly run your Selenium tests across 300+ browser/OS combos. Get unparalleled scalability from the best Selenium testing platform available. Simple to use. Nothing to install. Get started now for free." http://p.sf.net/sfu/SauceLabs _______________________________________________ Valgrind-users mailing list Valgrind-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/valgrind-users