Re: FreeBSD and Debugging?

2004-04-11 Thread Dan Nelson
In the last episode (Apr 10), Ted Unangst said:
> On Fri, 9 Apr 2004, Brandon Erhart wrote:
> > Are there any debuggers out there for BSD that will detect the
> > heap/stack corruption!?
> 
> valgrind and electric fence are very good suggestions.  my own
> personal pet project was adding guard pages to the system malloc. 
> then linking malloc.conf -> AFGJ or setenv MALLOC_OPTIONS and you can
> find bugs in all the software you run.  it's less complete than a
> dedicated heap checker, but lightweight enough (well, 20% penalty may
> not be light for some) that i run with it full time.  we've had a
> fairly significant amount of success with it finding bugs in software
> that just happened to work.
> 
> http://www.zeitbombe.org/patches/malloc_guard.diff should apply pretty
> cleanly to freebsd's malloc.c

I also have a malloc debugging patch that changes the Junk flag to fill
with a counter value, so you can track down where in your program a
particular block of memory was allocated/freed.

http://dan.allantgroup.com/FreeBSD/malloc.diff , or PR 52907

-- 
Dan Nelson
[EMAIL PROTECTED]
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Library problems

2004-04-11 Thread Cole
Hi

I have recently installed ntop 3.0 on freebsd 4.9 from the ports.
I then copied the binary and all needed libraries to another box also almost a 
duplicate of the box that i installed ntop 3.0 on.

When starting up ntop i get these errors, so i recompiled ntop on the new box from 
ports, and i still get these errors.
I have checked /usr/local/lib/ntop/plugins, and everything is there, and they are also 
the same as the libraries on the original box
that i installed ntop on.  Even copying the files from the plugin directory to the 
second box didnt solve this. I have recompiled,
reinstalled, tried everything, i have no idea why it is now doing this.

Sun Apr 11 16:32:18 2004  **WARNING** Unable to locate plugin 
'/usr/local/lib/ntop/plugins/netflowPlugin.so' entry function [Invalid
shared object handle 0x28070a00]
Sun Apr 11 16:32:18 2004  **WARNING** Unable to locate plugin 
'/usr/local/lib/ntop/plugins/nfsPlugin.so' entry function [Invalid
shared object handle 0x28070d00]
Sun Apr 11 16:32:18 2004  **WARNING** Unable to locate plugin 
'/usr/local/lib/ntop/plugins/pdaPlugin.so' entry function [Invalid
shared object handle 0x29b3d000]
Sun Apr 11 16:32:18 2004  **WARNING** Unable to locate plugin 
'/usr/local/lib/ntop/plugins/rrdPlugin.so' entry function [Invalid
shared object handle 0x29b3d300]
Sun Apr 11 16:32:18 2004  **WARNING** Unable to locate plugin 
'/usr/local/lib/ntop/plugins/sflowPlugin.so' entry function [Invalid
shared object handle 0x29b3d600]
Sun Apr 11 16:32:18 2004  **WARNING** Unable to locate plugin 
'/usr/local/lib/ntop/plugins/xmldumpPlugin.so' entry function [Invalid
shared object handle 0x29b3d900]

If anyone can help it would be greatly appreciated.
Thanks
/Cole

___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: FreeBSD and Debugging?

2004-04-11 Thread Roman Kurakin
Colin Percival wrote:

At 06:11 10/04/2004, Brandon Erhart wrote:
 

Are there any debuggers out there for BSD that will detect the heap/stack corruption!?
   

 Real Men use printf(3). :-)

You are talking as Linus ;-)

rik



___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


ATA/CHS problem (path + new information)

2004-04-11 Thread Roman Kurakin
Hi,

You can find history of my previous postings below.

