Closed murdegern closed 4 years ago
Hi @murdegern, thanks for the report!
I looked into this today - would you mind grabbing what's on the fix-boolean-frees branch and verifying that that fixes the problem for you? If it does, I can push a new release.
I'll look into it today. Thank you!
Looks very good!
Mh, I'm hitting more internal problems now: "Bizarre copy of ARRAY in subroutine exit at (eval 7274) line 8."
This is when we test our lua libs from perl, awfully dynamic stuff. If you have an idea immediately, that'd be great, otherwise I'll try to reduce it to a failing snippet - I couldn't yet.
It still looks like something's being reused, because I need to do two nearly identical calls after another for the bug to appear.
Regards, Torsten
Oh, I found another one. Try this:
#!/cs/re/2020-10-perl5.24-64-Apache2_pg9.6_rh6/bin/perl
use strict;
use warnings;
use Inline Lua => <<EOF;
function ouch()
return true
end
EOF
use Data::Dumper;
my $dung = ouch();
print Dumper($dung);
$dung = ouch();
It gives me the "attempt to copy freed scalar" message again, even with your fixed branch.
@murdegern Ok, thanks for the additional digging! I am able to reproduce that second example - I don't know if I'll be able to look at it today, but I'll see what I can do. I also managed to reproduce the "Bizzare copy of ARRAY" thing, so I'll dig into that as well.
@murdegern Ok, I fixed that example and my own example with the "bizarre copy" thing - could you try out the latest commit on that branch? I think there are probably other memory issues lurking around here, but I'd like to see if my change results in progress on your end.
I'm on it, will take some time though. Thank you for looking into it!
@hoelzro Now I only have one case of "bizarre ARRAY copy" left. I'll make a brief version of the test tomorrow.
@hoelzro It seems to be complicated. The one test which is still failing with our (huge) application does some contrived stuff like calling into perl objects from lua. It does not always fail in the same way; I saw "bizarre HASH copy", segfault, wrong return values and sometimes even success when running the test.
I hope I can get myself some time for working on this; it has now been revalued as lower priority 🙄
@hoelzro Ok, used a boring meeting ... the following snippet shows a few "Attempt to free unreferenced scalar" errors (usually around 4):
use strict;
use warnings;
my ($lua, $retval);
use Inline Lua => <<EOLUA;
function _lua_run (_lua_code)
local func, error_message = loadstring(_lua_code)
local status, return_value = pcall(func)
return return_value
end
EOLUA
for( my $i=0; $i<10; ++$i ) {
$lua = <<'EOT';
local status, val = pcall(function () return 1/1 end)
return { status, val }
EOT
$retval = _lua_run($lua);
$lua = <<'EOT';
local status, val = pcall(function () error("my error") end)
return { status, val }
EOT
$retval = _lua_run($lua);
}
What is really funny: if you remove one of the _lua_run calls (doesn't matter which one), it works.
@murdegern Thanks for the additional information - I don't know when I'll be able to take a deeper look, but I'll try by the end of the weekend!
@murdegern I spent some time with this today, and pushed my latest work to the fix-boolean-frees-take-2
branch - could you give that a try?
I will. I'm on a 3 day vacation, but I can probably start a new runtime build in the evening and let the tests run tomorrow.
@murdegern Sounds good, enjoy your vacation!
Tests are running, and it looks very good so far! No errors with perl 5.24 nor 5.14. I'll keep on hammering our test systems, but I think you've nailed it.
Excellent! If things still look good by the weekend I'll make a new release.
At least our tests run fine now, with different perl versions.
@murdegern I just published version 0.17 with the fix - if that works for you, I'll close this issue. Thanks again for the report and helping to test!
Fixed by @hoelzro in version 0.17
Hi,
it would be great if you could help me with this problem below.
We are currently working on using a current version of perl (currently 5.14) and, trying out 5.24 with Lua 5.1.5, Inline 0.80 and Inline::Lua 0.16 I hit the following problem:
This will print
The same happens with perl 5.32. The same does NOT happen if I return 1, or { 1, 2, 3 }, or "abc". Only booleans seem to be affected.
I fumbled around with a few other versions, e.g. Lua 5.3.5 + perl 5.30 + Inline 0.86, Inline::Lua 0.16, and the same problem appears.
Any help is greatly appreciated. Regards, Torsten