S
Sébastien Cottalorda
Hi all,
I develop an program based on a module names 'SHM' based on
IPC::Shareable module.
I'm under Fedora core 9 (kernel 2.6.27.21-78.2.41.fc9.i686) with
Perl 5.10.0
it works like this:
IPC::Shareable does this when it try to get something in memory
segment:
--------------------------------------------------------------------------
sub FETCH {
[snip]
my $data;
if ($self->{_lock} || $self->{_iterating}) {
$self->{_iterating} = ''; # In case we break out
$data = $self->{_data};
} else {
$data = _thaw($self->{_shm});
$self->{_data} = $data;
}
my $val;
[snip]
# work with $data following $self->{_type} type => then put result
in $val variable
return $val
}
.....
sub _thaw {
[snip]
my $s = shift;
my $ice = $s->shmread;
my $tag = substr $ice, 0, 14, '';
if ($tag eq 'IPC::Shareable') {
my $water = thaw $ice; # imported from Storable module
defined($water) or do {
require Carp;
_debug "Prob into shm segment ", $s->id, ": ", $ice;
Carp::confess "Munged shared memory segment (size
exceeded?) into shm segment ";
};
return $water;
} else {
return;
}
----------------------------------------------------------------------------------
my module, 'SHM', based on IPC::Shareable module does this
sub get_hash {
my $this = shift;
my $type = ref($this) or croak "GET: $this is not an object";
my $hashref = shift;
my %datas = ();
eval {
%datas = %{$this->{_data}}; # line 537 on which I got
Munged share memory .... message
};
if ($@){
croak "GET: Unable to get ".$hashref->{type}."| segment
allKeys : $@";
}
else {
[snip]
}
}
---------------------------------------------------------------------------------------------------------
my program base on the 'SHM' module does this
[snip]
my $memCmd = 'ps axfv | grep -P "^\s{0,}'.$$.'" | grep -v grep ';
print "MEMSize (BEFORE)=". `$memCmd` ;
if ($SEGMENT->shlock(LOCK_SH)){
eval {
$pano_SHM = $SEGMENT->get_hash({ type => 'panneau', primary
=> $control });
};
if ($@){
[snip]
}
print "MEMSize (AFTER)=". `$memCmd` ;
}
else {
print "unable to get a lock on SHM\n";
}
I run several time (5 times), in parallel, the same program.
I have then concurrent access to the memory segment.
On concurrent access, one process get the error :
"Munged shared memory segment (size exceeded?) into shm segment"
I note then that the virtual memory grow till 1,8 Go for the process
on which occured the access problem.
I trace this:
MEMSize (BEFORE)= 5080 pts/7 S+ 17:47 0 3 13776 8992
0.2 \_ PK52
"Munged shared memory segment (size exceeded?) into shm segment" at
SHM line 537
MEMSize (AFTER)= 5080 pts/7 S+ 17:47 0 3 1849624 9832
0.2 \_ PK52
If someone can help me in solving this problem , make me add some
useful trace somewhere, or whatever else .
Thanks in advance.
Sebastien
I develop an program based on a module names 'SHM' based on
IPC::Shareable module.
I'm under Fedora core 9 (kernel 2.6.27.21-78.2.41.fc9.i686) with
Perl 5.10.0
it works like this:
IPC::Shareable does this when it try to get something in memory
segment:
--------------------------------------------------------------------------
sub FETCH {
[snip]
my $data;
if ($self->{_lock} || $self->{_iterating}) {
$self->{_iterating} = ''; # In case we break out
$data = $self->{_data};
} else {
$data = _thaw($self->{_shm});
$self->{_data} = $data;
}
my $val;
[snip]
# work with $data following $self->{_type} type => then put result
in $val variable
return $val
}
.....
sub _thaw {
[snip]
my $s = shift;
my $ice = $s->shmread;
my $tag = substr $ice, 0, 14, '';
if ($tag eq 'IPC::Shareable') {
my $water = thaw $ice; # imported from Storable module
defined($water) or do {
require Carp;
_debug "Prob into shm segment ", $s->id, ": ", $ice;
Carp::confess "Munged shared memory segment (size
exceeded?) into shm segment ";
};
return $water;
} else {
return;
}
----------------------------------------------------------------------------------
my module, 'SHM', based on IPC::Shareable module does this
sub get_hash {
my $this = shift;
my $type = ref($this) or croak "GET: $this is not an object";
my $hashref = shift;
my %datas = ();
eval {
%datas = %{$this->{_data}}; # line 537 on which I got
Munged share memory .... message
};
if ($@){
croak "GET: Unable to get ".$hashref->{type}."| segment
allKeys : $@";
}
else {
[snip]
}
}
---------------------------------------------------------------------------------------------------------
my program base on the 'SHM' module does this
[snip]
my $memCmd = 'ps axfv | grep -P "^\s{0,}'.$$.'" | grep -v grep ';
print "MEMSize (BEFORE)=". `$memCmd` ;
if ($SEGMENT->shlock(LOCK_SH)){
eval {
$pano_SHM = $SEGMENT->get_hash({ type => 'panneau', primary
=> $control });
};
if ($@){
[snip]
}
print "MEMSize (AFTER)=". `$memCmd` ;
}
else {
print "unable to get a lock on SHM\n";
}
I run several time (5 times), in parallel, the same program.
I have then concurrent access to the memory segment.
On concurrent access, one process get the error :
"Munged shared memory segment (size exceeded?) into shm segment"
I note then that the virtual memory grow till 1,8 Go for the process
on which occured the access problem.
I trace this:
MEMSize (BEFORE)= 5080 pts/7 S+ 17:47 0 3 13776 8992
0.2 \_ PK52
"Munged shared memory segment (size exceeded?) into shm segment" at
SHM line 537
MEMSize (AFTER)= 5080 pts/7 S+ 17:47 0 3 1849624 9832
0.2 \_ PK52
If someone can help me in solving this problem , make me add some
useful trace somewhere, or whatever else .
Thanks in advance.
Sebastien