Mailinglist Archive: yast-devel (144 mails)

< Previous Next >
[yast-devel] Bug in Ruby code with arg_ref

Hi,

we had a strange bug in yast-storage with the Ruby code for
adding new LVM logical volumes (also see bng #834330).

In ep-lvm-lib.rb the function "EpCreateLogicalVolume" has a local
variable "data". That variable is passed by reference to
"DlgCreateLogicalVolume" in ep-lvm-dialogs.rb along with a
reference to the function "Commit". Commit use "data". So the
code looks roughly like this:

def EpCreateLogicalVolume(device)

data = { ... }

_Commit = lambda do
do something with data
end

data_ref = arg_ref(data);
DlgCreateLogicalVolume(data_ref, fun_ref(_Commit, "symbol ()"))
data = data_ref.value;

end

def DlgCreateLogicalVolume(data, _Commit)

modify data

_Commit.call

end

The problem is that "data" when used in "Commit" has wrong
values; it's neither the original value set in
"EpCreateLogicalVolume" nor the value set in
"DlgCreateLogicalVolume" but some mixture.

It's caused by the fact that "data = data_ref.value" happens
after calling "Commit".

We fixed this by passing "data" to "Commit" explicitely.

ciao Arvin

--
To unsubscribe, e-mail: yast-devel+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: yast-devel+owner@xxxxxxxxxxxx

< Previous Next >
Follow Ups