Bug#599172: dma-migrate eats all the CPU

2010-10-06 Thread Peter Pentchev
On Tue, Oct 05, 2010 at 02:58:04PM +0200, Matteo Cypriani wrote:
 On Tue, 5 Oct 2010 15:33:00 +0300, Peter Pentchev wrote:
  Can you run dma-migrate -v by hand and show
  me its output?
 
 There is no output at all…
[snip]
 time(NULL)  = 1286282846
 getpid()= 1143
 
 Hope it helps…

Even weirder.  Interesting.  Can you build a test program on that host?
If yes, could you try to build the attached program, first with

  env DEB_BUILD_HARDENING=0 cc -O2 -g -o dma-migrate dma-migrate.c

...and, if that suddenly happens to work (it shouldn't, but still), with:

  env DEB_BUILD_HARDENING=1 cc -O2 -g -o dma-migrate dma-migrate.c
(with the hardening-wrapper package installed)

...and show me the output (to stderr, mostly) and the strace output for
both cases?

If you can't build a program on this host, I'll try to hunt down
a PowerPC qemu image to experiment with.

Thanks for taking an interest in dma, and for your help with trying
to track this down!

G'luck,
Peter

-- 
Peter Pentchev  r...@space.bgr...@ringlet.netr...@freebsd.org
PGP key:http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
.siht ekil ti gnidaer eb d'uoy ,werbeH ni erew ecnetnes siht fI


signature.asc
Description: Digital signature


Bug#599172: dma-migrate eats all the CPU

2010-10-06 Thread Peter Pentchev
On Wed, Oct 06, 2010 at 09:12:34AM +0300, Peter Pentchev wrote:
 On Tue, Oct 05, 2010 at 02:58:04PM +0200, Matteo Cypriani wrote:
  On Tue, 5 Oct 2010 15:33:00 +0300, Peter Pentchev wrote:
   Can you run dma-migrate -v by hand and show
   me its output?
  
  There is no output at all…
 [snip]
  time(NULL)  = 1286282846
  getpid()= 1143
  
  Hope it helps…
 
 Even weirder.  Interesting.  Can you build a test program on that host?
 If yes, could you try to build the attached program, first with
 
   env DEB_BUILD_HARDENING=0 cc -O2 -g -o dma-migrate dma-migrate.c
 
 ...and, if that suddenly happens to work (it shouldn't, but still), with:
 
   env DEB_BUILD_HARDENING=1 cc -O2 -g -o dma-migrate dma-migrate.c
 (with the hardening-wrapper package installed)
 
 ...and show me the output (to stderr, mostly) and the strace output for
 both cases?
 
 If you can't build a program on this host, I'll try to hunt down
 a PowerPC qemu image to experiment with.
 
 Thanks for taking an interest in dma, and for your help with trying
 to track this down!

Of course, it would've helped if I'd actually attached the program...

G'luck,
Peter

-- 
Peter Pentchev  r...@space.bgr...@ringlet.netr...@freebsd.org
PGP key:http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
I am the meaning of this sentence.
/*-
 * Copyright (c) 2010  Peter Pentchev
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *notice, this list of conditions and the following disclaimer in the
 *documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

#define _GNU_SOURCE

#include sys/types.h
#include sys/file.h
#include sys/stat.h

#include dirent.h
#include err.h
#include errno.h
#include fcntl.h
#include inttypes.h
#include regex.h
#include stdarg.h
#include stdio.h
#include stdlib.h
#include string.h
#include time.h
#include unistd.h

#ifndef __printflike
#ifdef __GNUC__
#define __printflike(fmtarg, firstvararg)	\
	__attribute__((__format__ (__printf__, fmtarg, firstvararg)))
#else
#define __printflike(fmtarg, firstvararg)
#endif
#endif

#define DEFAULT_SPOOLDIR	/var/spool/dma

static int	 verbose = 0;
static char	 copybuf[BUFSIZ];

static int	 dma_migrate(int, const char *);

static int	 open_locked(const char *, int, ...);
static void	 cleanup_file(int, char *);

static void	 usage(int);
static void	 version(void);
static void	 debug(const char *, ...) __printflike(1, 2);

int
main(int argc, char **argv)
{
	const char *spooldir;
	int hflag, Vflag, errs, fd, res;
	char ch;
	DIR *d;
	struct dirent *e;
	struct stat sb;

	fprintf(stderr, RDBG 001 before srandom()\n);
srandom((unsigned long)((time(NULL) ^ getpid()) + ((uintptr_t)argv)));

	hflag = Vflag = 0;
	spooldir = DEFAULT_SPOOLDIR;
	fprintf(stderr, RDBG 002 before getopt()\n);
	while (ch = getopt(argc, argv, d:hVv), ch != -1)
		switch (ch) {
			case 'd':
spooldir = optarg;
break;

			case 'h':
hflag = 1;
break;

			case 'V':
Vflag = 1;
break;

			case 'v':
verbose = 1;
break;

			case '?':
usage(1);
		}
	if (Vflag)
		version();
	if (hflag)
		usage(0);
	if (hflag || Vflag)
		exit(0);

	fprintf(stderr, RDBG 003 after getopt()\n);
	argc -= optind;
	argv += optind;
	fprintf(stderr, RDBG 004 argc = %d argv = %p\n, argc, argv);

	/* Let's roll! */
	if (chdir(spooldir) == -1)
		err(1, Could not change into spool directory %s, spooldir);
	fprintf(stderr, RDBG 005 after chdir()\n);
	if (d = opendir(.), d == NULL)
		err(1, Could not read spool directory %s, spooldir);
	fprintf(stderr, RDBG 005 after opendir()\n);
	errs = 0;
	while (e = readdir(d), e != NULL) {
		/* Do we care about this entry? */
		fprintf(stderr, RDBG 006 read a dir entry %s\n, e-d_name);
		debug(Read a directory entry: %s\n, e-d_name);
		if 

Bug#599172: dma-migrate eats all the CPU

2010-10-06 Thread Matteo Cypriani
On Wed, 6 Oct 2010 09:12:34 +0300, Peter Pentchev wrote:
   env DEB_BUILD_HARDENING=0 cc -O2 -g -o dma-migrate dma-migrate.c
 
 ...and, if that suddenly happens to work (it shouldn't, but still),
with:
 
   env DEB_BUILD_HARDENING=1 cc -O2 -g -o dma-migrate dma-migrate.c
 (with the hardening-wrapper package installed)
 
 ...and show me the output (to stderr, mostly) and the strace output for
 both cases?

OK so here are the result without hardening (it still does not work, so I
did not try with hardening).

# ./dma-migrate -v
RDBG 001 before srandom()
RDBG 002 before getopt()

# strace ./dma-migrate -v
execve(./dma-migrate, [./dma-migrate, -v], [/* 21 vars */]) = 0
brk(0)  = 0x1014b000
access(/etc/ld.so.nohwcap, F_OK)  = -1 ENOENT (No such file or
directory)
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x4802
access(/etc/ld.so.preload, R_OK)  = -1 ENOENT (No such file or
directory)
open(/etc/ld.so.cache, O_RDONLY)  = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=22107, ...}) = 0
mmap(NULL, 22107, PROT_READ, MAP_PRIVATE, 3, 0) = 0x48023000
close(3)= 0
access(/etc/ld.so.nohwcap, F_OK)  = -1 ENOENT (No such file or
directory)
open(/lib/libc.so.6, O_RDONLY)= 3
read(3,
\177ELF\1\2\1\0\0\0\0\0\0\0\0\0\0\3\0\24\0\0\0\1\0\1\370\340\0\0\0004...,
512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1503336, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x48029000
mmap(0xfe6f000, 1574172, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE,
3, 0) = 0xfe6f000
mprotect(0xffd8000, 65536, PROT_NONE)   = 0
mmap(0xffe8000, 20480, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x169000) = 0xffe8000
mmap(0xffed000, 9500, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xffed000
close(3)= 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x4802a000
mprotect(0xffe8000, 16384, PROT_READ)   = 0
mprotect(0x48021000, 4096, PROT_READ)   = 0
munmap(0x48023000, 22107)   = 0
write(2, RDBG 001 before srandom()\n, 26RDBG 001 before srandom()
) = 26
time(NULL)  = 1286364471
getpid()= 1202
write(2, RDBG 002 before getopt()\n, 25RDBG 002 before getopt()
) = 25

  Matteo



--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#599172: dma-migrate eats all the CPU

2010-10-06 Thread Peter Pentchev
On Wed, Oct 06, 2010 at 01:34:32PM +0200, Matteo Cypriani wrote:
 On Wed, 6 Oct 2010 09:12:34 +0300, Peter Pentchev wrote:
env DEB_BUILD_HARDENING=0 cc -O2 -g -o dma-migrate dma-migrate.c
  
  ...and, if that suddenly happens to work (it shouldn't, but still),
 with:
  
env DEB_BUILD_HARDENING=1 cc -O2 -g -o dma-migrate dma-migrate.c
  (with the hardening-wrapper package installed)
  
  ...and show me the output (to stderr, mostly) and the strace output for
  both cases?
 
 OK so here are the result without hardening (it still does not work, so I
 did not try with hardening).

Ah.  Now I have a suspicion... low-probability, but who knows.
Once more, please? :)  Sorry if I'm bothering you too much - and *of course*
it's no problem that you build these programs only when you actually can
make the time to do so :)

So... can you build this one - without hardening would be enough?

Thanks for your patience and help!

G'luck,
Peter

-- 
Peter Pentchev  r...@space.bgr...@ringlet.netr...@freebsd.org
PGP key:http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
Thit sentence is not self-referential because thit is not a word.
/*-
 * Copyright (c) 2010  Peter Pentchev
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *notice, this list of conditions and the following disclaimer in the
 *documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

#define _GNU_SOURCE

#include sys/types.h
#include sys/file.h
#include sys/stat.h

#include dirent.h
#include err.h
#include errno.h
#include fcntl.h
#include inttypes.h
#include regex.h
#include stdarg.h
#include stdio.h
#include stdlib.h
#include string.h
#include time.h
#include unistd.h

#ifndef __printflike
#ifdef __GNUC__
#define __printflike(fmtarg, firstvararg)	\
	__attribute__((__format__ (__printf__, fmtarg, firstvararg)))
#else
#define __printflike(fmtarg, firstvararg)
#endif
#endif

#define DEFAULT_SPOOLDIR	/var/spool/dma

static int	 verbose = 0;
static char	 copybuf[BUFSIZ];

static int	 dma_migrate(int, const char *);

static int	 open_locked(const char *, int, ...);
static void	 cleanup_file(int, char *);

static void	 usage(int);
static void	 version(void);
static void	 debug(const char *, ...) __printflike(1, 2);

int
main(int argc, char **argv)
{
	const char *spooldir;
	int hflag, Vflag, errs, fd, res;
	char ch;
	DIR *d;
	struct dirent *e;
	struct stat sb;

	fprintf(stderr, RDBG 001 before srandom()\n);
srandom((unsigned long)((time(NULL) ^ getpid()) + ((uintptr_t)argv)));

	hflag = Vflag = 0;
	spooldir = DEFAULT_SPOOLDIR;
	fprintf(stderr, RDBG 002 before getopt()\n);
	while (ch = getopt(argc, argv, d:hVv), ch != -1)
		switch (ch) {
			case 'd':
fprintf(stderr, RDBG 002d '%s'\n, optarg);
spooldir = optarg;
break;

			case 'h':
fprintf(stderr, RDBG 002h\n);
hflag = 1;
break;

			case 'V':
fprintf(stderr, RDBG 002V\n);
Vflag = 1;
break;

			case 'v':
fprintf(stderr, RDBG 002v\n);
verbose = 1;
break;

			case '?':
fprintf(stderr, RDBG 002?\n);
usage(1);
/* NOTREACHED */

			default:
fprintf(stderr, Internal problem: unexpected getopt() return value: %d\n, ch);
return (1);
		}
	fprintf(stderr, RDBG 002.1 after the getopt loop\n);
	if (Vflag)
		version();
	if (hflag)
		usage(0);
	if (hflag || Vflag)
		exit(0);

	fprintf(stderr, RDBG 003 after getopt()\n);
	argc -= optind;
	argv += optind;
	fprintf(stderr, RDBG 004 argc = %d argv = %p\n, argc, argv);

	/* Let's roll! */
	if (chdir(spooldir) == -1)
		err(1, Could not change into spool directory %s, spooldir);
	fprintf(stderr, RDBG 005 after chdir()\n);
	if (d = opendir(.), d == NULL)
		err(1, Could not read spool directory %s, spooldir);
	fprintf(stderr, RDBG 005 after opendir()\n);
	errs = 0;
	while (e = readdir(d), e != NULL) {
		/* Do we 

Bug#599172: dma-migrate eats all the CPU

2010-10-06 Thread Matteo Cypriani
On Wed, 6 Oct 2010 14:52:35 +0300, Peter Pentchev r...@ringlet.net
wrote:
 Ah.  Now I have a suspicion... low-probability, but who knows.
 Once more, please? :)  Sorry if I'm bothering you too much

Don't worry, I'm pleased to help solve bugs! Thank you for *your* work, by
the way ;-)


 So... can you build this one - without hardening would be enough?

# ./dma-migrate -v
RDBG 001 before srandom()
RDBG 002 before getopt()
RDBG 002v
Internal problem: unexpected getopt() return value: 255

# strace ./dma-migrate -v
execve(./dma-migrate, [./dma-migrate, -v], [/* 26 vars */]) = 0
brk(0)  = 0x100ce000
access(/etc/ld.so.nohwcap, F_OK)  = -1 ENOENT (No such file or
directory)
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x4802
access(/etc/ld.so.preload, R_OK)  = -1 ENOENT (No such file or
directory)
open(/etc/ld.so.cache, O_RDONLY)  = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=22107, ...}) = 0
mmap(NULL, 22107, PROT_READ, MAP_PRIVATE, 3, 0) = 0x48023000
close(3)= 0
access(/etc/ld.so.nohwcap, F_OK)  = -1 ENOENT (No such file or
directory)
open(/lib/libc.so.6, O_RDONLY)= 3
read(3,
\177ELF\1\2\1\0\0\0\0\0\0\0\0\0\0\3\0\24\0\0\0\1\0\1\370\340\0\0\0004...,
512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1503336, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x48029000
mmap(0xfe6f000, 1574172, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE,
3, 0) = 0xfe6f000
mprotect(0xffd8000, 65536, PROT_NONE)   = 0
mmap(0xffe8000, 20480, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x169000) = 0xffe8000
mmap(0xffed000, 9500, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xffed000
close(3)= 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x4802a000
mprotect(0xffe8000, 16384, PROT_READ)   = 0
mprotect(0x48021000, 4096, PROT_READ)   = 0
munmap(0x48023000, 22107)   = 0
write(2, RDBG 001 before srandom()\n, 26RDBG 001 before srandom()
) = 26
time(NULL)  = 1286368149
getpid()= 1359
write(2, RDBG 002 before getopt()\n, 25RDBG 002 before getopt()
) = 25
write(2, RDBG 002v\n, 10RDBG 002v
) = 10
write(2, Internal problem: unexpected get..., 56Internal problem:
unexpected getopt() return value: 255
) = 56
exit_group(1)   = ?

Sounds like a progress…

  Matteo



--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#599172: dma-migrate eats all the CPU

2010-10-06 Thread Peter Pentchev
On Wed, Oct 06, 2010 at 02:31:45PM +0200, Matteo Cypriani wrote:
  So... can you build this one - without hardening would be enough?
 
 # ./dma-migrate -v
 RDBG 001 before srandom()
 RDBG 002 before getopt()
 RDBG 002v
 Internal problem: unexpected getopt() return value: 255
[snip]
 
 Sounds like a progress…

Argh!

Okay, I see the problem now.  It's mostly a case of me being a bit
stupid at times, though this particular mistake is one I hadn't made
in almost ten years - and as luck would have it, GCC does indeed treat
char as unsigned on PowerPC, so the getopt() loop never finishes and
dma-migrate never reaches the point where it will actually migrate stuff.

Mmmmkay, here's another version of the tool for you to test, although
I'm pretty sure it will just work now.  If it works, I'll upload
a fixed package tonight or tomorrow, and I'll see if the release team
will approve a freeze exception.

So... try this? (basically a char ch to int ch fix)  I'm 99.5% sure
that this *is* the problem, so I'll prepare a package for upload.

G'luck,
Peter

-- 
Peter Pentchev  r...@space.bgr...@ringlet.netr...@freebsd.org
PGP key:http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
If I had finished this sentence,
/*-
 * Copyright (c) 2010  Peter Pentchev
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *notice, this list of conditions and the following disclaimer in the
 *documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

#define _GNU_SOURCE

#include sys/types.h
#include sys/file.h
#include sys/stat.h

#include dirent.h
#include err.h
#include errno.h
#include fcntl.h
#include inttypes.h
#include regex.h
#include stdarg.h
#include stdio.h
#include stdlib.h
#include string.h
#include time.h
#include unistd.h

#ifndef __printflike
#ifdef __GNUC__
#define __printflike(fmtarg, firstvararg)	\
	__attribute__((__format__ (__printf__, fmtarg, firstvararg)))
#else
#define __printflike(fmtarg, firstvararg)
#endif
#endif

#define DEFAULT_SPOOLDIR	/var/spool/dma

static int	 verbose = 0;
static char	 copybuf[BUFSIZ];

static int	 dma_migrate(int, const char *);

static int	 open_locked(const char *, int, ...);
static void	 cleanup_file(int, char *);

static void	 usage(int);
static void	 version(void);
static void	 debug(const char *, ...) __printflike(1, 2);

int
main(int argc, char **argv)
{
	const char *spooldir;
	int hflag, Vflag, errs, fd, res;
	int ch;
	DIR *d;
	struct dirent *e;
	struct stat sb;

	fprintf(stderr, RDBG 001 before srandom()\n);
srandom((unsigned long)((time(NULL) ^ getpid()) + ((uintptr_t)argv)));

	hflag = Vflag = 0;
	spooldir = DEFAULT_SPOOLDIR;
	fprintf(stderr, RDBG 002 before getopt()\n);
	while (ch = getopt(argc, argv, d:hVv), ch != -1)
		switch (ch) {
			case 'd':
fprintf(stderr, RDBG 002d '%s'\n, optarg);
spooldir = optarg;
break;

			case 'h':
fprintf(stderr, RDBG 002h\n);
hflag = 1;
break;

			case 'V':
fprintf(stderr, RDBG 002V\n);
Vflag = 1;
break;

			case 'v':
fprintf(stderr, RDBG 002v\n);
verbose = 1;
break;

			case '?':
fprintf(stderr, RDBG 002?\n);
usage(1);
/* NOTREACHED */

			default:
fprintf(stderr, Internal problem: unexpected getopt() return value: %d\n, ch);
return (1);
		}
	fprintf(stderr, RDBG 002.1 after the getopt loop\n);
	if (Vflag)
		version();
	if (hflag)
		usage(0);
	if (hflag || Vflag)
		exit(0);

	fprintf(stderr, RDBG 003 after getopt()\n);
	argc -= optind;
	argv += optind;
	fprintf(stderr, RDBG 004 argc = %d argv = %p\n, argc, argv);

	/* Let's roll! */
	if (chdir(spooldir) == -1)
		err(1, Could not change into spool directory %s, spooldir);
	fprintf(stderr, RDBG 005 after chdir()\n);
	if (d = opendir(.), d == NULL)
		err(1, Could not read spool directory %s, spooldir);
	fprintf(stderr, RDBG 005 after 

Bug#599172: dma-migrate eats all the CPU

2010-10-06 Thread Matteo Cypriani
On Wed, 6 Oct 2010 16:16:08 +0300, Peter Pentchev wrote:
 So... try this? (basically a char ch to int ch fix)  I'm 99.5% sure
 that this *is* the problem, so I'll prepare a package for upload.

# ./dma-migrate -v
RDBG 001 before srandom()
RDBG 002 before getopt()
RDBG 002v
RDBG 002.1 after the getopt loop
RDBG 003 after getopt()
RDBG 004 argc = 0 argv = 0xbfd5fedc
RDBG 005 after chdir()
RDBG 005 after opendir()
RDBG 006 read a dir entry ..
Read a directory entry: ..
RDBG 007 skipping it
RDBG 006 read a dir entry .
Read a directory entry: .
RDBG 007 skipping it
RDBG 016 finished, errs = 0
Everything seems to be all right
RDBG 017 returning 0

\o/
Now I just hope that you'll obtain a freeze exception…
Thanks for your reactivity!

  Matteo



--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#599172: dma-migrate eats all the CPU

2010-10-05 Thread Matteo Cypriani
Package: dma-migrate
Version: 0.0.2010.06.17-3
Severity: important


dma-migrate never ends and eats all the CPU. Cron pops a new instance of
dma-migrate every 5 minutes, so after some time I have a lot of
dma-migrate processes and load average becomes really bad.

If I killall dma-migrate, mails are delivered normally (but cron
will launch a new dma-migrate process 5 minutes later).

dma has just been installed on this machine with the default config.

Please let me know if I can do anything to help you to locate the
problem.

  Matteo

-- System Information:
Debian Release: squeeze/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: powerpc (ppc)

Kernel: Linux 2.6.32-5-powerpc
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages dma-migrate depends on:
ii  libc6 2.11.2-6   Embedded GNU C Library: Shared lib

dma-migrate recommends no packages.

dma-migrate suggests no packages.

-- no debconf information



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#599172: dma-migrate eats all the CPU

2010-10-05 Thread Peter Pentchev
On Tue, Oct 05, 2010 at 11:37:26AM +0200, Matteo Cypriani wrote:
 Package: dma-migrate
 Version: 0.0.2010.06.17-3
 Severity: important
 
 
 dma-migrate never ends and eats all the CPU. Cron pops a new instance of
 dma-migrate every 5 minutes, so after some time I have a lot of
 dma-migrate processes and load average becomes really bad.
 
 If I killall dma-migrate, mails are delivered normally (but cron
 will launch a new dma-migrate process 5 minutes later).
 
 dma has just been installed on this machine with the default config.
 
 Please let me know if I can do anything to help you to locate the
 problem.

If this is a new installation, then you do not really need dma-migrate;
you may safely remove it from the cron job.  However, it would really
be good to find out what causes this hang.

Can you do the following for me (as root), preferably while there is
a single dma-migrate process running?

1. Show me the output of mount

2. Show me the output of lsof -n -p `pgrep dma_migrate` if there is
   only one dma-migrate process running, and of:
 lsof -n -p `pgrep dma-migrate | xargs | sed -e 's/ / -p /g'`
   if there is more than one

3. Run strace -p `pgrep dma-migrate` and see if it continuously
   outputs lines; if not, tell me what syscall it is blocking on.

4. If strace is continuously outputting lines, show me the output of
   strace -p `pgrep dma-migrate` | head -500

5. ls -l /var/spool/dma

6. dma -bp

Thanks in advance for your assistance, and apologies for bringing
your system to a crawl!

G'luck,
Peter

-- 
Peter Pentchev  r...@space.bgr...@ringlet.netr...@freebsd.org
PGP key:http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
I had to translate this sentence into English because I could not read the 
original Sanskrit.


signature.asc
Description: Digital signature


Bug#599172: dma-migrate eats all the CPU

2010-10-05 Thread Matteo Cypriani
On Tue, 5 Oct 2010 14:17:21 +0300, Peter Pentchev wrote:
 1. Show me the output of mount

/dev/hda3 on / type ext3 (rw,errors=remount-ro)
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
udev on /dev type tmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
/dev/hda5 on /home type ext3 (rw)


 2. Show me the output of lsof -n -p `pgrep dma_migrate` if there is
only one dma-migrate process running

COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF   NODE NAME
dma-migra 966 root  cwdDIR3,3 4096  24193 /root
dma-migra 966 root  rtdDIR3,3 4096  2 /
dma-migra 966 root  txtREG3,3 4180 267453
/usr/sbin/dma-migrate
dma-migra 966 root  memREG3,3  1503336 242162 /lib/libc-2.11.2.so
dma-migra 966 root  memREG3,3   142696 242158 /lib/ld-2.11.2.so
dma-migra 966 root0r  FIFO0,8  0t0   4050 pipe
dma-migra 966 root1u   REG3,30  40392 /tmp/tmpfSzT7Oo
(deleted)
dma-migra 966 root2u   REG3,30  40392 /tmp/tmpfSzT7Oo
(deleted)
dma-migra 966 root5u   REG3,30  40392 /tmp/tmpfSzT7Oo
(deleted)

 
 3. Run strace -p `pgrep dma-migrate` and see if it continuously
outputs lines; if not, tell me what syscall it is blocking on.

Nothing is displayed but the welcome line:
Process 966 attached - interrupt to quit


 5. ls -l /var/spool/dma

total 0
:-)


 6. dma -bp

Mail queue is empty


 Thanks in advance for your assistance, and apologies for bringing
 your system to a crawl!

You're welcome! Do you find anything helpful here?

  Matteo




--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#599172: dma-migrate eats all the CPU

2010-10-05 Thread Peter Pentchev
On Tue, Oct 05, 2010 at 02:10:35PM +0200, Matteo Cypriani wrote:
 On Tue, 5 Oct 2010 14:17:21 +0300, Peter Pentchev wrote:
[snip]
  5. ls -l /var/spool/dma
 
 total 0
 :-)
 
 
  6. dma -bp
 
 Mail queue is empty

