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

Re: racket (:mz) SEGV's vim

Expand Messages
  • Tim Brown
    Sergey, ... I m subscribed to their twitter feed (including changes/patches etc.). They never stop changing things... ever. Bless em. Can you recommend a
    Message 1 of 29 , Oct 1, 2011
    • 0 Attachment
      Sergey,

      On 1 October 2011 05:25, Sergey Khorev <sergey.khorev@...> wrote:
      > Looks like the folks changed something in Racket... again. I will take a look.

      I'm subscribed to their twitter feed (including changes/patches etc.).
      They never stop changing things... ever. Bless 'em.

      Can you recommend a working pair of vim/racket versions (from source)
      to get me going in the meantime?


      Thanks,

      Tim

      --
      | Tim Brown <tim.brown@...> | M:+44(0)7771714159 | H:01372747875 |

      --
      You received this message from the "vim_dev" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php
    • Sergey Khorev
      ... Yep, that s good for Racket but not so good for embedding applications: API leaps unpredictably and I m yet to see detailed changelog for this kind of
      Message 2 of 29 , Oct 1, 2011
      • 0 Attachment
        > I'm subscribed to their twitter feed (including changes/patches etc.).
        > They never stop changing things... ever. Bless 'em.

        Yep, that's good for Racket but not so good for embedding
        applications: API leaps unpredictably and I'm yet to see detailed
        changelog for this kind of stuff.

        > Can you recommend a working pair of vim/racket versions (from source)
        > to get me going in the meantime?

        MzScheme 4.x and Racket 5.0.1 should work for Vim 7.3.49+

        --
        You received this message from the "vim_dev" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php
      • Sergey Khorev
        ... Actually 5.1.3 has worked for me out of the box (I installed it from Racket PPA on Ubuntu). The only change needed is below (looks like PPA creator decided
        Message 3 of 29 , Oct 1, 2011
        • 0 Attachment
          >> Can you recommend a working pair of vim/racket versions (from source)
          >> to get me going in the meantime?
          >
          > MzScheme 4.x and Racket 5.0.1 should work for Vim 7.3.49+

          Actually 5.1.3 has worked for me out of the box (I installed it from
          Racket PPA on Ubuntu).
          The only change needed is below (looks like PPA creator decided to use
          /usr/share to store collects):
          diff -r fb6b43d55773 src/auto/configure
          --- a/src/auto/configure Fri Sep 30 18:35:57 2011 +0200
          +++ b/src/auto/configure Sat Oct 01 17:25:02 2011 +0300
          @@ -4935,6 +4935,10 @@
          else
          if test -d $vi_cv_path_mzscheme_pfx/lib/racket/collects; then
          SCHEME_COLLECTS=lib/racket/
          + else
          + if test -d $vi_cv_path_mzscheme_pfx/share/racket/collects; then
          + SCHEME_COLLECTS=share/racket/
          + fi
          fi
          fi
          if test -f
          "${vi_cv_path_mzscheme_pfx}/${SCHEME_COLLECTS}collects/scheme/base.ss"
          ; then


          --
          Sergey Khorev
          http://sites.google.com/site/khorser
          Can anybody think of a good tagline I can steal?

          --
          You received this message from the "vim_dev" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php
        • Tim Brown
          Sergey, could you confirm to me that: vim + :mz #f works with racket-5.1.3 It still cores on me. As does racket-5.0.1 ... -- ... -- You received this message
          Message 4 of 29 , Oct 3, 2011
          • 0 Attachment
            Sergey,

            could you confirm to me that:

            vim +':mz #f'

            works with racket-5.1.3

            It still cores on me. As does racket-5.0.1



            On 1 October 2011 15:29, Sergey Khorev <sergey.khorev@...> wrote:
            >>> Can you recommend a working pair of vim/racket versions (from source)
            >>> to get me going in the meantime?
            >>
            >> MzScheme 4.x and Racket 5.0.1 should work for Vim 7.3.49+
            >
            > Actually 5.1.3 has worked for me out of the box (I installed it from
            > Racket PPA on Ubuntu).
            > The only change needed is below (looks like PPA creator decided to use
            > /usr/share to store collects):
            > diff -r fb6b43d55773 src/auto/configure
            > --- a/src/auto/configure        Fri Sep 30 18:35:57 2011 +0200
            > +++ b/src/auto/configure        Sat Oct 01 17:25:02 2011 +0300
            > @@ -4935,6 +4935,10 @@
            >     else
            >       if test -d $vi_cv_path_mzscheme_pfx/lib/racket/collects; then
            >        SCHEME_COLLECTS=lib/racket/
            > +      else
            > +        if test -d $vi_cv_path_mzscheme_pfx/share/racket/collects; then
            > +         SCHEME_COLLECTS=share/racket/
            > +        fi
            >       fi
            >     fi
            >     if test -f
            > "${vi_cv_path_mzscheme_pfx}/${SCHEME_COLLECTS}collects/scheme/base.ss"
            > ; then
            >
            >
            > --
            > Sergey Khorev
            > http://sites.google.com/site/khorser
            > Can anybody think of a good tagline I can steal?
            >
            > --
            > You received this message from the "vim_dev" maillist.
            > Do not top-post! Type your reply below the text you are replying to.
            > For more information, visit http://www.vim.org/maillist.php
            >



            --
            | Tim Brown <tim.brown@...> | M:+44(0)7771714159 | H:01372747875 |
            |----------------------------------------------------------------|
            | vim: syntax=mail textwidth=65 ai nocindent

            --
            You received this message from the "vim_dev" maillist.
            Do not top-post! Type your reply below the text you are replying to.
            For more information, visit http://www.vim.org/maillist.php
          • Sergey Khorev
            ... Ah, got you! ... newer than 3.x. Once Vim has initialised everything should work as expected. In principle someone adventurous might refactor Vim startup
            Message 5 of 29 , Oct 3, 2011
            • 0 Attachment
              > could you confirm to me that:
              >
              > vim +':mz #f'
              >
              > works with racket-5.1.3
              >
              > It still cores on me. As does racket-5.0.1

              Ah, got you!
              :mz from command line does not and will not work with any versions
              newer than 3.x. Once Vim has initialised everything should work as
              expected.
              In principle someone adventurous might refactor Vim startup code to fix this...

              --
              You received this message from the "vim_dev" maillist.
              Do not top-post! Type your reply below the text you are replying to.
              For more information, visit http://www.vim.org/maillist.php
            • Tim Brown
              Sergey, Thanks for your help so far. ... Unfortunately, this is just a test case, and the + :mz #f on the command line isn t actually what I want to do. I m
              Message 6 of 29 , Oct 4, 2011
              • 0 Attachment
                Sergey,

                Thanks for your help so far.

                On 3 October 2011 17:39, Sergey Khorev <sergey.khorev@...> wrote:
                >> could you confirm to me that:
                >>
                >> vim +':mz #f'
                >>
                >> works with racket-5.1.3
                >>
                >> It still cores on me. As does racket-5.0.1
                >
                > Ah, got you!
                > :mz from command line does not and will not work with any versions
                > newer than 3.x. Once Vim has initialised everything should work as
                > expected.

                Unfortunately, this is just a test case, and the +":mz #f" on the
                command line isn't actually what I want to do. I'm trying to put
                together a "syntax" which adds all of the racket keywords (which IMO,
                only racket would know) as :syntax... keywords.

                (In fact: http://www.vim.org/scripts/script.php?script_id=3757)

                Unfortunately, it is not the case that "Vim has initialised
                everything" as I am loading my first racket file which then tries to
                :source/:runtime the vim script via an :autocmd

                In fact, I have to wait until the file is loaded and displayed to me.
                *Then* (and this is the bit I deeply resent) I have to souce the file
                myself! (OK, so it's mapped to a key, but there's a principle here).

                So I have two questions for you:
                * What is wrong with the way vim starts up that it is not ready to
                invoke :mzscheme on a command line, vim -u, syntax load or :autocmd?
                * When, technically has "Vim ... initialised everything"?

                > In principle someone adventurous might refactor Vim startup code to fix this...

                How adventurous?
                How much of this is at the vim end?
                How much of this is at the if_mzscheme/racket end?

                Tim

                --
                | Tim Brown <tim.brown@...> | M:+44(0)7771714159 | H:01372747875 |

                --
                You received this message from the "vim_dev" maillist.
                Do not top-post! Type your reply below the text you are replying to.
                For more information, visit http://www.vim.org/maillist.php
              • Bram Moolenaar
                ... The way mzscheme_main() is called, which then invokes main_loop(), is indeed odd. I suppose this would require moving most of main() into a separate
                Message 7 of 29 , Oct 4, 2011
                • 0 Attachment
                  Sergey Khorev wrote:

                  > > could you confirm to me that:
                  > >
                  > > vim +':mz #f'
                  > >
                  > > works with racket-5.1.3
                  > >
                  > > It still cores on me. As does racket-5.0.1
                  >
                  > Ah, got you!
                  > :mz from command line does not and will not work with any versions
                  > newer than 3.x. Once Vim has initialised everything should work as
                  > expected.
                  > In principle someone adventurous might refactor Vim startup code to
                  > fix this...

                  The way mzscheme_main() is called, which then invokes main_loop(), is
                  indeed odd. I suppose this would require moving most of main() into a
                  separate function.

                  --
                  Despite the cost of living, have you noticed how it remains so popular?

                  /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
                  /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
                  \\\ an exciting new programming language -- http://www.Zimbu.org ///
                  \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

                  --
                  You received this message from the "vim_dev" maillist.
                  Do not top-post! Type your reply below the text you are replying to.
                  For more information, visit http://www.vim.org/maillist.php
                • Sergey Khorev
                  I see your point. Basically, if you application embeds MzScheme v.4+ you need to use trampolined startup: all the Scheme activity should run inside a function
                  Message 8 of 29 , Oct 4, 2011
                  • 0 Attachment

                    I see your point.

                    Basically, if you application embeds MzScheme v.4+ you need to use trampolined startup: all the Scheme activity should run inside a function called from scheme_main_setup. Speaking of Vim it looks like:
                    1) At the end of VimMain in main.c we do mzscheme_main()
                    2) mzscheme_main in if_mzsch.c invokes scheme_main_setup(TRUE, mzscheme_env_main, 0, NULL)
                    3) mzscheme_env_main does some basic initialisations and passes control back to Vim calling its main_loop().

                    I think we can call mzscheme_main earlier, before Vim starts processing command line or scripts. We can wrap the remaining part of VimMain into a function and call it from mzscheme_env_main (reminds me continuation-passing style :)
                    I cannot recall why I did not implement it like that.

                    On Oct 4, 2011 12:44 PM, "Tim Brown" <tim.brown@...> wrote:
                    >
                    > Sergey,
                    >
                    > Thanks for your help so far.
                    >
                    > On 3 October 2011 17:39, Sergey Khorev <sergey.khorev@...> wrote:
                    > >> could you confirm to me that:
                    > >>
                    > >> vim +':mz #f'
                    > >>
                    > >> works with racket-5.1.3
                    > >>
                    > >> It still cores on me. As does racket-5.0.1
                    > >
                    > > Ah, got you!
                    > > :mz from command line does not and will not work with any versions
                    > > newer than 3.x. Once Vim has initialised everything should work as
                    > > expected.
                    >
                    > Unfortunately, this is just a test case, and the +":mz #f" on the
                    > command line isn't actually what I want to do. I'm trying to put
                    > together a "syntax" which adds all of the racket keywords (which IMO,
                    > only racket would know) as :syntax... keywords.
                    >
                    > (In fact: http://www.vim.org/scripts/script.php?script_id=3757)
                    >
                    > Unfortunately, it is not the case that "Vim has initialised
                    > everything" as I am loading my first racket file which then tries to
                    > :source/:runtime the vim script via an :autocmd
                    >
                    > In fact, I have to wait until the file is loaded and displayed to me.
                    > *Then* (and this is the bit I deeply resent) I have to souce the file
                    > myself! (OK, so it's mapped to a key, but there's a principle here).
                    >
                    > So I have two questions for you:
                    >  * What is wrong with the way vim starts up that it is not ready to
                    > invoke :mzscheme on a command line, vim -u, syntax load or :autocmd?
                    >  * When, technically has "Vim ... initialised everything"?
                    >
                    > > In principle someone adventurous might refactor Vim startup code to fix this...
                    >
                    > How adventurous?
                    > How much of this is at the vim end?
                    > How much of this is at the if_mzscheme/racket end?
                    >
                    > Tim
                    >
                    > --
                    > | Tim Brown <tim.brown@...> | M:+44(0)7771714159 | H:01372747875 |
                    >
                    > --
                    > You received this message from the "vim_dev" maillist.
                    > Do not top-post! Type your reply below the text you are replying to.
                    > For more information, visit http://www.vim.org/maillist.php

                    --
                    You received this message from the "vim_dev" maillist.
                    Do not top-post! Type your reply below the text you are replying to.
                    For more information, visit http://www.vim.org/maillist.php
                  • Tim Brown
                    I ve had a quick hack (and not sure how to get a proper patch set up... but), the trampoline should be able to happen as the first thing vim does. It seems to
                    Message 9 of 29 , Oct 4, 2011
                    • 0 Attachment
                      I've had a quick hack (and not sure how to get a proper patch set
                      up... but), the trampoline should be able to happen as the first thing
                      vim does.

                      It seems to work (although I've not tried any "windowing" commands yet)


                      proto/if_mzscheme.pro:

                      int mzscheme_main __ARGS((int, char**));

                      if_mzsch.c:

                      l.801:
                      --------------------------------
                      int
                      mzscheme_main(argc, argv)
                      int argc;
                      char **argv;
                      {
                      #if MZSCHEME_VERSION_MAJOR >= 500 && defined(WIN32) && defined(USE_THREAD_LOCAL)
                      scheme_register_tls_space(&tls_space, 0);
                      #endif
                      #if defined(MZ_PRECISE_GC) && MZSCHEME_VERSION_MAJOR >= 400
                      /* use trampoline for precise GC in MzScheme >= 4.x */
                      scheme_main_setup(TRUE, mzscheme_env_main, argc, argv);
                      #else
                      mzscheme_env_main(NULL, argc, argv);
                      #endif
                      }

                      static int
                      mzscheme_env_main(Scheme_Env *env, int argc, char **argv)
                      {
                      --------------------------------
                      l.849:

                      main(argc, argv);
                      --------------------------------



                      main.c:
                      l.175 (at very top of main):
                      #ifdef FEAT_MZSCHEME
                      {
                      static int mzscheme_trampolined_p = 0;
                      printf("in FEAT_MZSCHEME bit %d\n", mzscheme_trampolined_p);
                      if(!mzscheme_trampolined_p)
                      {
                      mzscheme_trampolined_p++;
                      return mzscheme_main(argc, argv);
                      }
                      }
                      #endif

                      Then at very bottom: l.946:

                      /* Call the main command loop. This never returns.
                      * For embedded MzScheme the main_loop will be called by Scheme
                      * for proper stack tracking
                      */
                      main_loop(FALSE, FALSE);

                      (removing references to FEAT_SCHEME)

                      Tim



                      On 4 October 2011 14:56, Sergey Khorev <sergey.khorev@...> wrote:
                      > I see your point.
                      >
                      > Basically, if you application embeds MzScheme v.4+ you need to use
                      > trampolined startup: all the Scheme activity should run inside a function
                      > called from scheme_main_setup. Speaking of Vim it looks like:
                      > 1) At the end of VimMain in main.c we do mzscheme_main()
                      > 2) mzscheme_main in if_mzsch.c invokes scheme_main_setup(TRUE,
                      > mzscheme_env_main, 0, NULL)
                      > 3) mzscheme_env_main does some basic initialisations and passes control back
                      > to Vim calling its main_loop().
                      >
                      > I think we can call mzscheme_main earlier, before Vim starts processing
                      > command line or scripts. We can wrap the remaining part of VimMain into a
                      > function and call it from mzscheme_env_main (reminds me continuation-passing
                      > style :)
                      > I cannot recall why I did not implement it like that.
                      >
                      > On Oct 4, 2011 12:44 PM, "Tim Brown" <tim.brown@...> wrote:
                      >>
                      >> Sergey,
                      >>
                      >> Thanks for your help so far.
                      >>
                      >> On 3 October 2011 17:39, Sergey Khorev <sergey.khorev@...> wrote:
                      >> >> could you confirm to me that:
                      >> >>
                      >> >> vim +':mz #f'
                      >> >>
                      >> >> works with racket-5.1.3
                      >> >>
                      >> >> It still cores on me. As does racket-5.0.1
                      >> >
                      >> > Ah, got you!
                      >> > :mz from command line does not and will not work with any versions
                      >> > newer than 3.x. Once Vim has initialised everything should work as
                      >> > expected.
                      >>
                      >> Unfortunately, this is just a test case, and the +":mz #f" on the
                      >> command line isn't actually what I want to do. I'm trying to put
                      >> together a "syntax" which adds all of the racket keywords (which IMO,
                      >> only racket would know) as :syntax... keywords.
                      >>
                      >> (In fact: http://www.vim.org/scripts/script.php?script_id=3757)
                      >>
                      >> Unfortunately, it is not the case that "Vim has initialised
                      >> everything" as I am loading my first racket file which then tries to
                      >> :source/:runtime the vim script via an :autocmd
                      >>
                      >> In fact, I have to wait until the file is loaded and displayed to me.
                      >> *Then* (and this is the bit I deeply resent) I have to souce the file
                      >> myself! (OK, so it's mapped to a key, but there's a principle here).
                      >>
                      >> So I have two questions for you:
                      >>  * What is wrong with the way vim starts up that it is not ready to
                      >> invoke :mzscheme on a command line, vim -u, syntax load or :autocmd?
                      >>  * When, technically has "Vim ... initialised everything"?
                      >>
                      >> > In principle someone adventurous might refactor Vim startup code to fix
                      >> > this...
                      >>
                      >> How adventurous?
                      >> How much of this is at the vim end?
                      >> How much of this is at the if_mzscheme/racket end?
                      >>
                      >> Tim
                      >>
                      >> --
                      >> | Tim Brown <tim.brown@...> | M:+44(0)7771714159 | H:01372747875 |
                      >>
                      >> --
                      >> You received this message from the "vim_dev" maillist.
                      >> Do not top-post! Type your reply below the text you are replying to.
                      >> For more information, visit http://www.vim.org/maillist.php
                      >
                      > --
                      > You received this message from the "vim_dev" maillist.
                      > Do not top-post! Type your reply below the text you are replying to.
                      > For more information, visit http://www.vim.org/maillist.php
                      >



                      --
                      | Tim Brown <tim.brown@...> | M:+44(0)7771714159 | H:01372747875 |
                      |----------------------------------------------------------------|
                      | vim: syntax=mail textwidth=65 ai nocindent

                      --
                      You received this message from the "vim_dev" maillist.
                      Do not top-post! Type your reply below the text you are replying to.
                      For more information, visit http://www.vim.org/maillist.php
                    • Tim Brown
                      Attached: diffs covering the changes described below. ... I ve done some trivial tests with :mz including: # vim + :mz #f ... And of personal importance, a
                      Message 10 of 29 , Oct 4, 2011
                      • 0 Attachment
                        Attached: diffs covering the changes described below.

                        On 4 October 2011 15:04, Tim Brown <tim.brown@...> wrote:
                        > I've had a quick hack (and not sure how to get a proper patch set
                        > up... but), the trampoline should be able to happen as the first thing
                        > vim does.

                        I've done some trivial tests with :mz including:

                        # vim +':mz #f'

                        In a vim session:
                        :mz (win? (curr-win))

                        And of personal importance, a test of (in my .vimrc):
                        autocmd BufReadPost *.rkt runtime scripts/racket-auto-keywords.vim

                        No cores.
                        Yay

                        Tim

                        --
                        | Tim Brown <tim.brown@...> | M:+44(0)7771714159 | H:01372747875

                        --
                        You received this message from the "vim_dev" maillist.
                        Do not top-post! Type your reply below the text you are replying to.
                        For more information, visit http://www.vim.org/maillist.php
                      • Tim Brown
                        sorry, i ve left a debug printf in if_mzsch.c ... -- ... -- You received this message from the vim_dev maillist. Do not top-post! Type your reply below the
                        Message 11 of 29 , Oct 4, 2011
                        • 0 Attachment
                          sorry, i've left a debug printf in if_mzsch.c

                          On 4 October 2011 15:19, Tim Brown <tim.brown@...> wrote:
                          > Attached: diffs covering the changes described below.
                          >
                          > On 4 October 2011 15:04, Tim Brown <tim.brown@...> wrote:
                          >> I've had a quick hack (and not sure how to get a proper patch set
                          >> up... but), the trampoline should be able to happen as the first thing
                          >> vim does.
                          >
                          > I've done some trivial tests with :mz including:
                          >
                          > # vim +':mz #f'
                          >
                          > In a vim session:
                          > :mz (win? (curr-win))
                          >
                          > And of personal importance, a test of (in my .vimrc):
                          > autocmd BufReadPost *.rkt runtime scripts/racket-auto-keywords.vim
                          >
                          > No cores.
                          > Yay
                          >
                          > Tim
                          >
                          > --
                          > | Tim Brown <tim.brown@...> | M:+44(0)7771714159 | H:01372747875
                          >



                          --
                          | Tim Brown <tim.brown@...> | M:+44(0)7771714159 | H:01372747875 |
                          |----------------------------------------------------------------|
                          | vim: syntax=mail textwidth=65 ai nocindent

                          --
                          You received this message from the "vim_dev" maillist.
                          Do not top-post! Type your reply below the text you are replying to.
                          For more information, visit http://www.vim.org/maillist.php
                        • Tim Brown
                          Improving stability -- the trampoline has to be split so that a certain degree of initialisation can occur. This has necessitated (in this iteration) that:
                          Message 12 of 29 , Oct 4, 2011
                          • 0 Attachment
                            Improving stability -- the trampoline has to be split so that a
                            certain degree of initialisation can occur.

                            This has necessitated (in this iteration) that:
                            static char_u *fname = NULL;
                            static mparm_T params;
                            static int i;

                            Are all statics (is this OK -- or is there a better way of doing this?).

                            Tim

                            --
                            | Tim Brown <tim.brown@...> | M:+44(0)7771714159 | H:01372747875 |

                            --
                            You received this message from the "vim_dev" maillist.
                            Do not top-post! Type your reply below the text you are replying to.
                            For more information, visit http://www.vim.org/maillist.php
                          • Sergey Khorev
                            ... Sorry, I cannot see why fname should be static, maybe because the patch is incomplete? Can you do diff -cr to compare all the files, also it will make it
                            Message 13 of 29 , Oct 4, 2011
                            • 0 Attachment
                              > Improving stability -- the trampoline has to be split so that a
                              > certain degree of initialisation can occur.
                              >
                              > This has necessitated (in this iteration) that:
                              >  static char_u *fname = NULL;
                              >    static mparm_T      params;
                              >    static int          i;
                              >
                              > Are all statics (is this OK -- or is there a better way of doing this?).

                              Sorry, I cannot see why fname should be static, maybe because the
                              patch is incomplete? Can you do "diff -cr" to compare all the files,
                              also it will make it simpler to apply the patch. If you use Mercurial
                              "hg diff" should do it as well.
                              Anyway this looks quite promising.

                              --
                              You received this message from the "vim_dev" maillist.
                              Do not top-post! Type your reply below the text you are replying to.
                              For more information, visit http://www.vim.org/maillist.php
                            • Tim Brown
                              I ve been testing my cobbled together patch for an afternoon now. Seems to work. I am working on a proper patch via Mercurial. Is main() in main.c the only
                              Message 14 of 29 , Oct 5, 2011
                              • 0 Attachment
                                I've been testing my cobbled together patch for an afternoon now. Seems to work.

                                I am working on a proper patch via Mercurial.

                                Is main() in main.c the only place where vim "starts"?
                                Better put: no matter how vim is started, no matter what OS/Framework,
                                will it go through main.c:main()?

                                Tim

                                On 4 October 2011 18:34, Sergey Khorev <sergey.khorev@...> wrote:
                                >> Improving stability -- the trampoline has to be split so that a
                                >> certain degree of initialisation can occur.
                                >>
                                >> This has necessitated (in this iteration) that:
                                >>  static char_u *fname = NULL;
                                >>    static mparm_T      params;
                                >>    static int          i;
                                >>
                                >> Are all statics (is this OK -- or is there a better way of doing this?).
                                >
                                > Sorry, I cannot see why fname should be static, maybe because the
                                > patch is incomplete? Can you do "diff -cr" to compare all the files,
                                > also it will make it simpler to apply the patch. If you use Mercurial
                                > "hg diff" should do it as well.
                                > Anyway this looks quite promising.



                                --
                                | Tim Brown <tim.brown@...> | M:+44(0)7771714159 | H:01372747875 |

                                --
                                You received this message from the "vim_dev" maillist.
                                Do not top-post! Type your reply below the text you are replying to.
                                For more information, visit http://www.vim.org/maillist.php
                              • Tim Brown
                                ... initialised, e.g. in startup scripts and on the command line. Therefore the following would SEGV: vim + :mz 1 ... works when editing a file. mzscheme
                                Message 15 of 29 , Oct 5, 2011
                                • 0 Attachment
                                  Please find attached a patch for the following issue:

                                  :mzscheme could be invoked before the mzscheme/racket libraries were
                                  initialised, e.g. in startup scripts and on the command line.

                                  Therefore the following would SEGV:
                                  vim +':mz 1'

                                  Even though:
                                  :mz 1
                                  works when editing a file.

                                  mzscheme expects to be invoked by a "trampoline" that wraps around the
                                  main() of the embedding environment -- and this trampoline is around
                                  main_loop().

                                  exe_pre_commands() and source_startup_scripts() are outside the scope
                                  of the trampoline.

                                  This patch causes main() to be called in two parts. The first part
                                  sets up vim's environment and globals, but does not execute any vim
                                  commands (as far as I can tell). It then calls to mzscheme_init, which
                                  eventually recurs into main(); which skips the initialisation, and
                                  proceeds with anything that may perform commands.

                                  Notes:
                                  * I pass fname and params between invocations of main() through the
                                  static variables save_mz_fname and save_mz_params. There is
                                  justification at the top of main() for doing so. I'm not so keen on
                                  statics, myself -- so I've not re-declared fname and params
                                  themselves.
                                  * The other option would be to split main into two parts -- an
                                  "initialisation" and a "commands" part. Then start up vim with:
                                  main(argc, argv)
                                  calls mzscheme_init(argc, argv, fname, params)
                                  calls ... main_part2(argc, argv, fname, params)

                                  [or, in the case of !FEAT_MZSCHEME: main(argc,argv) calls
                                  main_part2(argc, argv, fname, params)]

                                  I think I've done enough in main already! And, unless there is more
                                  general merit in such a refactoring, this is as much disruption as I
                                  need to cause :-)

                                  Thanks Sergey and Bram for your help!

                                  Tim

                                  --
                                  | Tim Brown <tim.brown@...> | M:+44(0)7771714159 | H:01372747875 |

                                  --
                                  You received this message from the "vim_dev" maillist.
                                  Do not top-post! Type your reply below the text you are replying to.
                                  For more information, visit http://www.vim.org/maillist.php
                                • Tim Brown
                                  Google hasn t embedded this in plaintext :-( Here s the patch in a legible format: diff -r 409691084d19 src/if_mzsch.c ... +++ b/src/if_mzsch.c Wed Oct 05
                                  Message 16 of 29 , Oct 5, 2011
                                  • 0 Attachment
                                    Google hasn't embedded this in plaintext :-(

                                    Here's the patch in a legible format:

                                    diff -r 409691084d19 src/if_mzsch.c
                                    --- a/src/if_mzsch.c Tue Oct 04 21:22:44 2011 +0200
                                    +++ b/src/if_mzsch.c Wed Oct 05 11:28:38 2011 +0100
                                    @@ -798,22 +798,22 @@
                                    static __declspec(thread) void *tls_space;
                                    #endif

                                    - void
                                    -mzscheme_main(void)
                                    + int
                                    +mzscheme_main(int argc, char** argv)
                                    {
                                    #if MZSCHEME_VERSION_MAJOR >= 500 && defined(WIN32) &&
                                    defined(USE_THREAD_LOCAL)
                                    scheme_register_tls_space(&tls_space, 0);
                                    #endif
                                    #if defined(MZ_PRECISE_GC) && MZSCHEME_VERSION_MAJOR >= 400
                                    /* use trampoline for precise GC in MzScheme >= 4.x */
                                    - scheme_main_setup(TRUE, mzscheme_env_main, 0, NULL);
                                    + scheme_main_setup(TRUE, mzscheme_env_main, argc, argv);
                                    #else
                                    - mzscheme_env_main(NULL, 0, NULL);
                                    + return mzscheme_env_main(NULL, argc, argv);
                                    #endif
                                    }

                                    static int
                                    -mzscheme_env_main(Scheme_Env *env, int argc UNUSED, char **argv UNUSED)
                                    +mzscheme_env_main(Scheme_Env *env, int argc, char **argv)
                                    {
                                    /* neither argument nor return values are used */
                                    #ifdef MZ_PRECISE_GC
                                    @@ -844,13 +844,19 @@
                                    int dummy = 0;
                                    stack_base = (void *)&dummy;
                                    #endif
                                    - main_loop(FALSE, FALSE);
                                    + /* mzscheme_main is called as a (semi-) trampoline from main.
                                    + * We trampoline back into main -- to avoid a complete refacator.
                                    + * Passing argc, argv through from mzscheme_main
                                    + * */
                                    + {
                                    + int main_rv = main(argc, argv);
                                    #if defined(MZ_PRECISE_GC) && MZSCHEME_VERSION_MAJOR < 400
                                    - /* releasing dummy */
                                    - MZ_GC_REG();
                                    - MZ_GC_UNREG();
                                    + /* releasing dummy */
                                    + MZ_GC_REG();
                                    + MZ_GC_UNREG();
                                    #endif
                                    - return 0;
                                    + return main_rv;
                                    + }
                                    }

                                    static void
                                    diff -r 409691084d19 src/main.c
                                    --- a/src/main.c Tue Oct 04 21:22:44 2011 +0200
                                    +++ b/src/main.c Wed Oct 05 11:28:38 2011 +0100
                                    @@ -172,6 +172,24 @@
                                    int i;
                                    #endif

                                    +#ifdef FEAT_MZSCHEME
                                    + {
                                    + static int mzscheme_trampolined = 0;
                                    + /* TODO: I don't want to change the storage class of fname and params
                                    + * to static. fname is required after the trampoline (i.e. outside this
                                    + * block, and in the recursive call to main()). In the section:
                                    + * "Recovery mode without a file name"
                                    + *
                                    + * params is used quite frequently both inside and outside of this
                                    + * block.
                                    + * */
                                    + static char_u *save_mz_fname = NULL;
                                    + static mparm_T save_mz_params;
                                    + if(!mzscheme_trampolined) /* first time in */
                                    + {
                                    + mzscheme_trampolined = 1; /* there won't be a second time in! */
                                    +#endif
                                    +
                                    /*
                                    * Do any system-specific initialisations. These can NOT use IObuff or
                                    * NameBuff. Thus emsg2() cannot be called!
                                    @@ -554,6 +572,25 @@
                                    debug_break_level = params.use_debug_break_level;
                                    #endif

                                    +#ifdef FEAT_MZSCHEME
                                    + /* save params and fname for when we bouce back from the trampoline */
                                    + save_mz_fname = fname;
                                    + save_mz_params = params;
                                    + /*
                                    + * For embedded MzScheme the main_loop will be called by Scheme
                                    + * for proper stack tracking
                                    + *
                                    + * mzscheme_main calls main, which then calls main_loop which never
                                    + * returns. So the return here is a little redundant.
                                    + */
                                    + return mzscheme_main(argc, argv);
                                    + } /* this ends the if!(mzscheme_trampolined) above */
                                    + /* restore params and fname for when we bouce back from the trampoline */
                                    + fname = save_mz_fname;
                                    + params = save_mz_params;
                                    + }
                                    +#endif
                                    +
                                    /* Execute --cmd arguments. */
                                    exe_pre_commands(¶ms);

                                    @@ -957,14 +994,8 @@

                                    /*
                                    * Call the main command loop. This never returns.
                                    - * For embedded MzScheme the main_loop will be called by Scheme
                                    - * for proper stack tracking
                                    - */
                                    -#ifndef FEAT_MZSCHEME
                                    + */
                                    main_loop(FALSE, FALSE);
                                    -#else
                                    - mzscheme_main();
                                    -#endif

                                    return 0;
                                    }
                                    diff -r 409691084d19 src/proto/if_mzsch.pro
                                    --- a/src/proto/if_mzsch.pro Tue Oct 04 21:22:44 2011 +0200
                                    +++ b/src/proto/if_mzsch.pro Wed Oct 05 11:28:38 2011 +0100
                                    @@ -14,6 +14,6 @@
                                    void mzvim_reset_timer __ARGS((void));
                                    void *mzvim_eval_string __ARGS((char_u *str));
                                    int mzthreads_allowed __ARGS((void));
                                    -void mzscheme_main __ARGS((void));
                                    +int mzscheme_main __ARGS((int argc, char** argv));
                                    void do_mzeval __ARGS((char_u *str, typval_T *rettv));
                                    /* vim: set ft=c : */

                                    --
                                    You received this message from the "vim_dev" maillist.
                                    Do not top-post! Type your reply below the text you are replying to.
                                    For more information, visit http://www.vim.org/maillist.php
                                  • Bram Moolenaar
                                    ... Thanks for the patch, I ll put it on the todo list. Is the configure change that was previously send also needed? -- Don t read everything you believe. ///
                                    Message 17 of 29 , Oct 5, 2011
                                    • 0 Attachment
                                      Tim Brown wrote:

                                      > Please find attached a patch for the following issue:
                                      >
                                      > :mzscheme could be invoked before the mzscheme/racket libraries were
                                      > initialised, e.g. in startup scripts and on the command line.
                                      >
                                      > Therefore the following would SEGV:
                                      > vim +':mz 1'
                                      >
                                      > Even though:
                                      > :mz 1
                                      > works when editing a file.
                                      >
                                      > mzscheme expects to be invoked by a "trampoline" that wraps around the
                                      > main() of the embedding environment -- and this trampoline is around
                                      > main_loop().
                                      >
                                      > exe_pre_commands() and source_startup_scripts() are outside the scope
                                      > of the trampoline.
                                      >
                                      > This patch causes main() to be called in two parts. The first part
                                      > sets up vim's environment and globals, but does not execute any vim
                                      > commands (as far as I can tell). It then calls to mzscheme_init, which
                                      > eventually recurs into main(); which skips the initialisation, and
                                      > proceeds with anything that may perform commands.
                                      >
                                      > Notes:
                                      > * I pass fname and params between invocations of main() through the
                                      > static variables save_mz_fname and save_mz_params. There is
                                      > justification at the top of main() for doing so. I'm not so keen on
                                      > statics, myself -- so I've not re-declared fname and params
                                      > themselves.
                                      > * The other option would be to split main into two parts -- an
                                      > "initialisation" and a "commands" part. Then start up vim with:
                                      > main(argc, argv)
                                      > calls mzscheme_init(argc, argv, fname, params)
                                      > calls ... main_part2(argc, argv, fname, params)
                                      >
                                      > [or, in the case of !FEAT_MZSCHEME: main(argc,argv) calls
                                      > main_part2(argc, argv, fname, params)]
                                      >
                                      > I think I've done enough in main already! And, unless there is more
                                      > general merit in such a refactoring, this is as much disruption as I
                                      > need to cause :-)
                                      >
                                      > Thanks Sergey and Bram for your help!

                                      Thanks for the patch, I'll put it on the todo list.

                                      Is the configure change that was previously send also needed?

                                      --
                                      Don't read everything you believe.

                                      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
                                      /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
                                      \\\ an exciting new programming language -- http://www.Zimbu.org ///
                                      \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

                                      --
                                      You received this message from the "vim_dev" maillist.
                                      Do not top-post! Type your reply below the text you are replying to.
                                      For more information, visit http://www.vim.org/maillist.php
                                    • Tim Brown
                                      I don t know where the configure part of the earlier patch came from --probably my experimentation on some source I found somewhere :-] The patch I submitted
                                      Message 18 of 29 , Oct 5, 2011
                                      • 0 Attachment
                                        I don't know where the configure part of the earlier patch came from --probably my experimentation on some source I found somewhere :-]

                                        The patch I submitted was against a Mercurial clone that I made this morning. The last patch submitted is the nescessary and sufficient.

                                        Tim


                                        -----Original Message-----
                                        From: Bram Moolenaar <Bram@...>
                                        Sent: 05 October 2011 19-31
                                        To: Tim Brown <tim.brown@...>
                                        Cc: vim_dev@...
                                        Subject: Re: racket (:mz) SEGV's vim


                                        Tim Brown wrote:

                                        > Please find attached a patch for the following issue:
                                        >
                                        > :mzscheme could be invoked before the mzscheme/racket libraries were
                                        > initialised, e.g. in startup scripts and on the command line.
                                        >
                                        > Therefore the following would SEGV:
                                        > vim +':mz 1'
                                        >
                                        > Even though:
                                        > :mz 1
                                        > works when editing a file.
                                        >
                                        > mzscheme expects to be invoked by a "trampoline" that wraps around the
                                        > main() of the embedding environment -- and this trampoline is around
                                        > main_loop().
                                        >
                                        > exe_pre_commands() and source_startup_scripts() are outside the scope
                                        > of the trampoline.
                                        >
                                        > This patch causes main() to be called in two parts. The first part
                                        > sets up vim's environment and globals, but does not execute any vim
                                        > commands (as far as I can tell). It then calls to mzscheme_init, which
                                        > eventually recurs into main(); which skips the initialisation, and
                                        > proceeds with anything that may perform commands.
                                        >
                                        > Notes:
                                        > * I pass fname and params between invocations of main() through the
                                        > static variables save_mz_fname and save_mz_params. There is
                                        > justification at the top of main() for doing so. I'm not so keen on
                                        > statics, myself -- so I've not re-declared fname and params
                                        > themselves.
                                        > * The other option would be to split main into two parts -- an
                                        > "initialisation" and a "commands" part. Then start up vim with:
                                        > main(argc, argv)
                                        > calls mzscheme_init(argc, argv, fname, params)
                                        > calls ... main_part2(argc, argv, fname, params)
                                        >
                                        > [or, in the case of !FEAT_MZSCHEME: main(argc,argv) calls
                                        > main_part2(argc, argv, fname, params)]
                                        >
                                        > I think I've done enough in main already! And, unless there is more
                                        > general merit in such a refactoring, this is as much disruption as I
                                        > need to cause :-)
                                        >
                                        > Thanks Sergey and Bram for your help!

                                        Thanks for the patch, I'll put it on the todo list.

                                        Is the configure change that was previously send also needed?

                                        --
                                        Don't read everything you believe.

                                        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
                                        /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
                                        \\\ an exciting new programming language -- http://www.Zimbu.org ///
                                        \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

                                        --
                                        You received this message from the "vim_dev" maillist.
                                        Do not top-post! Type your reply below the text you are replying to.
                                        For more information, visit http://www.vim.org/maillist.php

                                        --
                                        You received this message from the "vim_dev" maillist.
                                        Do not top-post! Type your reply below the text you are replying to.
                                        For more information, visit http://www.vim.org/maillist.php
                                      • Sergey Khorev
                                        ... Cool, I will play with it on the weekend. ... refacator must be an interesting concept ;) -- You received this message from the vim_dev maillist. Do not
                                        Message 19 of 29 , Oct 5, 2011
                                        • 0 Attachment
                                          > Here's the patch in a legible format:

                                          Cool, I will play with it on the weekend.

                                          > +     * We trampoline back into main -- to avoid a complete refacator.

                                          refacator must be an interesting concept ;)

                                          --
                                          You received this message from the "vim_dev" maillist.
                                          Do not top-post! Type your reply below the text you are replying to.
                                          For more information, visit http://www.vim.org/maillist.php
                                        • Tim Brown
                                          ... It s all the rage here! -- ... -- You received this message from the vim_dev maillist. Do not top-post! Type your reply below the text you are replying
                                          Message 20 of 29 , Oct 6, 2011
                                          • 0 Attachment
                                            On 6 October 2011 04:13, Sergey Khorev <sergey.khorev@...> wrote:
                                            > refacator must be an interesting concept ;)

                                            It's all the rage here!

                                            --
                                            | Tim Brown <tim.brown@...> | M:+44(0)7771714159 | H:01372747875 |

                                            --
                                            You received this message from the "vim_dev" maillist.
                                            Do not top-post! Type your reply below the text you are replying to.
                                            For more information, visit http://www.vim.org/maillist.php
                                          • Tim Brown
                                            ... Apologies for the top-post, I forgot that my windows phone has that as its habit. I ll take more care next time! -- ... -- You received this message from
                                            Message 21 of 29 , Oct 6, 2011
                                            • 0 Attachment
                                              On 5 October 2011 21:27, Tim Brown <mightyfoo@...> wrote:
                                              > ...
                                              > -----Original Message-----
                                              > From: Bram Moolenaar <Bram@...>
                                              > Sent: 05 October 2011 19-31
                                              > To: Tim Brown <tim.brown@...>
                                              > Cc: vim_dev@...
                                              > Subject: Re: racket (:mz) SEGV's vim
                                              > ...

                                              Apologies for the top-post, I forgot that my windows phone has that as
                                              its habit. I'll take more care next time!

                                              --
                                              | Tim Brown <tim.brown@...> | M:+44(0)7771714159 | H:01372747875 |

                                              --
                                              You received this message from the "vim_dev" maillist.
                                              Do not top-post! Type your reply below the text you are replying to.
                                              For more information, visit http://www.vim.org/maillist.php
                                            • Tim Brown
                                              Bram, I ve not seen this patch go into vim yet. Did I miss it? ... Is this still on your todo list? Is there a problem with the patch, or are you waiting on
                                              Message 22 of 29 , Dec 10, 2011
                                              • 0 Attachment
                                                Bram,

                                                I've not seen this patch go into vim yet.
                                                Did I miss it?

                                                On Oct 5, 6:31 pm, Bram Moolenaar <B...@...> wrote:
                                                > Thanks for the patch, I'll put it on the todo list.

                                                Is this still on your todo list?
                                                Is there a problem with the patch,
                                                or are you waiting on some input from Sergey or me?

                                                Tim

                                                --
                                                You received this message from the "vim_dev" maillist.
                                                Do not top-post! Type your reply below the text you are replying to.
                                                For more information, visit http://www.vim.org/maillist.php
                                              • Bram Moolenaar
                                                ... I think it s this note: Other way to start Mzscheme. Tim Brown, 2011 Oct 5: change main call. Later patch by Sergey Khorev, 2011 Oct 9. I haven t looked at
                                                Message 23 of 29 , Dec 10, 2011
                                                • 0 Attachment
                                                  Tim Brown wrote:

                                                  > I've not seen this patch go into vim yet.
                                                  > Did I miss it?
                                                  >
                                                  > On Oct 5, 6:31 pm, Bram Moolenaar <B...@...> wrote:
                                                  > > Thanks for the patch, I'll put it on the todo list.
                                                  >
                                                  > Is this still on your todo list?
                                                  > Is there a problem with the patch,
                                                  > or are you waiting on some input from Sergey or me?

                                                  I think it's this note:

                                                  Other way to start Mzscheme. Tim Brown, 2011 Oct 5: change main call.
                                                  Later patch by Sergey Khorev, 2011 Oct 9.

                                                  I haven't looked at it yet, are you OK with Sergey's patch that he sent
                                                  Oct 9?

                                                  --
                                                  There is a fine line between courage and foolishness.
                                                  Unfortunately, it's not a fence.

                                                  /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
                                                  /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
                                                  \\\ an exciting new programming language -- http://www.Zimbu.org ///
                                                  \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

                                                  --
                                                  You received this message from the "vim_dev" maillist.
                                                  Do not top-post! Type your reply below the text you are replying to.
                                                  For more information, visit http://www.vim.org/maillist.php
                                                • Tim Brown
                                                  Bram, ... Sorry - took my eye off the ball here. I ve been working fine with this patch applied since October. I d be happy for it to be merged. Tim -- ... --
                                                  Message 24 of 29 , Mar 28, 2012
                                                  • 0 Attachment
                                                    Bram,

                                                    On 10 December 2011 20:20, Bram Moolenaar <Bram@...> wrote:
                                                    I think it's this note:

                                                    Other way to start Mzscheme. Tim Brown, 2011 Oct 5: change main call.
                                                    Later patch by Sergey Khorev, 2011 Oct 9.

                                                    I haven't looked at it yet, are you OK with Sergey's patch that he sent
                                                    Oct 9?

                                                    Sorry - took my eye off the ball here.

                                                    I've been working fine with this patch applied since October. I'd be happy for it to be merged.

                                                    Tim

                                                     
                                                    --
                                                    | Tim Brown <tim.brown@...> | M:+44(0)7771714159 | H:+44(0)1372747875 |

                                                    --
                                                    You received this message from the "vim_dev" maillist.
                                                    Do not top-post! Type your reply below the text you are replying to.
                                                    For more information, visit http://www.vim.org/maillist.php
                                                  • Sergey Khorev
                                                    ... It s in Vim Mercurial repository already :) -- You received this message from the vim_dev maillist. Do not top-post! Type your reply below the text you
                                                    Message 25 of 29 , Mar 28, 2012
                                                    • 0 Attachment
                                                      >> I haven't looked at it yet, are you OK with Sergey's patch that he sent
                                                      >> Oct 9?
                                                      >
                                                      >
                                                      > Sorry - took my eye off the ball here.
                                                      >
                                                      > I've been working fine with this patch applied since October. I'd be happy
                                                      > for it to be merged.

                                                      It's in Vim Mercurial repository already :)

                                                      --
                                                      You received this message from the "vim_dev" maillist.
                                                      Do not top-post! Type your reply below the text you are replying to.
                                                      For more information, visit http://www.vim.org/maillist.php
                                                    • Bram Moolenaar
                                                      ... If I m not mistaken this was included with patch 7.3.441. So, unless there is something wrong, there nothing more to do. -- Edison s greatest achievement
                                                      Message 26 of 29 , Mar 28, 2012
                                                      • 0 Attachment
                                                        Tim Brown wrote:

                                                        > On 10 December 2011 20:20, Bram Moolenaar <Bram@...> wrote:
                                                        >
                                                        > > I think it's this note:
                                                        > >
                                                        > > Other way to start Mzscheme. Tim Brown, 2011 Oct 5: change main call.
                                                        > > Later patch by Sergey Khorev, 2011 Oct 9.
                                                        > >
                                                        > > I haven't looked at it yet, are you OK with Sergey's patch that he sent
                                                        > > Oct 9?
                                                        > >
                                                        >
                                                        > Sorry - took my eye off the ball here.
                                                        >
                                                        > I've been working fine with this patch applied since October. I'd be happy
                                                        > for it to be merged.

                                                        If I'm not mistaken this was included with patch 7.3.441. So, unless
                                                        there is something wrong, there nothing more to do.

                                                        --
                                                        Edison's greatest achievement came in 1879, when he invented the
                                                        electric company. Edison's design was a brilliant adaptation of the
                                                        simple electrical circuit: the electric company sends electricity
                                                        through a wire to a customer, then immediately gets the electricity
                                                        back through another wire

                                                        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
                                                        /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
                                                        \\\ an exciting new programming language -- http://www.Zimbu.org ///
                                                        \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

                                                        --
                                                        You received this message from the "vim_dev" maillist.
                                                        Do not top-post! Type your reply below the text you are replying to.
                                                        For more information, visit http://www.vim.org/maillist.php
                                                      Your message has been successfully submitted and would be delivered to recipients shortly.