Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 Jul 2005 19:14:39 GMT
From:      Harry Coin <harrycoin@qconline.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   kern/83686: kernel resource_xxx_value hints fails to find dynamic environment changes 
Message-ID:  <200507181914.j6IJEdfQ023198@www.freebsd.org>
Resent-Message-ID: <200507181920.j6IJKLEZ069198@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         83686
>Category:       kern
>Synopsis:       kernel resource_xxx_value hints fails to find dynamic environment changes
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jul 18 19:20:21 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Harry Coin
>Release:        5.4
>Organization:
>Environment:
FreeBSD sueofficerm 5.4-RELEASE FreeBSD 5.4-RELEASE #23: Mon Jul 18 13:34:01 CDT 2005     root@server1.quietfountain.com:/usr/obj/usr/src/sys/DISKLESS  i386

>Description:
The resource_xxx routines in subr_hints.c are called before and after the kenv environment in kern_environment.c switches to dynamic.  The prior call sets static variable hintp to the static hints in subr_hints.c. (hintmode==0).  

However, changes to the environment are not detected by the resource_xxx lookups after the change to dynamic kernel environment, so the lookup routines only report the old stuff in hintmode 0, even after the change to dynamic.  Upshot: kenv users see one thing, the kernel routines depending on the same information use a hidden prior kernel environment roster.

When hintmode==0 (usual case), checks in res_find (called by all resource_xxx lookups) fail to note to switch to dynamic kenv because static hintp isn't reset at the top of the routine that checks for the switch to dynamic.  Hence no switch and lookup failure problems.

This is a problem in the mixer.c code that looks up initial mixer volume settings from the hints.  If the hints are dynamic and not from the device.hints file, mixer.c doesn't see them -- but kenv does.  

tested confirmed bugfix below.
>How-To-Repeat:
Add anything via kernel call setenv in kern_environment.c after dynamic has been initialized. 
Try using the resource_xxx routines in subr_hints.c to find the new item.  It won't be there as the lookup routine fails to note the change from static to dynamic hints.  kenv dump and related routines find them.


tested confirmed bugfix below.
>Fix:
--- /usr/src/sys/kern/subr_hints.c	Sun Mar 13 12:05:26 2005
+++ /mnt/server1/usr/src/sys/kern/subr_hints.c	Mon Jul 18 13:53:02 2005
@@ -61,6 +61,7 @@
 	char *p;
 
 	if (checkmethod) {
+		hintp=NULL;
 		switch (hintmode) {
 		case 0:		/* loader hints in environment only */
 			break;

>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200507181914.j6IJEdfQ023198>