Hm, that's... interesting.  Can you run dma-migrate -v by hand and show
me its output?

G'luck,
Peter

-- 
Peter Pentchev  r...@space.bgr...@ringlet.netr...@freebsd.org
PGP key:http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
I had to translate this sentence into English because I could not read the 
original Sanskrit.


signature.asc
Description: Digital signature


Bug#599172: dma-migrate eats all the CPU

2010-10-05 Thread Matteo Cypriani
On Tue, 5 Oct 2010 15:33:00 +0300, Peter Pentchev wrote:
 Can you run dma-migrate -v by hand and show
 me its output?

There is no output at all…

The output of lsof while dma-migrate -v is running is slightly different
than previously (due to output to the terminal instead of in files, I
guess):
COMMANDPID USER   FD   TYPE DEVICE SIZE/OFF   NODE NAME
dma-migra 1116 root  cwdDIR3,3 4096  24193 /root
dma-migra 1116 root  rtdDIR3,3 4096  2 /
dma-migra 1116 root  txtREG3,3 4180 267453
/usr/sbin/dma-migrate
dma-migra 1116 root  memREG3,3  1503336 242162 /lib/libc-2.11.2.so
dma-migra 1116 root  memREG3,3   142696 242158 /lib/ld-2.11.2.so
dma-migra 1116 root0u   CHR  136,2  0t0  5 /dev/pts/2
dma-migra 1116 root1u   CHR  136,2  0t0  5 /dev/pts/2
dma-migra 1116 root2u   CHR  136,2  0t0  5 /dev/pts/2

