[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: store_open() unforgiving in bootstrap fs
From: |
John Tobey |
Subject: |
Re: store_open() unforgiving in bootstrap fs |
Date: |
Mon, 26 Nov 2001 19:36:01 -0500 |
User-agent: |
Mutt/1.2.5i |
On Mon, Nov 26, 2001 at 06:48:42AM -0500, Roland McGrath wrote:
> > The crash came in file_name_lookup() presumably because there is no
> > working directory port yet.
>
> Don't presume, debug! There is no reason why file_name_lookup should ever
> produce a crash (unless given a bad string argument), and if it does then
> that is the bug (in libc).
I have made a little project of extracting the stack trace. Here is
my proposed (untested!) patch:
2001-11-26 John Tobey <jtobey@john-edwin-tobey.org>
* hurd/hurdinit.c (_hurd_ports_use): Avoid a crash if _hurd_ports
is null, e.g., in bootstrap filesystems.
Index: hurd/hurdinit.c
===================================================================
RCS file: /cvs/glibc/libc/hurd/hurdinit.c,v
retrieving revision 1.49
diff -u -r1.49 hurdinit.c
--- hurdinit.c 2001/07/06 04:54:47 1.49
+++ hurdinit.c 2001/11/26 23:19:41
@@ -39,6 +39,8 @@
error_t
_hurd_ports_use (int which, error_t (*operate) (mach_port_t))
{
+ if (_hurd_ports == NULL)
+ return ENOENT;
return HURD_PORT_USE (&_hurd_ports[which], (*operate) (port));
}
END OF PATCH.
Here is the analysis, wherein I manually emulate a debugger: (Needless
to say, I aim to get GDB running under Mach OTOP ASAP.)
EXC_BAD_ACCESS in __spin_try_lock (0)
glibc/sysdeps/mach/i386/machine-lock.h:52
_EXTERN_INLINE int
__spin_try_lock (__spin_lock_t *__lock)
{
register int __locked;
> __asm__ __volatile ("xchgl %0, %1"
: "=&r" (__locked), "=m" (*__lock) : "0" (1));
return !__locked;
}
called from __spin_lock (0)
glibc/mach/lock-intern.h:46
_EXTERN_INLINE void
__spin_lock (__spin_lock_t *__lock)
{
> if (! __spin_try_lock (__lock))
__spin_lock_solid (__lock);
}
called from _hurd_port_get (0, 0x1f90c)
glibc/hurd/hurd/port.h:103
_HURD_PORT_H_EXTERN_INLINE mach_port_t
_hurd_port_get (struct hurd_port *port,
struct hurd_userlink *link)
{
mach_port_t result;
HURD_CRITICAL_BEGIN;
> __spin_lock (&port->lock);
result = _hurd_port_locked_get (port, link);
HURD_CRITICAL_END;
return result;
}
called from HURD_PORT_USE(0, (*operate) (port))
glibc/hurd/hurd/port.h:51
#define HURD_PORT_USE(portcell, expr) \
({ struct hurd_port *const __p = (portcell); \
struct hurd_userlink __link; \
> const mach_port_t port = _hurd_port_get (__p, &__link); \
__typeof(expr) __result = (expr); \
_hurd_port_free (__p, &__link, port); \
__result; })
called from _hurd_ports_use (INIT_PORT_CWDIR, 0x1f95c)
glibc/hurd/hurdinit.c:4
error_t
_hurd_ports_use (int which, error_t (*operate) (mach_port_t))
{
> return HURD_PORT_USE (&_hurd_ports[which], (*operate) (port));
}
called from __hurd_file_name_lookup (_hurd_ports_use, __getdport,
__dir_lookup, "hd0s5", O_RDWR, 0, 0x1fdb0)
glibc/hurd/hurdlookup.c:94
}
> err = (*use_init_port) (startport, &lookup_op);
if (! err)
err = __hurd_file_name_lookup_retry (use_init_port, get_dtable_port,
called from __file_name_lookup ("hd0s5", O_RDWR, 0)
glibc/hurd/hurdlookup.c:235
error_t err;
file_t result;
> err = __hurd_file_name_lookup (&_hurd_ports_use, &__getdport, 0,
file_name, flags, mode & ~_hurd_umask,
&result);
called from store_open ("hd0s5", 0, &store_std_classes, 0x1fec8)
hurd/libstore/open.c:38
{
error_t err;
int open_flags = (flags & STORE_HARD_READONLY) ? O_RDONLY : O_RDWR;
> file_t node = file_name_lookup (name, open_flags, 0);
if (node == MACH_PORT_NULL && !(flags & STORE_HARD_READONLY)
&& (errno == EACCES || errno == EROFS))
called from store_typed_open ("hd0s5", 0, &store_std_classes, 0x1fec8)
hurd/libstore/typed.c:63
else
/* Try opening NAME by querying it as a file instead. */
> return store_open (name, flags, classes, store);
}
called from store_parsed_open::open ("hd0s5", 0x1fec8)
hurd/libstore/argp.c:186
return (*type->open) (pfxed_name, flags, parsed->classes, store);
}
else
> return (*type->open) (name, flags, parsed->classes, store);
}
else
return EOPNOTSUPP;
called from store_parsed_open (0x811a430, 0, 0x1fec8)
hurd/libstore/argp.c:193
if (num == 1)
> return open (parsed->names, store);
else if (num == 0)
called from diskfs_init_main (&startup_argp, 8,
{ "/jtobey/build/gnumach/boot/ext2fs.static",
"--multiboot-command-line=root=hd0s5", "--host-priv-port=2",
"--device-master-port=3", "-T", "typed", "hd0s5" },
&store_parsed, 0x1ff20)
hurd/libdiskfs/init-main.c:43
if (err)
error (4, err, "init");
> err = store_parsed_open (*store_parsed, diskfs_readonly ? STORE_READONLY : 0,
&store);
if (err)
error (3, err, "%s", diskfs_disk_name);
called from main.
--
John Tobey <jtobey@john-edwin-tobey.org>