[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] perl swig bindings failure in svn 1.1.0

From: J Robert Ray <jrray_at_imageworks.com>
Date: 2004-10-07 22:42:10 CEST

Ben Reser wrote:
> On Wed, Oct 06, 2004 at 07:41:43PM -0700, J Robert Ray wrote:
>
>>Hello,
>>
>>I had a problem building and using the perl swig bindings that ship with
>>subversion 1.1.0. I am using perl 5.8.0.
>>
>>Sample error message:
>>Modification of a read-only value attempted at
>>subversion-1.1.0/subversion/bindings/swig/perl/native/Core.pm line 6.
>>Compilation failed in require.
>>BEGIN failed--compilation aborted.
>>
>>In Core.pm, the 'use SVN::Base qw(Core svn_);' line seems to create a
>>$SVN::Core::VERSION variable, set to '1.1.0'. The next line also tries
>>to set this variable and produces the above error.
>>
>>I found the most sensible approach was to comment out the two lines that
>>try to redundantly set the VERSION variable. Patch attached.
>>
>>Another approach that works (but is silly) is to put those two lines in
>>a BEGIN {} block above the 'use SVN::Base qw(Core svn_);' line.
>>
>>Without this patch, the perl binding test suite fails a bunch of times
>>with that same error message above. With the patch, the test suite
>>succeeds and the perl binding do indeed to work fine.
>>
>>I don't know if this problem is happening for everyone or is something
>>specific to my configuration, but I wanted to point it out to the
>>developers.
>
>
> I can't seem to replicate this. Can you provide the output of the
> following commands:

Hi Ben, thanks for the reply.

>
> perl -v
> swig -version

This is perl, v5.8.0 built for i686-linux

SWIG Version 1.3.21
Compiled with /usr/local/gcc32/bin/g++3 [i686-pc-linux-gnu]

>
> The error you got is indicitive of an attempt to change a constant.
> $SVN::Core::VERSION shouldn't be a constant. Though this might be
> related to the addtiion of svn_*_version() functions to the various
> libraries. But Perl has case sensitive namespaces... So VERSION
> shouldn't be mapping to a constant since there is no svn_VERSION.

In core.c, I see a bunch of constants being defined here. e.g.:

{ SWIG_STRING, (char *) SWIG_prefix "SVN_KEYWORD_REVISION_LONG", 0, 0,
(void *)"LastChangedRevision", 0},
...
{ SWIG_STRING, (char *) SWIG_prefix "SVN_VERSION", 0, 0, (void *)"1.1.0
(dev build, r2)", 0},

I can see the values of any of these by stripping off the SVN_ prefix:

> perl -MSVN::Core -le 'print $SVN::Core::KEYWORD_REVISION_LONG'
LastChangedRevision

> perl -MSVN::Core -le 'print $SVN::Core::VERSION'
1.1.0 (dev build, r2)

Looking more closely at Base.pm, line 71 is:

        next unless s/^$prefix//i;

It is doing a case insensitive comparison for the symbol prefix. So
even though SVN::Core passes in 'svn_' as the prefix, it matches all the
SVN_* symbols too. With some debug printouts I see this output:

Looking at 'SVN_VERSION'

Defining 'SVN::Core::VERSION'

For reference:
==========================================================================
--- Base.pm Thu Jul 1 04:07:45 2004
+++ /usr/local/lib/perl5/5.8.0/i686-linux/SVN/Base.pm Thu Oct 7
13:34:23 2004
@@ -67,6 +67,7 @@
      my $caller = caller(0);

      SYMBOL: for (keys %{"SVN::_${pkg}::"}) {
+ print STDERR "Looking at '$_'\n";
         my $name = $_;
         next unless s/^$prefix//i;
      foreach my $ignored_symbol (@ignore) {
@@ -84,6 +85,7 @@
         elsif (m/(.*)_set$/) {
         }
         else {
+ print STDERR "Defining '${caller}::$_'\n";
             *{"${caller}::$_"} = ${"SVN::_${pkg}::"}{$name};
         }
      }
==========================================================================

>
> Also if you could post your subversion/bindings/swig/perl dir that might
> be helpful. It's possible SWIG is generating some weird code on your
> platform.

I've attached all the SWIG generated .c files.

>
> Lastly, looks like this may have been a Perl 5.8.0 bug, though I'm a bit
> suprised we haven't seen it before. I build and test the bindings with
> 5.8.0 on Linux:
> http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=97200
>

It doesn't feel like a perl bug to me, based on what I show above.

Thanks,

- Robert

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Received on Thu Oct 7 22:46:47 2004

This is an archived mail posted to the Subversion Dev mailing list.