Jon K Hellan <[EMAIL PROTECTED]> writes:
> Build it, and run it with stdin closed:
> % ./prog <&-1
> Segmentation fault (core dumped)
>
> (gdb) bt
How did scm_init_fluids sneek into your backtrace? Mine looks like:
% gdb guile
GNU gdb 4.17.m68k.objc.threads.hwwp.fpu.gnat
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i486-pc-linux-gnu"...
(gdb) r <&-1
Starting program: /usr/local/bin/guile <&-1
Program received signal SIGSEGV, Segmentation fault.
0x40060543 in scm_ithrow (key=1075107536, args=1075141056, noreturn=1) at throw.c:635
635 }
(gdb) bt
#0 0x40060543 in scm_ithrow (key=1075107536, args=1075141056, noreturn=1) at
throw.c:635
#1 0x40026b85 in scm_error (key=1075107536, subr=0x4007a000 "scm_fport_buffer_add",
message=0x40079259 "~A", args=1075141032,
rest=1075141016) at error.c:82
#2 0x40026e11 in scm_syserror () at error.c:135
#3 0x400351e8 in scm_fport_buffer_add (port=1075141008, read_size=-1, write_size=-1)
at fports.c:86
#4 0x4003584d in scm_fdes_to_port (fdes=0, mode=0x4007a706 "r", name=1075141000) at
fports.c:388
#5 0x4003ceee in scm_standard_stream_to_port (fdes=0, mode=0x4007a706 "r",
name=0x4007a6f4 "standard input") at init.c:255
#6 0x4003cf50 in scm_init_standard_ports () at init.c:278
#7 0x4003d2b8 in scm_boot_guile_1 (base=0xbffffbd4, closure=0xbffffbd8) at init.c:518
#8 0x4003d0c0 in scm_boot_guile (argc=2, argv=0xbffffc54, main_func=0x80488ec
<inner_main>, closure=0x0) at init.c:392
#9 0x8048931 in main (argc=2, argv=0xbffffc54) at guile.c:76
The segmentation fault only occurs when libguile has been compiled
with optimizations.
When libguile is compiled without optimizations, it produces a clean
`abort' in scm_ithrow:642 in this situation because it wants to throw
an EBADF error about fd 0 but is not yet prepared to handle such
errors.
I don't know why it segfaults when compiled with optimizations.
> Why I care: Gnome object activation closes fd 0 as part of the
> daemonizing procedure. Gnumeric embeds guile, and crashes if it's
> activated via the Gnome Object Activation service.
>
> We can work around this if we have to. But shouldn't guile be
> prepared for this situation.
I think Guile should not produce a segmentation fault, but I also
think that one never ever should expect a program to run with a
invalid fd 0. Instead, one should hook fd 0 to /dev/null or
something. The standard streams should always be valid (IMO).
- Marius