I didn't moved far since that time, because lack of time. But any way
I have some new information and one patch I want to share. This patch
didn't solve any of my problems.
Soren, please review it. This time it is comlete. I hope this
patch would allow to track down similar problems I have.
I remind you that now I have two problems. First one that FreeBSD uses
wrong assumption about which device should be CHS and which LBA:
if (!ad_version(atadev->param->version_major) ||
!(atadev->param->atavalid & ATA_FLAG_54_58) || !lbasize)
atadev->flags |= ATA_D_USE_CHS;
True ATA device may not have ATA_FLAG_54_58 valid bit, and also due
to last ATA standard this bit is obsoleted.
I also want to know why ata driver doesn't check LBA support from word 49?
May be this one check could solve my problems and didn't breake code for
non-ATA devices.
Second one, that only 20G part of my hard disk works with CHS. This is other
side of the same problem. Device should work in CHS mode. And it works
witch ICH5 controller. But with ICH2 it doesn't with out hack.
I've checked standard again and I sew command 91h (Initialize drive 
parameters).
YES, this command solved my problem witch CHS. But. But the life is no 
so easy :-)
This command fails itself with abort code. But as I said I can access 
sectors that was
previously NOT FOUND after it.
(ata_controlcmd (atadev,0x91, 0, 0xfUL << 24, 63); I've put it just 
after Identify driver
command in ata_getparam function)

Any comments and suggestions very very appreciated. And please do not 
suggest how
to fix this problem only for me. I already know a few variant that can't 
be commited.
I realy want to crush this bug.

rik

Roman Kurakin wrote:

Hi,

(Was "HDD question" on hackers@, posted also here cause this is also 
CURRENT problem)

History:

I have some problems with my HDD (ST380021A). The problem was 

checked on 5.2, 5.2.1, and some

5.Current (cvsuped about week or two).

At first I got this problem while system installation. I get trap 

and message from ata after I start a commit:

FAILURE READ_DMA status=51  error=10 

 LBA=245529601

I started to hack sysinstall and finally came to simple program 

that could lead

to the same message from ata:

fd = open ("/dev/ata0", O_RDWR);
read_block (fd, (daddr_t)41929650, 512); // this one could be changed 

// to pair calls lseek and read,

// so this is not libdisk problem

I checked the same code with /dev/ata1 which is twice as little, but 

I didn't get any messages.
I don't have any ideas where my read call goes, which drivers to look 

to catch this bug.

So I need a help from some gurus in this area.


What I've found since that time:

This is not an LBA request. ATA driver thinks that I have 80G CHS 
device, cause it's ATA_FLAG_54_58
is zero. (This decision is incorrect, we shouldn't relay on this 
flag). I've checked another seagate 80G drive in
CHS mode(by driver hacking), and problematic one with LBA mode. I get 
the same behavior on both with CHS.
And both work fine in LBA mode. It also should be mentioned that I get 
this problem on machine with
ICH2 controller, and it seems that I don't have such problem on other 
machine with ICH5.

PS. If you have any ideas, or if you have any materials (standards for 
example) about ATA/ATAPI and you
can share them with me, please let me know. I am not ata developer, so 
this is a bit difficalt for me to
dig this problem.

rik


diff -ubr ata-orig/ata-disk.c ata/ata-disk.c
--- ata-orig/ata-disk.c Wed Mar 10 20:05:56 2004
+++ ata/ata-disk.c  Sun Apr 11 12:26:02 2004
@@ -388,13 +388,14 @@
(adp->heads * adp->sectors)),
   adp->heads, adp->sectors, DEV_BSIZE);
 
-   ata_prtdev(adp->device, "%d secs/int, %d depth queue, %s%s\n", 
+   ata_prtdev(adp->device, "%d secs/int, %d depth queue, %s%s%s\n", 
   adp->max_iosize / DEV_BSIZE, adp->num_tags + 1,
   (adp->flags & AD_F_TAG_ENABLED) ? "tagged " : "",
-  ata_mode2str(adp->device->mode));
+  ata_mode2str(adp->device->mode),
+  (adp->device->flags & ATA_D_USE_CHS) ? "(CHS mode)": "");
 }
 else
-   ata_prtdev(adp->device,"%lluMB <%.40s> [%lld/%d/%d] at ata%d-%s %s%s\n",
+   ata_prtdev(adp->device,"%lluMB <%.40s> [%lld/%d/%d] at ata%d-%s %s%s%s\n",
   (unsigned long long)(adp->total_secs /
((1024L * 1024L) / DEV_BSIZE)),
   adp->device->param->model,
@@ -404,7 +405,8 @@
   device_get_unit(adp->device->channel->dev),
   (adp->device->unit == ATA_MASTER) ? "master" : "slave",
   (adp->flags & AD_F_TAG_ENABLED) ? "tagged " : "",
-  ata_mode2str(adp->device->mode));
+  ata_mode2str(adp->device->mode),
+  (adp->device->flags & ATA_D_USE_CHS) ? " (CHS mode)": "");