Here is the result of strace dma-migrate -v:
execve(/usr/sbin/dma-migrate, [dma-migrate, -v], [/* 24 vars */]) =
0
brk(0)  = 0x10136000
access(/etc/ld.so.nohwcap, F_OK)  = -1 ENOENT (No such file or
directory)
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x4802
access(/etc/ld.so.preload, R_OK)  = -1 ENOENT (No such file or
directory)
open(/etc/ld.so.cache, O_RDONLY)  = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=22107, ...}) = 0
mmap(NULL, 22107, PROT_READ, MAP_PRIVATE, 3, 0) = 0x48023000
close(3)= 0
access(/etc/ld.so.nohwcap, F_OK)  = -1 ENOENT (No such file or
directory)
open(/lib/libc.so.6, O_RDONLY)= 3
read(3,
\177ELF\1\2\1\0\0\0\0\0\0\0\0\0\0\3\0\24\0\0\0\1\0\1\370\340\0\0\0004...,
512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1503336, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x48029000
mmap(0xfe6f000, 1574172, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE,
3, 0) = 0xfe6f000
mprotect(0xffd8000, 65536, PROT_NONE)   = 0
mmap(0xffe8000, 20480, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x169000) = 0xffe8000
mmap(0xffed000, 9500, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xffed000
close(3)= 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) =
0x4802a000
mprotect(0xffe8000, 16384, PROT_READ)   = 0
mprotect(0x48021000, 4096, PROT_READ)   = 0
munmap(0x48023000, 22107)   = 0
time(NULL)  = 1286282846
getpid()= 1143

Hope it helps…

  Matteo



--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org