delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/09/12/16:38:58

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=0.4 required=5.0 tests=AWL,BAYES_50,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,T_TO_NO_BRKTS_FREEMAIL
X-Spam-Check-By: sourceware.org
Message-ID: <722657.29232.qm@web25502.mail.ukl.yahoo.com>
Date: Sun, 12 Sep 2010 20:38:45 +0000 (GMT)
From: Marco Atzeri <marco_atzeri AT yahoo DOT it>
Subject: malloc-bzero and /proc/pid/statm reading bug
To: cygwin AT cygwin DOT com
MIME-Version: 1.0
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

--0-2111852949-1284323925=:29232
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

on the ngspice development list one of the developer
find a likely cygwin bug, see description an test case

--- Dom 12/9/10, Robert Larice  ha scritto:

> Hello All,
>=20
> =A0 I need some help with a cygwin Problem.
> =A0 Trying to find a bug reported for ngspice,
> =A0 =A0 I finally could boil the problem down
> =A0 =A0 to what seems to be a plain cygwin bug.
>=20
> =A0 The attached very small C file, fails
> =A0 =A0 after some iterations to open a
> =A0 =A0 certain /proc/.. entry
>=20
[cut]
>=20
> =A0 Here I get:
> =A0 =A0=A0=A0malloc -> 0x7fd30008
> =A0 =A0=A0=A0malloc -> 0x7fab0008
> =A0 =A0=A0=A0malloc -> 0x7f830008
> =A0 =A0=A0=A0malloc -> 0x7f470008
> =A0 =A0=A0=A0malloc -> 0x7f1f0008
> =A0 =A0=A0=A0malloc -> 0x7ef70008
> =A0 =A0=A0=A0/proc/3044/statm: No error
> =A0 =A0=A0=A0malloc -> 0x7ecf0008
> =A0 =A0=A0=A0/proc/3044/statm: No error
> =A0 =A0=A0=A0...
>=20
> =A0 { No error, nevertheless means,
> =A0 =A0=A0=A0the thing can't be read ... }
>=20
> Thanks,
> =A0 Robert Larice

I checked and both 1.7.7 and the latest 20100912
show the issue.
Are we assuming something wrong and missing something else=20
or is it a bzero bug ?

Marco



=20=20=20=20=20=20
--0-2111852949-1284323925=:29232
Content-Type: text/x-csrc; charset=us-ascii
Content-Disposition: inline; filename="t3.c"

// (compile "make CFLAGS='-Wall -O2' t3 && ./t3.exe")
// (man "proc(5)")

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>

static void
foo(const char *path)
{
  int length = 320000*8;
  void *blob = malloc(length);

  fprintf(stderr,"malloc -> %p\n", blob);

  /* writing to the alloced space causes failure to open /proc/$pid/statm */
  if(1)
    bzero(blob, length);

  {
    int hndl = open(path, O_RDONLY);
    if(hndl < 0)
      perror(path);
    else
      close(hndl);
  }
}


int
main(int argc, char **argv)
{
  char proc_statm[100];
  int i;

#if 0
  // just some info, for debugging purpose
  sprintf(proc_statm, "cat /proc/%d/maps | sort", getpid());
  system(proc_statm);

  // stat doesn't fail
  sprintf(proc_statm, "/proc/%d/stat", getpid());
#endif

  // statm will fail
  sprintf(proc_statm, "/proc/%d/statm", getpid());

  for(i=0; i<60; i++)
    foo(proc_statm);

  exit(0);
}


--0-2111852949-1284323925=:29232
Content-Type: text/plain; charset=us-ascii

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
--0-2111852949-1284323925=:29232--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019