X-Spam-Check-By: sourceware.org Date: Wed, 7 Mar 2007 07:07:37 +0100 (CET) From: "Buzz" Subject: [Testcase] Memory returned by malloc not always zeroed. Reply-To: cygwin mailing-list Organisation: Ehm... MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="eilk-ski-frau-iensts-oomds" X-Lingo-Id: 45ee4b3d Message-ID: User-Agent: slrn/0.9.8.1 (Win32) Hamster/2.1.0.11 KorrNews/4.2.1 To: cygwin AT cygwin DOT com Lines: 71 X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com --eilk-ski-frau-iensts-oomds Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8Bit Hi, On three different cygwin 1.5.24-2 systems, attached testprogram (compile with ``gcc -o mall-test mall-test.c'') returns many lines like: n1 S13 p12 is 0x81, not 0 n1 S14 p0 is 0x8c, not 0 n1 S14 p1 is 0x7f, not 0 n1 S14 p2 is 0x14, not 0 n1 S14 p3 is 0x61, not 0 n1 S14 p4 is 0x8c, not 0 n1 S14 p5 is 0x7f, not 0 n1 S14 p6 is 0x14, not 0 n1 S14 p7 is 0x61, not 0 n1 S14 p12 is 0x81, not 0 This indicates malloc returning non-zeroed memory. Has anybody got a clue as to what's going on? L8r, Buzz. -- ) | | ---/ ---/ Yes, this | This message consists of true | I do not -- | | / / really is | and false bits entirely. | mail for ) | | / / a 72 by 4 +-------------------------------+ any1 but -- \--| /--- /--- .sigfile. | |perl -pe "s.u(z)\1.as." | me. 4^re --eilk-ski-frau-iensts-oomds Content-Type: text/plain; name="mall-test.c" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="mall-test.c" #include #include int main () { int n, s, p, f; char *m; for (f = 0, n = 1; n <= 10000 && f <= 200; n++) { for (s = 1; s < 40; s++) { m = malloc (s); if (m == NULL) { printf ("n%d s%d: Malloc returned NULL.\n", n, s); } else { // m!= NULL for (p = 0; p < s; p++) { if (m[p] != 0) { f++; printf ("n%d S%d p%d is 0x%02x, not 0\n", n, s, p, m[p] & 255 ); } } // for p free (m); } // m == NULL } // for s } // for n return f > 0; } --eilk-ski-frau-iensts-oomds Content-Type: text/plain; charset=us-ascii -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/ --eilk-ski-frau-iensts-oomds--