Project

General

Profile

Development #35061

perl "Attempt to free unreferenced scalar" warning when using lasso_server_add_provider2

Added by Maxime Besson about 1 year ago. Updated 11 months ago.

Status:
Solution déployée
Priority:
Normal
Category:
Binding perl
Target version:
Start date:
25 Jul 2019
Due date:
% Done:

100%

Patch proposed:
Yes
Planning:
No

Description

My application is currently doing something like this to load multiple SP metadatas into an IDP server:

use Lasso;
my $server = new Lasso::Server("metadata.xml", "private-key.pem");

# for each provider I want to load
$server->add_provider_from_buffer(Lasso::Constants::PROVIDER_ROLE_SP, "sp.xml");

This has been working fine for years now. However, I would like to extract the entityID of each provider as I load it into the server. For logging purposes among other things.

I would like to avoid parsing the XML metadata a second time to extract the entityID field. After reading the API docs, it seems like the following approach should work:

use Lasso;
my $server = new Lasso::Server("metadata.xml", "private-key.pem");

# For each provider I want to load:
my $provider = new Lasso::Provider(Lasso::Constants::PROVIDER_ROLE_SP,"sp.xml");
my $entityID=$provider->ProviderID;
# Do something interesting with $entityID....
$server->add_provider2($provider);

However, running this particular perl script yields the following, and rather scary warning:

Attempt to free unreferenced scalar: SV 0x5618e45d2f48, Perl interpreter: 0x5618e45d0010 at test.pl line 10.

Tested with PERL v5.24.1 and v5.28.1 (debian stretch and buster), using Lasso's git master branch, metadata files used in my script come from the Lasso test suite, any metadata file I try yields the same result.

Am I doing something wrong here? This seems like a reference counting issue when registering the provider. Is there another way I could extract the entityID from a metadatafile before registering it into the server that I haven't found?

Thanks for your help.

issue-35061.zip (5.95 KB) Maxime Besson, 06 Aug 2019 04:06 PM

0001-Fix-reference-count-in-lasso_server_add_provider2-fi.patch View (3.85 KB) Benjamin Dauvergne, 03 Sep 2019 01:42 PM

Associated revisions

Revision 6c852f8c (diff)
Added by Benjamin Dauvergne 11 months ago

Fix reference count in lasso_server_add_provider2 (fixes #35061)

As implemented lasso_server_add_provider2 could not be used as a publik
API as it dit not increase the reference count of the LassoProvider
object before adding it to the providers hashtable.

lasso_server_add_provider_helper had to be modified to decrement the
reference count of the new LassoProvider object after using
lasso_server_add_provider2.

History

#1 Updated by Benjamin Dauvergne about 1 year ago

  • Status changed from Nouveau to Information nécessaire

I'm not able to reproduce the trace on buster with your example code, could you provide a working script with accompanying data files ?

#2 Updated by Maxime Besson about 1 year ago

You'll find a more complete test in the attached zip. All data files come from the test Lasso test suite.

I discovered that in some cases, instead of a perl warning I get a GObject warning, you should see it while running fail2.pl

#3 Updated by Benjamin Dauvergne 11 months ago

I found the problem, lasso_provider_add_provider2 was just never tested as a public API on our side, as we always use lasso_server_add_provider/_from_buffer.

#4 Updated by Maxime Besson 11 months ago

No more warning from perl, thanks for fixing this!

#5 Updated by Benjamin Dauvergne 11 months ago

  • Status changed from Solution proposée to Résolu (à déployer)
commit 6c852f8c0bdca7cc85dd1edbdb939887bd35ffe3
Author: Benjamin Dauvergne <bdauvergne@entrouvert.com>
Date:   Tue Sep 3 13:39:05 2019 +0200

    Fix reference count in lasso_server_add_provider2 (fixes #35061)

    As implemented lasso_server_add_provider2 could not be used as a publik
    API as it dit not increase the reference count of the LassoProvider
    object before adding it to the providers hashtable.

    lasso_server_add_provider_helper had to be modified to decrement the
    reference count of the new LassoProvider object after using
    lasso_server_add_provider2.

#6 Updated by Benjamin Dauvergne 11 months ago

  • % Done changed from 0 to 100

#7 Updated by Benjamin Dauvergne 11 months ago

  • Target version set to 2.6.1

#8 Updated by Benjamin Dauvergne 11 months ago

  • Status changed from Résolu (à déployer) to Solution déployée

Also available in: Atom PDF