Projet

Général

Profil

Development #35061

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

Ajouté par Maxime Besson il y a plus de 4 ans. Mis à jour il y a plus de 4 ans.

Statut:
Fermé
Priorité:
Normal
Assigné à:
Catégorie:
Binding perl
Version cible:
Début:
25 juillet 2019
Echéance:
% réalisé:

100%

Temps estimé:
Patch proposed:
Oui
Planning:
Non

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.


Fichiers

issue-35061.zip (5,95 ko) issue-35061.zip Maxime Besson, 06 août 2019 16:06
0001-Fix-reference-count-in-lasso_server_add_provider2-fi.patch (3,85 ko) 0001-Fix-reference-count-in-lasso_server_add_provider2-fi.patch Benjamin Dauvergne, 03 septembre 2019 13:42

Révisions associées

Révision 6c852f8c (diff)
Ajouté par Benjamin Dauvergne il y a plus de 4 ans

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.

Historique

#1

Mis à jour par Benjamin Dauvergne il y a plus de 4 ans

  • Statut changé de Nouveau à 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

Mis à jour par Maxime Besson il y a plus de 4 ans

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

Mis à jour par Benjamin Dauvergne il y a plus de 4 ans

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

Mis à jour par Maxime Besson il y a plus de 4 ans

No more warning from perl, thanks for fixing this!

#5

Mis à jour par Benjamin Dauvergne il y a plus de 4 ans

  • Statut changé de Solution proposée à 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

Mis à jour par Benjamin Dauvergne il y a plus de 4 ans

  • % réalisé changé de 0 à 100
#7

Mis à jour par Benjamin Dauvergne il y a plus de 4 ans

  • Version cible mis à 2.6.1
#8

Mis à jour par Benjamin Dauvergne il y a plus de 4 ans

  • Statut changé de Résolu (à déployer) à Solution déployée

Formats disponibles : Atom PDF