From owner-freebsd-hackers Sun Jul 15 3:49:40 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from hpux37.dc.engr.scu.edu (hpux37.dc.engr.scu.edu [129.210.16.37]) by hub.freebsd.org (Postfix) with ESMTP id 5C9E937B403 for ; Sun, 15 Jul 2001 03:49:31 -0700 (PDT) (envelope-from dclark@applmath.scu.edu) Received: from localhost (dclark@localhost) by hpux37.dc.engr.scu.edu (8.10.2/8.10.2) with ESMTP id f6CHo6L26365 for ; Thu, 12 Jul 2001 10:50:07 -0700 (PDT) Date: Thu, 12 Jul 2001 10:50:06 -0700 (PDT) From: "Dorr H. Clark" To: freebsd-hackers@freebsd.org Subject: now OK, was - need help: gdb -k 4.16/7 Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Some time ago, I wrote: > I am experimenting with porting an application > from the FreeBSD 2.2.x series to a more modern release, > and as such I have occaision to debug kernel core files > under the old release using the gdb -k option > (saved via savecore). The problem is the old kernel > has been customized with a different load address > (new style 0xC0000000 vs. old style 0xF0000000). > ... The problem is the resulting gdb -k sessions > are not fully functional... 80% of all problems that appear to be OS problems are really application problems. This was one of them. It turns out that there were more changes than just the load address, the application malloc() calls in the custom kernel had also been changed from 512, 1k, & 2k (sub-page fragments) to full page allocations (actually multi-page). As you may know, FreeBSD malloc()s of sub-page fragments in the kernel are permanent, when they are freed they are put on queues according to size buckets. In contrast, freeing multiple whole pages truly frees the pages, including unmapping! So when the kernel went down, the at_shutdown() call was freeing all the memory, and unmapping it. This side effect was never noticed in the old system, the debugging of cores was actually relying on the stale mapping of freed memory (I didn't do this code myself, so I didn't catch it before). The fix was only to free() in in the at_shutdown() call IF a normal shutdown is in progress (i.e.- not a panic, page_fault, etc.). I just wanted to share the absolution of the product for the permanent record. The custom FreeBSD kernel is doing the Right Thing (tm), gdb is doing the Right Thing (tm), savecore and wddump() are doing the Right Thing (tm), and when the application code is doing the right thing the cores are completely debuggable. Thanks for the previous responses, it was helpful in straightening this bug out, -Dorr H. Clark Santa Clara University To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message