Skip to content

irssi crashes on quitting #1482

@sevan

Description

@sevan

On PowerPC OS X (big endian), when quitting out of irssi by issuing /quit, there is a short delay and the system reports Bus error before dropping you back into the terminal.

Building v1.4.4 with CFLAGS=-g and running it via GDB show the following back trace.

[(status)] /quit
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000000
0x90049a5c in realpath ()
(gdb) bt 
#0  0x90049a5c in realpath ()
#1  0x000518d8 in config_write (rec=0x2107550, fname=0x0, create_mode=432) at write.c:316
#2  0x0002b718 in settings_save (fname=0x210aee0 "/Users/t/.irssi/config", autosave=1) at settings.c:853
#3  0x0002b82c in sig_autosave () at settings.c:875
#4  0x00034cc4 in signal_emit_real (rec=0x210b160, params=0, va=0x1b0 <Address 0x1b0 out of bounds>, first_hook=0xffffffff) at signals.c:242
#5  0x00034ee0 in signal_emit (signal=0xa000edcc "", params=0) at signals.c:286
#6  0x00034cc4 in signal_emit_real (rec=0x210f080, params=0, va=0x1b0 <Address 0x1b0 out of bounds>, first_hook=0xffffffff) at signals.c:242
#7  0x00034ee0 in signal_emit (signal=0xa000edcc "", params=3) at signals.c:286
#8  0x00043dfc in event_command (line=0x215b990 "command quit", server=0x0, item=0x0) at commands.c:920
#9  0x00034cc4 in signal_emit_real (rec=0x210b220, params=0, va=0x1b0 <Address 0x1b0 out of bounds>, first_hook=0xffffffff) at signals.c:242
#10 0x00034ee0 in signal_emit (signal=0xa000edcc "", params=3) at signals.c:286
#11 0x0000a528 in key_send_line () at gui-readline.c:637
#12 0x00034cc4 in signal_emit_real (rec=0x2133500, params=0, va=0x1b0 <Address 0x1b0 out of bounds>, first_hook=0xffffffff) at signals.c:242
#13 0x00034ee0 in signal_emit (signal=0xa000edcc "", params=3) at signals.c:286
#14 0x0003db04 in sig_multi (data=0xa000edcc "", gui_data=0x0) at keyboard.c:748
#15 0x00034cc4 in signal_emit_real (rec=0x211a1c0, params=0, va=0x1b0 <Address 0x1b0 out of bounds>, first_hook=0xffffffff) at signals.c:242
#16 0x00034ee0 in signal_emit (signal=0xa000edcc "", params=3) at signals.c:286
#17 0x0003cfd4 in key_emit_signal (keyboard=0x212e0f0, key=0x212f830) at keyboard.c:616
#18 0x0003d264 in key_pressed (keyboard=0x212e0f0, key=0x215b790 "key multi") at keyboard.c:703
#19 0x0000a3c8 in sig_gui_key_pressed (keyp=0xd) at gui-readline.c:592
#20 0x00034cc4 in signal_emit_real (rec=0x2135c60, params=0, va=0x1b0 <Address 0x1b0 out of bounds>, first_hook=0xffffffff) at signals.c:242
#21 0x00034ee0 in signal_emit (signal=0xa000edcc "", params=1) at signals.c:286
#22 0x0000b3a4 in sig_input () at gui-readline.c:1011
#23 0x0002715c in irssi_io_invoke (source=0x571720, condition=0, data=0xa00061ec) at misc.c:51
#24 0x0054c1a8 in g_main_context_dispatch (context=0x210af90) at gmain.c:3180
#25 0x0054fcc4 in g_main_context_iterate (context=0x210af90, block=1, dispatch=1, self=0xffffffff) at gmain.c:3918
#26 0x0054ff7c in g_main_context_iteration (context=0x210af90, may_block=1) at gmain.c:3979
#27 0x00026d90 in main (argc=964324, argv=0xc6964) at irssi.c:393

Manual for realpath(3) on the system

NAME
     realpath -- returns the canonicalized absolute pathname

LIBRARY
     Standard C Library (libc, -lc)

SYNOPSIS
     #include <sys/param.h>
     #include <stdlib.h>

     char *
     realpath(const char *pathname, char resolved_path[PATH_MAX]);

DESCRIPTION
     The realpath() function resolves all symbolic links, extra ``/'' charac-
     ters and references to /./ and /../ in pathname, and copies the resulting
     absolute pathname into the memory referenced by resolved_path.  The
     resolved_path argument must refer to a buffer capable of storing at least
     PATH_MAX characters.

     The realpath() function will resolve both absolute and relative paths and
     return the absolute pathname corresponding to pathname.  All but the last
     component of pathname must exist when realpath() is called.

RETURN VALUES
     The realpath() function returns resolved_path on success.  If an error
     occurs, realpath() returns NULL, and resolved_path contains the pathname
     which caused the problem.

ERRORS
     The function realpath() may fail and set the external variable errno for
     any of the errors specified for the library functions lstat(2),
     readlink(2) and getcwd(3).

CAVEATS
     This implementation of realpath() differs slightly from the Solaris
     implementation.  The 4.4BSD version always returns absolute pathnames,
     whereas the Solaris implementation will, under certain circumstances,
     return a relative resolved_path when given a relative pathname.

SEE ALSO
     getcwd(3)

HISTORY
     The realpath() function first appeared in 4.4BSD.

A few years back support for Solaris 10 was added to irssi, I wonder if this is a similar scenario.
Using only that method, resolves the issues.

                /* variable path length not supported by glibc < 2.3, Solaris < 11 */
                char resolved_path[PATH_MAX] = { 0 };
                errno = 0;
                if ((dest_name = realpath(base_name, resolved_path)) != NULL) {
                        dest_name = g_strdup(dest_name);
                }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions