Re: [racket-dev] Embedding racket in vim

2012-12-17 Thread Sergey Khorev
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.
_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] Embedding racket in vim

2012-12-16 Thread 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
--- 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.kho...@gmail.comwrote:


 On Fri, Dec 14, 2012 at 9:20 AM, Eric Dobson eric.n.dob...@gmail.comwrote:

 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 :)

 _
  

Re: [racket-dev] Embedding racket in vim

2012-12-16 Thread 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 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();



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


Re: [racket-dev] Embedding racket in vim

2012-12-14 Thread Sergey Khorev
On Fri, Dec 14, 2012 at 9:20 AM, Eric Dobson eric.n.dob...@gmail.comwrote:

 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


Re: [racket-dev] Embedding racket in vim

2012-12-13 Thread 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 racket objects. I'll hopefully have a patch soon.


On Mon, Dec 10, 2012 at 10:32 PM, Eric Dobson eric.n.dob...@gmail.comwrote:

 +correct vim group.



 On Mon, Dec 10, 2012 at 10:25 PM, Eric Dobson eric.n.dob...@gmail.comwrote:

 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: 0x00a0
 0x000100328d99 in scheme_top_level_do_worker (dyn_state=0x0,
 k=0x7fff5fbfdd10, eb=1000, new_thread=1606409488) at fun.c:1227
 1227scheme_longjmp(*save, 1);
 (gdb) bt
 #0  0x000100328d99 in scheme_top_level_do_worker (dyn_state=0x0,
 k=0x7fff5fbfdd10, eb=1000, new_thread=1606409488) at fun.c:1227
 #1  0x0001003ff41e in _module_resolve (modidx=0x103004150,
 stx=0x103004068, env=0x0, load_it=1) at module.c:3860
 #2  0x00010041162a in parse_requires () at schthread.h:376
 #3  0x0001004122e4 in do_namespace_require () at module.c:7685
 #4  0x0001004123ce in scheme_namespace_require (r=0x103ec8008) at
 module.c:1316
 #5  0x0001001574dd in _mh_execute_header ()
 #6  0x0001001585d8 in _mh_execute_header ()
 #7  0x00010005bc43 in _mh_execute_header ()
 #8  0x00010004ca4a in _mh_execute_header ()
 #9  0x00010015f608 in _mh_execute_header ()
 #10 0x0001002a6093 in call_with_basic (data=0x103ec8008) at
 schthread.h:376
 #11 0x0001002a64a8 in scheme_main_setup (no_auto_statics=1606414024,
 _main=0x7fff5fbfe268, argc=6433496, argv=0x7fff5fbfe240) at salloc.c:194
 #12 0x000100161fff in _mh_execute_header ()
 #13 0x7fff939eb7e1 in start ()
 (gdb)

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



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


[racket-dev] Embedding racket in vim

2012-12-10 Thread Eric Dobson
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: 0x00a0
0x000100328d99 in scheme_top_level_do_worker (dyn_state=0x0,
k=0x7fff5fbfdd10, eb=1000, new_thread=1606409488) at fun.c:1227
1227scheme_longjmp(*save, 1);
(gdb) bt
#0  0x000100328d99 in scheme_top_level_do_worker (dyn_state=0x0,
k=0x7fff5fbfdd10, eb=1000, new_thread=1606409488) at fun.c:1227
#1  0x0001003ff41e in _module_resolve (modidx=0x103004150,
stx=0x103004068, env=0x0, load_it=1) at module.c:3860
#2  0x00010041162a in parse_requires () at schthread.h:376
#3  0x0001004122e4 in do_namespace_require () at module.c:7685
#4  0x0001004123ce in scheme_namespace_require (r=0x103ec8008) at
module.c:1316
#5  0x0001001574dd in _mh_execute_header ()
#6  0x0001001585d8 in _mh_execute_header ()
#7  0x00010005bc43 in _mh_execute_header ()
#8  0x00010004ca4a in _mh_execute_header ()
#9  0x00010015f608 in _mh_execute_header ()
#10 0x0001002a6093 in call_with_basic (data=0x103ec8008) at
schthread.h:376
#11 0x0001002a64a8 in scheme_main_setup (no_auto_statics=1606414024,
_main=0x7fff5fbfe268, argc=6433496, argv=0x7fff5fbfe240) at salloc.c:194
#12 0x000100161fff in _mh_execute_header ()
#13 0x7fff939eb7e1 in start ()
(gdb)

I can include more information if you can tell me what is useful.
_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] Embedding racket in vim

2012-12-10 Thread Eric Dobson
+correct vim group.


On Mon, Dec 10, 2012 at 10:25 PM, Eric Dobson eric.n.dob...@gmail.comwrote:

 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: 0x00a0
 0x000100328d99 in scheme_top_level_do_worker (dyn_state=0x0,
 k=0x7fff5fbfdd10, eb=1000, new_thread=1606409488) at fun.c:1227
 1227scheme_longjmp(*save, 1);
 (gdb) bt
 #0  0x000100328d99 in scheme_top_level_do_worker (dyn_state=0x0,
 k=0x7fff5fbfdd10, eb=1000, new_thread=1606409488) at fun.c:1227
 #1  0x0001003ff41e in _module_resolve (modidx=0x103004150,
 stx=0x103004068, env=0x0, load_it=1) at module.c:3860
 #2  0x00010041162a in parse_requires () at schthread.h:376
 #3  0x0001004122e4 in do_namespace_require () at module.c:7685
 #4  0x0001004123ce in scheme_namespace_require (r=0x103ec8008) at
 module.c:1316
 #5  0x0001001574dd in _mh_execute_header ()
 #6  0x0001001585d8 in _mh_execute_header ()
 #7  0x00010005bc43 in _mh_execute_header ()
 #8  0x00010004ca4a in _mh_execute_header ()
 #9  0x00010015f608 in _mh_execute_header ()
 #10 0x0001002a6093 in call_with_basic (data=0x103ec8008) at
 schthread.h:376
 #11 0x0001002a64a8 in scheme_main_setup (no_auto_statics=1606414024,
 _main=0x7fff5fbfe268, argc=6433496, argv=0x7fff5fbfe240) at salloc.c:194
 #12 0x000100161fff in _mh_execute_header ()
 #13 0x7fff939eb7e1 in start ()
 (gdb)

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

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