Bug 72962 - [sysinstall] Sysinstall panics on sparc64 if /dev/cd0 present
Summary: [sysinstall] Sysinstall panics on sparc64 if /dev/cd0 present
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: sparc64 (show other bugs)
Version: 5.3-BETA7
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-sparc64 (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-21 13:40 UTC by bel
Modified: 2008-06-10 01:59 UTC (History)
0 users

See Also:


Attachments
libdisk.patch (395 bytes, patch)
2004-10-21 13:40 UTC, bel
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description bel 2004-10-21 13:40:28 UTC
	On sparc64 systems sysinstall panics after "Probing devices, please
wait (this can take a while)...":

Floating point exception (core dumped)

Fix: It is necessary to fix libdisk(3).
How-To-Repeat: 
# gdb53 /usr/obj/usr/src/usr.sbin/sysinstall/sysinstall
GNU gdb 5.3 (FreeBSD)
[...]
This GDB was configured as "sparc64-portbld-freebsd5.2"...
(gdb) run

Program received signal SIGFPE, Arithmetic exception.
0x00000000001241f4 in Int_Open_Disk (name=0x2a4350 "cd0", conftxt=0x276a1c "0")
    at /usr/src/lib/libdisk/open_disk.c:270
270                     o = d->chunks->size / (hd * sc);
(gdb) l
265             /* PLATFORM POLICY BEGIN ------------------------------------- */
266             /* We have a chance to do things on a blank disk here */
267             if (platform == p_sparc64 && d->chunks->part->part == NULL) {
268                     hd = d->bios_hd;
269                     sc = d->bios_sect;
270                     o = d->chunks->size / (hd * sc);
271                     o *= (hd * sc);
272                     o -= 2 * hd * sc;
273                     if (Add_Chunk(d, 0, o, name, freebsd, 0, 0, "-")) {
274                             DPRINT(("Failed to add 'freebsd' chunk"));
(gdb) p hd
$1 = 0
(gdb) p sc
$2 = 0
(gdb) p d[0]
$3 = {name = 0x2a4360 "cd0", bios_cyl = 0, bios_hd = 0, bios_sect = 0, 
  bootmgr = 0x0, bootmgr_size = 0, boot1 = 0x0, chunks = 0x29c200, 
  sector_size = 512}
Comment 1 Ken Smith 2004-10-25 17:35:05 UTC
On Thu, Oct 21, 2004 at 04:36:59PM +0400, Andrew Belashov wrote:
> >Fix:
> 
> 	It is necessary to fix libdisk(3).
> 
> --- libdisk.patch begins here ---
> --- lib/libdisk/open_disk.c.orig	Tue Oct 12 16:02:58 2004
> +++ lib/libdisk/open_disk.c	Thu Oct 21 16:19:40 2004
> @@ -267,6 +267,8 @@ Int_Open_Disk(const char *name, char *co
>  	if (platform == p_sparc64 && d->chunks->part->part == NULL) {
>  		hd = d->bios_hd;
>  		sc = d->bios_sect;
> +		if ((hd * sc) == 0)
> +			return (NULL);
>  		o = d->chunks->size / (hd * sc);
>  		o *= (hd * sc);
>  		o -= 2 * hd * sc;
> --- libdisk.patch ends here ---

Just letting you know...  I'm not ignoring this, I've started to work
on it.  I tested this patch and then passed it off to someone for review.
His reaction was that this patch shouldn't be necessary, sysinstall never
should have gotten this far.  It should have recognized the device more
clearly as a CDROM and not used Int_Open_Disk() as a consequence.  I'm
guessing that this behavior is also why we're seeing CDROM's offered as
*targets* for installation in sysinstall for some configurations.

So at the moment I'm looking through more of sysinstall to understand
a bit better how it's supposed to handle CDROM's.  :-)

-- 
						Ken Smith
- From there to here, from here to      |       kensmith@cse.buffalo.edu
  there, funny things are everywhere.   |
                      - Theodore Geisel |
Comment 2 bel 2004-10-26 11:03:56 UTC
The additional debug information: backtrace, local variables.

root@jail# uname -a
FreeBSD jail.localdomain 5.3-BETA7 FreeBSD 5.3-BETA7 #11: Thu Oct 14
  13:02:53 MSD 2004     bel@bel.localdomain:/usr/obj/usr/src/sys/SUNC3D  sparc64

root@jail# gdb sysinstall
GNU gdb 6.1.1 [FreeBSD]
[...]
This GDB was configured as "sparc64-marcel-freebsd"...
(gdb) b open_disk.c:270
Breakpoint 1 at 0x1241f0: file /usr/src/lib/libdisk/open_disk.c, line 270.
(gdb) run
[...]
Breakpoint 1, Int_Open_Disk (name=0x2726e0 "cd0", conftxt=0x27e81c "0")
     at /usr/src/lib/libdisk/open_disk.c:270
270                     if ((hd * sc) == 0)
(gdb) p d[0].chunks[0]
$1 = {next = 0x0, part = 0x296280, disk = 0x296180, offset = 0, size = 0,
   end = -1, sname = 0x2727a0 "-", name = 0x2732b0 "cd0", oname = 0x0,
   type = whole, subtype = 0, flags = 0, private_free = 0, private_clone = 0,
   private_data = 0x0}

(gdb) bt full
#0  Int_Open_Disk (name=0x2726e0 "cd0", conftxt=0x27e81c "0")
     at /usr/src/lib/libdisk/open_disk.c:270
         d = (struct disk *) 0x296180
         i = 0
         p = 0x27e81e "DISK da0 36420075008 512 hd 255 sc 63"
         q = 0x27e844 "1 SUN da0g 23126791680 512 i 6 o 13290324480 sc 107 hd 27 alt 2\n
1 SUN da0f 10738759680 512 i 5 o 2551564800 sc 107 hd 27 alt 2\n
1 SUN da0e 1073875968 512 i 4 o 1477688832 sc 107 hd 27 alt 2\n
1 SUN da0d "...
         r = 0x27e81b ""
         a = 0x27e81c "0"
         b = 0x27e81a "0"
         n = 0x0
         t = 0x143000 "-8s %-16s %-8s 0x%02x %s"
         sn = 0x0
         o = 0
         len = 0
         off = 1084322560
         l = 320
         s = 2048
         ty = 3
         sc = 0
         hd = 0
         alt = 0
         lo = {0, 0, 0, 0, -1, 8787503075792, 8787503079264, 1082666696, 3, 0}
#1  0x0000000000121438 in Open_Disk (name=0x2726e0 "cd0")
     at /usr/src/lib/libdisk/disk.c:102
         conftxt = 0x27e800 "0"
         txtsize = 486
#2  0x00000000001081b8 in deviceGetAll ()
     at /usr/src/usr.sbin/sysinstall/devices.c:460
         c1 = (Chunk *) 0x2726e0
         d = (Disk *) 0x0
         i = 0
         i = 71
         j = 0
         fd = 2565856
         s = 0
         ifc = {ifc_len = 64, ifc_ifcu = {ifcu_buf = 0x7fdffffe360 "hme0",
     ifcu_req = 0x7fdffffe360}}
         ifptr = (struct ifreq *) 0x2726e0
         end = (struct ifreq *) 0x7fdffffdf60
         buffer = "hme0\000\000\002f\000\000\000\000\000\000\002f\020\002\000\000??ca\000
\000\000\000\000\000\000\000lo0\000\000\000\002f\000\000\000\000\000\000\002f",
'\0' <repeats 18 times>, "\a?????", '\0' <repeats 45 times>, "&?\000\000\000\000\000\000
\000\000=\000\000\000\000\000\000\000\004\000\000\000\000@\204??", '\0' <repeats 15 times>,
" \000\000\a????A\000\000\000\000@\204?x\000\000\000
\000@'\004\000\000\000\000\000@'\006\000\000\000\000\000@'\b\000\000\000\000\000\000\000
\0017\000\000\000T\000\000\022\000\000\000\000\000@'\n\000\000\000\000\000\000\000\000
\003\000\000\000\000\000&?\000\000\000\000\000@\204?d"...
         names = (char **) 0x27e600
#3  0x00000000001144fc in main (argc=1, argv=0x7fdffffec18)
     at /usr/src/usr.sbin/sysinstall/main.c:130
         choice = 0
         scroll = 0
         curr = 0
         max = 0
         status = -6112
(gdb)
Comment 3 tyler 2004-12-22 18:32:42 UTC
yongari@ submitted a workaround to this "critical" bug (an unusable
sysinstall on SCSI CDROM systems counts as critical) that can be found
here:
http://www.freebsd.org/cgi/cvsweb.cgi/src/usr.sbin/sysinstall/devices.c?rev=1.159&content-type=text/x-cvsweb-markup

It doesn't fix the entire problem, for example, the SCSI CDROM still
shows up in fdisk IIRC, but it will make sure that the sysinstall
program can still be used (i.e. just a workaround ;)).

-R. Tyler Ballance
Comment 4 marius 2005-02-28 16:23:22 UTC
Pyun, the underlying cause of this problem is that SCSI CDROMs are
enlisted in kern.disks, which is because cd(4) uses disk(9) since
rev. 1.28 of scsi_cd.c, i.e. also pre-GEOM. Disk(9) is an API for
disk-like storage devices, i.e. not necessarily limited to hard-
disks. Therefore I think sysinstall(8) is actually the right place
to deal with this, rather than geom(4) or libdisk(3), and your
change in src/usr.sbin/sysinstall/devices.c rev. 1.159 is a fix
rather than just a work-around. Maybe the comment could be
improved somewhat but otherwise I think this PR can be closed.

Marius
Comment 5 Pietro Cerutti freebsd_committer freebsd_triage 2008-06-10 01:59:28 UTC
State Changed
From-To: open->closed

Fixed ages ago in sysinstall's code.