Loading ...
Sorry, an error occurred while loading the content.

Re: [BUG] VIM exits when do profiling

Expand Messages
  • Bram Moolenaar
    ... The obvious thing to do is use PROFILE_CFLAGS = -pg -g -DWE_ARE_PROFILING and #if defined(SIGPROF) && !defined(FEAT_MZSCHEME) && !defined(WE_ARE_PROFILING)
    Message 1 of 5 , Mar 5, 2008
    • 0 Attachment
      Liu Yubao wrote:

      > I found VIM(https://vim.svn.sourceforge.net/svnroot/vim/vim7@929)
      > exits when I enable profiling flags in src/Makefile:
      >
      > --- Makefile (revision 929)
      > +++ Makefile (working copy)
      > @@ -545,8 +545,8 @@
      > # For unknown reasons adding "-lc" fixes a linking problem with
      > GCC. That's
      > # probably a bug in the "-pg" implementation.
      > # Need to recompile everything after changing this: "make clean"
      > "make".
      > -#PROFILE_CFLAGS = -pg -g
      > -#PROFILE_LIBS = -pg
      > +PROFILE_CFLAGS = -pg -g
      > +PROFILE_LIBS = -pg
      > #PROFILE_LIBS = -pg -lc
      >
      >
      > $ ./vim -u NONE -U NONE -c ":q" ../bigfile
      > vim: Caught deadly signal PROF
      > vim: Finished.
      > Profiling timer expired.
      >
      > After comment out line 274 in os_unix.c I can run that command normally,
      > so I think os_unix.c requires a patch like this:
      >
      > Index: os_unix.c
      > ===================================================================
      > --- os_unix.c (revision 929)
      > +++ os_unix.c (working copy)
      > @@ -269,7 +269,7 @@
      > #ifdef SIGVTALRM
      > {SIGVTALRM, "VTALRM", TRUE},
      > #endif
      > -#if defined(SIGPROF) && !defined(FEAT_MZSCHEME)
      > +#if defined(SIGPROF) && !defined(FEAT_MZSCHEME) && ! DO_GPROF
      > /* MzScheme uses SIGPROF for its own needs */
      > {SIGPROF, "PROF", TRUE},
      > #endif
      >
      > This is not a real patch because I don't know how to define DO_GPROF,
      > maybe there is already a macro can tell we are compiling with gprof
      > support.

      The obvious thing to do is use

      PROFILE_CFLAGS = -pg -g -DWE_ARE_PROFILING

      and

      #if defined(SIGPROF) && !defined(FEAT_MZSCHEME) && !defined(WE_ARE_PROFILING)

      > I compile and test the code on Debian Etch.

      I'm running on FreeBSD, it works just fine without disabling that
      SIGPROF line. Is there something about Debian that works differently
      with signals?

      --
      Warning label on a superhero Halloween costume:
      "Caution: Cape does not enable user to fly."

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
      \\\ download, build and distribute -- http://www.A-A-P.org ///
      \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_dev" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Liu Yubao
      ... I test the program below on Debian Etch, Debian Lenny, Ubuntu Gusty, Fedora Core and FreeBSD, strangely it doesn t trigger func_deadly() only on FreeBSD.
      Message 2 of 5 , Mar 5, 2008
      • 0 Attachment
        Bram Moolenaar wrote:
        > Liu Yubao wrote:
        >> I found VIM(https://vim.svn.sourceforge.net/svnroot/vim/vim7@929)
        >> exits when I enable profiling flags in src/Makefile:
        >
        >> I compile and test the code on Debian Etch.
        >
        > I'm running on FreeBSD, it works just fine without disabling that
        > SIGPROF line. Is there something about Debian that works differently
        > with signals?
        >

        I test the program below on Debian Etch, Debian Lenny, Ubuntu Gusty,
        Fedora Core and FreeBSD, strangely it doesn't trigger func_deadly()
        only on FreeBSD. I'm not sure whether it's a bug or a feature in Linux
        kernel.

        Here are some version information:
        Debian Etch: linux kernel 2.6.18-4-686, gcc 4.1.2, libc 2.3.6
        Debian Lenny: linux kernel 2.6.22-3-686, gcc 4.2.3, libc 2.7
        Ubuntu Gusty: linux kernel 2.6.22-14-generic(x86_64), gcc 4.1.3, libc 2.6.1
        Fedora Core 6: linux kernel 2.6.20(x86_64), gcc 4.1.2, libc 2.5
        Fedora Core 7: linux kernel 2.6.23.8-34(x86_64), gcc 4.1.2
        FreeBSD 6.2: gcc 3.4.6
        FreeBSD 7.0: gcc 4.2.1

        And the source code:

        /*
        * $ gcc -g -pg -o sigprof sigprof.c
        * $ ./sigprof
        */
        #include <stdio.h>
        #include <unistd.h>
        #include <signal.h>

        void func_deadly(int signo)
        {
        fprintf(stderr, "dead: signo=%d, SIGPROF=%d\n", signo, SIGPROF);
        _exit(1);
        }


        int main(void)
        {
        int n = 0;
        int a = 1, b = 2;
        struct sigaction sa;

        sa.sa_handler = func_deadly;
        sa.sa_flags = SA_ONSTACK;
        sigemptyset(&sa.sa_mask);
        sigaction(SIGPROF, &sa, NULL);

        #if 1
        /* can receive SIGPROF */
        while (++n < 10000000)
        a = a * b * b * a * b * b / 3;
        #else
        /* can't receive SIGPROF */
        while (++n < 4)
        sleep(2);
        #endif

        return 0;
        }


        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_dev" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Bram Moolenaar
        ... I tried disabling SIGPROF on FreeBSD, doesn t seem to make a difference. Did you try that -D in the Makefile, as I suggested? -- ... /// Bram Moolenaar --
        Message 3 of 5 , Mar 5, 2008
        • 0 Attachment
          Liu Yubao wrote:

          > >> I found VIM(https://vim.svn.sourceforge.net/svnroot/vim/vim7@929)
          > >> exits when I enable profiling flags in src/Makefile:
          > >
          > >> I compile and test the code on Debian Etch.
          > >
          > > I'm running on FreeBSD, it works just fine without disabling that
          > > SIGPROF line. Is there something about Debian that works differently
          > > with signals?
          > >
          >
          > I test the program below on Debian Etch, Debian Lenny, Ubuntu Gusty,
          > Fedora Core and FreeBSD, strangely it doesn't trigger func_deadly()
          > only on FreeBSD. I'm not sure whether it's a bug or a feature in Linux
          > kernel.
          >
          > Here are some version information:
          > Debian Etch: linux kernel 2.6.18-4-686, gcc 4.1.2, libc 2.3.6
          > Debian Lenny: linux kernel 2.6.22-3-686, gcc 4.2.3, libc 2.7
          > Ubuntu Gusty: linux kernel 2.6.22-14-generic(x86_64), gcc 4.1.3, libc 2.6.1
          > Fedora Core 6: linux kernel 2.6.20(x86_64), gcc 4.1.2, libc 2.5
          > Fedora Core 7: linux kernel 2.6.23.8-34(x86_64), gcc 4.1.2
          > FreeBSD 6.2: gcc 3.4.6
          > FreeBSD 7.0: gcc 4.2.1

          I tried disabling SIGPROF on FreeBSD, doesn't seem to make a difference.
          Did you try that -D in the Makefile, as I suggested?

          --
          From "know your smileys":
          :'-D Laughing so much that they're crying

          /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
          /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
          \\\ download, build and distribute -- http://www.A-A-P.org ///
          \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_dev" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • Liu Yubao
          ... Yes, I tried, it works on Linux. It seems it s a problem specific to Linux. Best regards, Liu Yubao --~--~---------~--~----~------------~-------~--~----~
          Message 4 of 5 , Mar 5, 2008
          • 0 Attachment
            Bram Moolenaar wrote:
            > Liu Yubao wrote:
            >
            >> I test the program below on Debian Etch, Debian Lenny, Ubuntu Gusty,
            >> Fedora Core and FreeBSD, strangely it doesn't trigger func_deadly()
            >> only on FreeBSD. I'm not sure whether it's a bug or a feature in Linux
            >> kernel.
            >>
            >> Here are some version information:
            >> Debian Etch: linux kernel 2.6.18-4-686, gcc 4.1.2, libc 2.3.6
            >> Debian Lenny: linux kernel 2.6.22-3-686, gcc 4.2.3, libc 2.7
            >> Ubuntu Gusty: linux kernel 2.6.22-14-generic(x86_64), gcc 4.1.3, libc 2.6.1
            >> Fedora Core 6: linux kernel 2.6.20(x86_64), gcc 4.1.2, libc 2.5
            >> Fedora Core 7: linux kernel 2.6.23.8-34(x86_64), gcc 4.1.2
            >> FreeBSD 6.2: gcc 3.4.6
            >> FreeBSD 7.0: gcc 4.2.1
            >
            > I tried disabling SIGPROF on FreeBSD, doesn't seem to make a difference.
            > Did you try that -D in the Makefile, as I suggested?
            >

            Yes, I tried, it works on Linux. It seems it's a problem specific to Linux.


            Best regards,

            Liu Yubao

            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_dev" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          Your message has been successfully submitted and would be delivered to recipients shortly.