On Monday, August 6, 2012 2:29:41 PM UTC-4, Bram Moolenaar wrote:
> Raymond Ko wrote:
> 
> 
> 
> [...]
> 
> 
> 
> > > > Here is where it crashed for me:
> 
> > > > http://i.imgur.com/rkiaz.png
> 
> > > 
> 
> > > Thanks, that is very useful.
> 
> > > 
> 
> > > > Searching for the "length" variable, I do not see it initialized
> 
> > > > anywhere prior to use by SvPV(). Maybe this is triggering an out of
> 
> > > > bound read/write somewhere?
> 
> > > 
> 
> > > "length" is set by the macro.  Searching a bit suggested that PL_errgv
> 
> > > might be NULL.  And indeed, skipping the SvPV macro when PL_errgv is
> 
> > > NULL solves the crash.
> 
> > > 
> 
> > > However, it appears errors in perl_eval_sv() are now not reported, thus
> 
> > > it's a workaround, not a solution.
> 
> > > 
> 
> > > Perhaps there is a mismatch in the installed Perl version and the Vim
> 
> > > compilation?
> 
> > 
> 
> > Although I am not an expert at Perl bindings by any means, I just
> 
> > noticed this interesting fact: Compiling with the latest MinGW from
> 
> > http://sourceforge.net/projects/mingwbuilds/files/windows-host/
> 
> > (i686-mingw-w64-gcc-4.7.1-release-c,c++,fortran-sjlj-rev2.7z) does not
> 
> > make Perl bindings crash (tested with :perl VIM::Msg("hello")).
> 
> >
> 
> > If the dependencies of executables produced by MinGW is similar to
> 
> > MSVC 2008 Express, then it might be a possible option to produce
> 
> > official Windows binaries with MinGW instead. The Make_ming.mak file
> 
> > should be tweaked to use "-O2 -flto -fwhole-program" as optimization
> 
> > flags (-O3 produced a miscompiled VIM binary that crashes).
> 
> 
> 
> I have had problems with MingW in the past.  I prefer to build with
> 
> MSVC.  Sticking with one compiler usually works best, other compilers
> 
> have other problems...
> 
> 
> 
> > The only tradeoff of using MinGW, at least in my experience, is that
> 
> > you can't use the JIT Debugging as mentioned in my previous post,
> 
> > making post-mortem debugging and stacktraces impossible, and that
> 
> > there is no profiling tools available for MinGW like in MSVC. This
> 
> > shouldn't really affect end users though. In fact, if you want to use
> 
> > the Command-T plugin for VIM on Windows, you have to use MinGW as it
> 
> > has a C extension for the Ruby bindings. My guess is that Ruby C
> 
> > bindings are in C99, which MSVC does not support, and as a result it
> 
> > does not compile. Of course this assumes you are using Ruby from
> 
> > http://rubyinstaller.org/ which includes a DevKit to allow you compile
> 
> > C extensions.
> 
> > 
> 
> > Based on some random googling, the whole issue seems to be related to
> 
> > this bug, which is supposedly fixed?:
> 
> > https://rt.perl.org/rt3/Public/Bug/Display.html?id=20772
> 
> 
> 
> If it is already fixed, then in what version?  And where is it broken?
> 
> I did install the latest version of Perl.  I prefer the Vim code to work
> 
> with most Perl versions anyway.
> 
> 
> 
> -- 
> 
> hundred-and-one symptoms of being an internet addict:
> 
> 216. Your pet rock leaves home.
> 
> 
> 
>  /// Bram Moolenaar -- [email protected] -- 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    ///

After some careful re-reading, I might have been too hasty in posting that 
link. It was for Perl 5.6 and Linux. Just thought it might be relevant since it 
seems to use the same way to retrieve errors.

A more relevant post I found is this:
http://sourceforge.net/mailarchive/forum.php?thread_name=20111121203748.GA2514%40whitehatsec.com&forum_name=swig-devel
, which seems to exactly describe this problem. And indeed, using ActiveState 
Perl 5.12 works for print "hello" without crashing and can report errors. From 
the comments in the post, they offer a workaround, which I have based the 
following patch on. It is somewhat ugly as I had to use the preprocessor to 
check for MS VC is being used (since MinGW doesn't need fixing). I am not sure 
if the error messages obtained differ from PL_errgv method, although through my 
one test, they appear to be the same.

IMO, I think this stems from ActiveState's choice to use the woefully outdated 
VC6 to compile Perl to ensure maximum compatibility on all Windows systems. 
Using VC6 links to the VC6 runtime (msvcrt.dll). Since we are using newer 
versions of MSVC, it is using different version of the C++ Runtime Library, 
which might be causing conflicts. It is that or some other ABI incompatibility 
I think.

I also tried using Strawberry Perl, although that wouldn't compile.

Based of all this I think the following options are:
1. Use ActiveState Perl 5.12 and say that is the official version of Windows 
binaries.
2. Use the patch and just fix it for MS VC and Perl >= 5.14
3. Use a variant of the patch and always use perl_get_sv(). I don't know if 
this is available or equivalent in older versions, or what the ramifications 
are.
4. Find a Windows Perl maintainer to investigate the root cause and recommended 
fix, as none of this stuff is my forte.

-- 
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
diff -r 8f65fe01b3fa src/if_perl.xs
--- a/src/if_perl.xs	Fri Aug 03 09:50:50 2012 -0400
+++ b/src/if_perl.xs	Mon Aug 06 21:35:56 2012 -0400
@@ -796,7 +796,11 @@
 
     SvREFCNT_dec(sv);
 
+#if (PERL_REVISION == 5) && (PERL_VERSION >= 14) && defined(_MSC_VER)
+    err = SvPV(perl_get_sv("@", GV_ADD), length);
+#else
     err = SvPV(GvSV(PL_errgv), length);
+#endif
 
     FREETMPS;
     LEAVE;
@@ -866,7 +870,11 @@
     sv_catpvn(sv, "}", 1);
     perl_eval_sv(sv, G_DISCARD | G_NOARGS);
     SvREFCNT_dec(sv);
+#if (PERL_REVISION == 5) && (PERL_VERSION >= 14) && defined(_MSC_VER)
+    str = SvPV(perl_get_sv("@", GV_ADD), length);
+#else
     str = SvPV(GvSV(PL_errgv), length);
+#endif
     if (length)
 	goto err;
 
@@ -880,7 +888,11 @@
 	sv_setpv(GvSV(PL_defgv), (char *)ml_get(i));
 	PUSHMARK(sp);
 	perl_call_pv("VIM::perldo", G_SCALAR | G_EVAL);
+#if (PERL_REVISION == 5) && (PERL_VERSION >= 14) && defined(_MSC_VER)
+	str = SvPV(perl_get_sv("@", GV_ADD), length);
+#else
 	str = SvPV(GvSV(PL_errgv), length);
+#endif
 	if (length)
 	    break;
 	SPAGAIN;

Raspunde prin e-mail lui