Menu

#80 $ mode2 Segmentation fault (core dumped)

0.9.3
closed
nobody
fixed,
2015-01-24
2014-12-09
metsys
No

lirc-0.9.2pre3

$ uname -a
Linux myhost 2.6.32-504.1.3.el6.x86_64 #1 SMP Tue Nov 11 17:57:25 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/issue
CentOS release 6.6 (Final)

Discussion

  • metsys

    metsys - 2014-12-09
     
  • Alec Leamas

    Alec Leamas - 2014-12-11

    I can't reproduce this.

    That said, a /usr/local installation is generally problematic. You need to provide usable values for many files and directories which usually does not exist.

    Of course, this is not to say that mode2 should segfault. If you look into the CONTRIBUTE.md document you will find instructions how to generate a stacktrace. If you could provide that, it should be possible to fix this.

    Also in CONTRIBUTE.md you will find instructions how to run things straight off the build tree. That could be a starter for you, a basic work-around.

     
  • metsys

    metsys - 2014-12-12

    Ok, I'll try to investigate (need some time)

     

    Last edit: metsys 2014-12-12
  • Alec Leamas

    Alec Leamas - 2014-12-15
    • Milestone: 1.0 --> 0.9.3
     
  • Martin Tharby Jones

    I've just been looking at what appears to be the same problem with the latest from git
    b0b70d8ee25261f717d17f0dce165855fef6bfd8

    martin@Ace:tools$ uname -a
    Linux Ace 3.2.0-4-amd64 #1 SMP Debian 3.2.63-2+deb7u2 x86_64 GNU/Linux
    martin@Ace:tools$ cat /etc/issue
    Debian GNU/Linux 7

    martin@Ace:tools$ /usr/bin/mode2 -Hudp
    Segmentation fault

    martin@Ace:tools$ ./mode2 --plugindir=../plugins/.libs -Hudp
    Segmentation fault

    With the debugger I get as far as:

        static struct driver*
        visit_plugin(const char* path, drv_guest_func func, void* arg)
        // Apply func(hw, arg) for all drivers found in plugin on path.
        {
        struct driver** drivers;
        struct driver* result = (struct driver*) NULL;
    
        (void)dlerror();
        if (last_plugin != NULL)
            dlclose(last_plugin);
        last_plugin = dlopen(path, RTLD_NOW);
    

    it hangs in dlopen, path appears correct "/usr/lib/lirc/plugins/usbx.so" (the first found).

    martin@Ace:lirc-git$ file /usr/lib/lirc/plugins/usbx.so
    /usr/lib/lirc/plugins/usbx.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=0x9705611c85f35cede2ad5960a13920a6ceb0551c, not stripped

     
  • Bengt Martensson

    The program crashes in line 166:

    if (strcmp(device, LIRCD) == 0) {
    

    since device == NULL there. This happens if and only if no -d (--device) argument is given. So a simple work around is to always use a device argument.

    device is a file-local ("static") variable, which probably was set in a previous version.

    Possible fix:

    --- ../lirc-0.9.2.orig/tools/mode2.c    2014-11-23 18:42:09.000000000 +0100
    +++ ../lirc-0.9.2/tools/mode2.c 2015-01-10 21:52:11.275461386 +0100
    @@ -33,6 +33,7 @@
    #include <time.h>
    
    #include "lirc_private.h"
    +#include "driver.h"
     static char *device = NULL;
     static int dmode = 0;
     static int t_div = 500;
    @@ -163,6 +164,8 @@
            strncpy(progname, "mode2", sizeof(progname));
            hw_choose_driver(NULL);
            options_load(argc, argv, NULL, parse_options);
    +        if (device == NULL)
    +                device = (char *) curr_driver->device;
            if (strcmp(device, LIRCD) == 0) {
                    fprintf(stderr, "%s: refusing to connect to lircd socket\n", progname);
                    return EXIT_FAILURE;
    

    (This fix is not at all clean. Sorry Alec, the programming style in the main routines is not at all easy to follow, at least not for me :-).)

     
    • Alec Leamas

      Alec Leamas - 2015-01-11

      One problem with this patch is that the driver will not see the difference between a explicit device set by user and misssing --device option.

      I think the proper fix is to patch default_open in driver.c. This is common code for both lircd and mode2, and gives the driver the opportunity to override the behaviour using it's own open() implementation. I have such a patch under way.

      Sorry Alec, the programming style in
      the main routines is not at all easy to follow, at least not for me :-).

      Just the main routines? ;)

       
  • Alec Leamas

    Alec Leamas - 2015-01-24
    • status: open --> closed
    • Resolution: na, --> fixed,
     
  • Alec Leamas

    Alec Leamas - 2015-01-24

    This was fixed by the [tickets:#90] fix [81b7b2].

     

    Related

    Tickets: #90
    Commit: [81b7b2]


Log in to post a comment.

MongoDB Logo MongoDB