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

Re: Embedding racket in vim

Expand Messages
  • Sergey Khorev
    ... I have no access to a Mac so will have to guess. What versions of Vim and Racket do you use? Also latest update to the mzscheme interface did not make it
    Message 1 of 8 , Dec 12, 2012
    • 0 Attachment
      > I have recently installed a version of vim with the mzscheme option enabled.
      > And it sortof works except that some times it segfaults or has other memory
      > corruption issues. So I enabled MZ_GC_CHECK when compiling vim, and now I
      > get the corruption every single time on startup.

      I have no access to a Mac so will have to guess. What versions of Vim and Racket do you use?
      Also latest update to the mzscheme interface did not make it into Vim yet, it is available as a clone on Google Code (http://code.google.com/r/sergeykhorev-vim-mzscheme/source/browse). Would you be able to give it a try?

      --
      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
    • Eric Dobson
      I figured this out. It was that vim was not being compiled with the precise garbage collection when racket was, and a couple of bugs on the vim allocation of
      Message 2 of 8 , Dec 13, 2012
      • 0 Attachment
        I figured this out. It was that vim was not being compiled with the precise garbage collection when racket was, and a couple of bugs on the vim allocation of racket objects. I'll hopefully have a patch soon.


        On Mon, Dec 10, 2012 at 10:32 PM, Eric Dobson <eric.n.dobson@...> wrote:
        +correct vim group.



        On Mon, Dec 10, 2012 at 10:25 PM, Eric Dobson <eric.n.dobson@...> wrote:
        I have recently installed a version of vim with the mzscheme option enabled. And it sortof works except that some times it segfaults or has other memory corruption issues. So I enabled MZ_GC_CHECK when compiling vim, and now I get the corruption every single time on startup.

        Here is the output from gdb when running it:

        GNU gdb 6.3.50-20050815 (Apple version gdb-1820) (Sat Jun 16 02:40:11 UTC 2012)
        Copyright 2004 Free Software Foundation, Inc.
        GDB is free software, covered by the GNU General Public License, and you are
        welcome to change it and/or distribute copies of it under certain conditions.
        Type "show copying" to see the conditions.
        There is absolutely no warranty for GDB.  Type "show warranty" for details.
        This GDB was configured as "x86_64-apple-darwin"...
        warning: Unable to read symbols for Racket.framework/Versions/5.3.1.9_3m/Racket (file not found).

        warning: Unable to read symbols from "Racket" (not yet mapped into memory).
        Reading symbols for shared libraries .......... done

        (gdb) run
        Starting program: /Users/endobson/proj/vim/install/bin/vim
        Reading symbols for shared libraries ++++.+++++....................................................................................................................................... done
        Reading symbols for shared libraries . done
        ?: bad module path
          in: #<bad-value>
          context...:
           standard-module-name-resolver

        Program received signal EXC_BAD_ACCESS, Could not access memory.
        Reason: KERN_INVALID_ADDRESS at address: 0x00000000000000a0
        0x0000000100328d99 in scheme_top_level_do_worker (dyn_state=0x0, k=0x7fff5fbfdd10, eb=1000, new_thread=1606409488) at fun.c:1227
        1227            scheme_longjmp(*save, 1);
        (gdb) bt
        #0  0x0000000100328d99 in scheme_top_level_do_worker (dyn_state=0x0, k=0x7fff5fbfdd10, eb=1000, new_thread=1606409488) at fun.c:1227
        #1  0x00000001003ff41e in _module_resolve (modidx=0x103004150, stx=0x103004068, env=0x0, load_it=1) at module.c:3860
        #2  0x000000010041162a in parse_requires () at schthread.h:376
        #3  0x00000001004122e4 in do_namespace_require () at module.c:7685
        #4  0x00000001004123ce in scheme_namespace_require (r=0x103ec8008) at module.c:1316
        #5  0x00000001001574dd in _mh_execute_header ()
        #6  0x00000001001585d8 in _mh_execute_header ()
        #7  0x000000010005bc43 in _mh_execute_header ()
        #8  0x000000010004ca4a in _mh_execute_header ()
        #9  0x000000010015f608 in _mh_execute_header ()
        #10 0x00000001002a6093 in call_with_basic (data=0x103ec8008) at schthread.h:376
        #11 0x00000001002a64a8 in scheme_main_setup (no_auto_statics=1606414024, _main=0x7fff5fbfe268, argc=6433496, argv=0x7fff5fbfe240) at salloc.c:194
        #12 0x0000000100161fff in _mh_execute_header ()
        #13 0x00007fff939eb7e1 in start ()
        (gdb) 

        I can include more information if you can tell me what is useful.


        --
        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
        ... Are you talking about official Vim source? For http://code.google.com/r/sergeykhorev-vim-mzscheme/source I reworked some memory allocation stuff so
        Message 3 of 8 , Dec 14, 2012
        • 0 Attachment
          On Fri, Dec 14, 2012 at 9:20 AM, Eric Dobson <eric.n.dobson@...> wrote:
          I figured this out. It was that vim was not being compiled with the precise garbage collection when racket was, and a couple of bugs on the vim allocation of racket objects. I'll hopefully have a patch soon.
           

          Are you talking about official Vim source? For http://code.google.com/r/sergeykhorev-vim-mzscheme/source I reworked some memory allocation stuff so something must have changed in this regard :) 

          --
          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
        • Eric Dobson
          Yes I was using the official source. Here is the patch of my changes, some of which you may already have. diff -r 52bfa939fc07 src/auto/configure ... +++
          Message 4 of 8 , Dec 16, 2012
          • 0 Attachment
            Yes I was using the official source. 

            Here is the patch of my changes, some of which you may already have.

            diff -r 52bfa939fc07 src/auto/configure
            --- a/src/auto/configure Thu Dec 06 21:30:29 2012 +0100
            +++ b/src/auto/configure Sun Dec 16 14:37:19 2012 -0800
            @@ -4927,7 +4927,8 @@
             
               if test "X$vi_cv_path_mzscheme_pfx" != "X"; then
                 if test "x$MACOSX" = "xyes"; then
            -      MZSCHEME_LIBS="-framework PLT_MzScheme"
            +      MZSCHEME_LIBS="-framework Racket"
            +      MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
                 elif test -f "${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"; then
                   MZSCHEME_LIBS="${vi_cv_path_mzscheme_pfx}/lib/libmzscheme3m.a"
                   MZSCHEME_CFLAGS="-DMZ_PRECISE_GC"
            @@ -4968,6 +4969,10 @@
                   else
              if test -d $vi_cv_path_mzscheme_pfx/share/racket/collects; then
               SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/share/racket/
            +        else
            +  if test -d $vi_cv_path_mzscheme_pfx/collects; then
            +    SCHEME_COLLECTS=$vi_cv_path_mzscheme_pfx/
            +  fi
              fi
                   fi
                 fi
            diff -r 52bfa939fc07 src/if_mzsch.c
            --- a/src/if_mzsch.c Thu Dec 06 21:30:29 2012 +0100
            +++ b/src/if_mzsch.c Sun Dec 16 14:37:19 2012 -0800
            @@ -183,6 +183,8 @@
             }
             static int buffer_fixup_proc(void *obj)
             {
            +    vim_mz_buffer* buf = (vim_mz_buffer*) obj;
            +    buf->buf->b_mzscheme_ref = GC_fixup_self(obj);
                 return buffer_size_proc(obj);
             }
             static int window_size_proc(void *obj UNUSED)
            @@ -195,6 +197,8 @@
             }
             static int window_fixup_proc(void *obj)
             {
            +    vim_mz_window* win = (vim_mz_window*) obj;
            +    win->win->w_mzscheme_ref = GC_fixup_self(obj);
                 return window_size_proc(obj);
             }
             #endif
            @@ -861,6 +865,12 @@
                 scheme_set_stack_base(stack_base, 1);
             #endif
             
            +#ifndef TRAMPOLINED_MZVIM_STARTUP
            +    /* in newer versions of precise GC the initial env has been created */
            +    environment = scheme_basic_env();
            +#endif
            +    MZ_GC_CHECK();
            +
                 MZ_REGISTER_STATIC(environment);
                 MZ_REGISTER_STATIC(curout);
                 MZ_REGISTER_STATIC(curerr);
            @@ -869,10 +879,6 @@
                 MZ_REGISTER_STATIC(exn_message);
                 MZ_REGISTER_STATIC(vim_exn);
             
            -#ifndef TRAMPOLINED_MZVIM_STARTUP
            -    /* in newer versions of precise GC the initial env has been created */
            -    environment = scheme_basic_env();
            -#endif
                 MZ_GC_CHECK();
             
             #ifdef INCLUDE_MZSCHEME_BASE
            @@ -925,11 +931,7 @@
              MZ_GC_CHECK();
              coll_path = scheme_char_string_to_path(coll_char_string);
              MZ_GC_CHECK();
            - coll_pair = scheme_make_pair(coll_path, scheme_null);
            - MZ_GC_CHECK();
            - config = scheme_config;
            - MZ_GC_CHECK();
            - scheme_set_param(config, MZCONFIG_COLLECTION_PATHS, coll_pair);
            +        scheme_set_collects_path(coll_path);
              MZ_GC_CHECK();
              MZ_GC_UNREG();
                 }
            @@ -1016,10 +1018,10 @@
             #ifdef MZ_PRECISE_GC
                 GC_register_traversers(mz_buffer_type,
                 buffer_size_proc, buffer_mark_proc, buffer_fixup_proc,
            -    TRUE, TRUE);
            +    TRUE, FALSE);
                 GC_register_traversers(mz_window_type,
                 window_size_proc, window_mark_proc, window_fixup_proc,
            -    TRUE, TRUE);
            +    TRUE, FALSE);
             #endif
             
                 make_modules();
            @@ -1652,7 +1654,7 @@
                 if (win->w_mzscheme_ref != NULL)
              return win->w_mzscheme_ref;
             
            -    self = scheme_malloc_fail_ok(scheme_malloc, sizeof(vim_mz_window));
            +    self = scheme_malloc_fail_ok(scheme_malloc_tagged, sizeof(vim_mz_window));
                 vim_memset(self, 0, sizeof(vim_mz_window));
                 scheme_dont_gc_ptr(self); /* because win isn't visible to GC */
                 MZ_GC_CHECK();
            @@ -1977,7 +1979,7 @@
                 if (buf->b_mzscheme_ref)
              return buf->b_mzscheme_ref;
             
            -    self = scheme_malloc_fail_ok(scheme_malloc, sizeof(vim_mz_buffer));
            +    self = scheme_malloc_fail_ok(scheme_malloc_tagged, sizeof(vim_mz_buffer));
                 vim_memset(self, 0, sizeof(vim_mz_buffer));
                 scheme_dont_gc_ptr(self); /* because buf isn't visible to GC */
                 MZ_GC_CHECK();
            @@ -2298,8 +2300,8 @@
                 MZ_GC_VAR_IN_REG(1, rest);
                 MZ_GC_REG();
             
            -    array = (char **)alloc(new_len * sizeof(char *));
            -    vim_memset(array, 0, new_len * sizeof(char *));
            +    array = (char **)alloc((new_len + 1) * sizeof(char *));
            +    vim_memset(array, 0, (new_len + 1) * sizeof(char *));
             
                 rest = line_list;
                 for (i = 0; i < new_len; ++i)
            @@ -2481,8 +2483,8 @@
              MZ_GC_VAR_IN_REG(1, rest);
              MZ_GC_REG();
             
            - array = (char **)alloc(size * sizeof(char *));
            - vim_memset(array, 0, size * sizeof(char *));
            + array = (char **)alloc((size + 1) * sizeof(char *));
            + vim_memset(array, 0, (size + 1) * sizeof(char *));
             
              rest = list;
              for (i = 0; i < size; ++i)



            On Fri, Dec 14, 2012 at 9:05 AM, Sergey Khorev <sergey.khorev@...> wrote:

            On Fri, Dec 14, 2012 at 9:20 AM, Eric Dobson <eric.n.dobson@...> wrote:
            I figured this out. It was that vim was not being compiled with the precise garbage collection when racket was, and a couple of bugs on the vim allocation of racket objects. I'll hopefully have a patch soon.
             

            Are you talking about official Vim source? For http://code.google.com/r/sergeykhorev-vim-mzscheme/source I reworked some memory allocation stuff so something must have changed in this regard :) 

            _________________________
              Racket Developers list:
              http://lists.racket-lang.org/dev


            --
            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
            Looks good except one thing: you really wouldn t want to gc environment (see MZ_GC_CHECK) before registering it with MZ_REGISTER_STATIC. BTW are there any
            Message 5 of 8 , Dec 16, 2012
            • 0 Attachment
              Looks good except one thing: you really wouldn't want to gc environment (see MZ_GC_CHECK) before registering  it with MZ_REGISTER_STATIC.

              BTW are there any guarantees that MZ_REGISTER_STATIC doesn't trigger garbage collection?

              @@ -861,6 +865,12 @@
                   scheme_set_stack_base(stack_base, 1);
               #endif
               
              +#ifndef TRAMPOLINED_MZVIM_STARTUP
              +    /* in newer versions of precise GC the initial env has been created */
              +    environment = scheme_basic_env();
              +#endif
              +    MZ_GC_CHECK();
              +
                   MZ_REGISTER_STATIC(environment);
                   MZ_REGISTER_STATIC(curout);
                   MZ_REGISTER_STATIC(curerr);
              @@ -869,10 +879,6 @@
                   MZ_REGISTER_STATIC(exn_message);
                   MZ_REGISTER_STATIC(vim_exn);
               
              -#ifndef TRAMPOLINED_MZVIM_STARTUP
              -    /* in newer versions of precise GC the initial env has been created */
              -    environment = scheme_basic_env();
              -#endif
                   MZ_GC_CHECK();
               

              --
              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
              ... Please let me know what I should include in the distribution. The patch was missing changes to configure.in. -- Very funny, Scotty. Now beam down my
              Message 6 of 8 , Dec 17, 2012
              • 0 Attachment
                Sergey Khorev wrote:

                > Looks good except one thing: you really wouldn't want to gc environment
                > (see MZ_GC_CHECK) before registering it with MZ_REGISTER_STATIC.
                >
                > BTW are there any guarantees that MZ_REGISTER_STATIC doesn't trigger
                > garbage collection?

                Please let me know what I should include in the distribution. The patch
                was missing changes to configure.in.


                --
                Very funny, Scotty. Now beam down my clothes.

                /// 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
                Eric, I incorporated you changes into http://code.google.com/r/sergeykhorev-vim-mzscheme/source. Can you try it on Mac? Bram, ... I will send you a cumulative
                Message 7 of 8 , Dec 17, 2012
                • 0 Attachment
                  Eric,

                  I incorporated you changes into http://code.google.com/r/sergeykhorev-vim-mzscheme/source. Can you try it on Mac?

                  Bram,

                  Please let me know what I should include in the distribution.  The patch
                  was missing changes to configure.in.

                   I will send you a cumulative patch once it is tested.

                  --
                  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.