SYSV message queues

2004-04-11 Thread Vlad GALU

Hello. I have the following scenario: one process that creates a
message queue and goes through it in a loop, together with another process
that inserts various messages into the queue. What I wish is for the
'listening' process to be able to fully process the queue at a fixed
amount of time. In short, I'd like msgrcv() to iterate throught the queue
and visit every element in a single run. That set of operations being done
periodically.
Do you find this possible ? I'm quite puzzled here. I first tried
inserting a sleep() call in my queue processing loop but then I noticed
that it had a bad effect. It's true that I haven't read the man page very
carefully the first time. I'll blame it on the hurry.

However, while writing this message, an idea occured to me. What
if I write the processing loop as follows:

-- cut here --
int i;
while (1) {
i = 0;
msgctl(queueid, IPC_STAT, &queuestat);
while (i <= queuestat.msg_qnum) {
msgrcv(queueid, &message, sizeof(message), 0, 0);
process_message(message);
i++;
}
sleep(5);
}
-- and here --

Does this look pheasible ? I'm expecting an injection of about
100k messages per second or even more. There'll be quite a lot of
unprocessed ones at the end of each run, I suppose. I'll measure the average time 
spent for
one run and decide on the sleep interval. However, does anyone have a
better design ?


If it's there, and you can see it, it's real.
If it's not there, and you can see it, it's virtual.
If it's there, and you can't see it, it's transparent.
If it's not there, and you can't see it, you erased it.
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


bus_allloc_resource() in -STABLE sys/pci/if_de.c returning NULL

2004-04-11 Thread Jon Passki
Hello all,

(if this question is not on topic, please let me know)

I'm attempting to debug an issue and I need some assistance.  I am
running a complicated setup using the following:

--) Mac OS X (Panther) running Virtual PC
--) Etherboot boot1a.bin & bin/tulip.rom Virtual PC disk
--) FreeBSD -STABLE diskless-enabled kernel
--) FreeBSD -STABLE Virtual PC disk

I can boot the FreeBSD VPC disk, with everything working great.  I
can boot the Etherboot VPC disk, which netboots a FreeBSD kernel. 
The kernel loads, but the virtual DEC 21041 (de0) driver fails to
attach.  I've figured this out to be at bus_alloc_resource() within
tulip_pci_attach() in sys/pci/if_de.c.  I'm trying to figure out
what's going on and I want to see the why the attach is failing. 
How should I go about this?

Thanks,

Jon Passki


__
Do you Yahoo!?
Yahoo! Tax Center - File online by April 15th
http://taxes.yahoo.com/filing.html
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: SYSV message queues

2004-04-11 Thread Lev Walkin
Vlad GALU wrote:
Hello. I have the following scenario: one process that creates a
message queue and goes through it in a loop, together with another process
that inserts various messages into the queue. What I wish is for the
'listening' process to be able to fully process the queue at a fixed
amount of time. In short, I'd like msgrcv() to iterate throught the queue
and visit every element in a single run. That set of operations being done
periodically.
Do you find this possible ? I'm quite puzzled here. I first tried
inserting a sleep() call in my queue processing loop but then I noticed
that it had a bad effect. It's true that I haven't read the man page very
carefully the first time. I'll blame it on the hurry.
However, while writing this message, an idea occured to me. What
if I write the processing loop as follows:
-- cut here --
int i;
while (1) {
i = 0;
msgctl(queueid, IPC_STAT, &queuestat);
while (i <= queuestat.msg_qnum) {
msgrcv(queueid, &message, sizeof(message), 0, 0);
process_message(message);
i++;
}
sleep(5);
}
-- and here --
Does this look pheasible ? I'm expecting an injection of about
100k messages per second or even more. There'll be quite a lot of
unprocessed ones at the end of each run, I suppose. I'll measure the average time 
spent for
one run and decide on the sleep interval.


Did you try to grok what the msgrcv() call is supposed to return?
Specifically, read about -1/EAGAIN and IPC_NOWAIT. Then remove sleep().
> However, does anyone have a better design ?

Yes. Use sockets.

Obsolescent Unix IPC Methods
http://www.catb.org/~esr/writings/taoup/html/ch07s03.html#id2923376
--
Lev Walkin
[EMAIL PROTECTED]
___
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"