Development #35061
perl "Attempt to free unreferenced scalar" warning when using lasso_server_add_provider2
100%
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
Révisions associées
Historique
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 ?
Mis à jour par Maxime Besson il y a plus de 4 ans
- Fichier issue-35061.zip issue-35061.zip ajouté
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
Mis à jour par Benjamin Dauvergne il y a plus de 4 ans
- Fichier 0001-Fix-reference-count-in-lasso_server_add_provider2-fi.patch 0001-Fix-reference-count-in-lasso_server_add_provider2-fi.patch ajouté
- Tracker changé de Support à Development
- Statut changé de Information nécessaire à Solution proposée
- Patch proposed changé de Non à Oui
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.
Mis à jour par Maxime Besson il y a plus de 4 ans
No more warning from perl, thanks for fixing this!
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.
Mis à jour par Benjamin Dauvergne il y a plus de 4 ans
- % réalisé changé de 0 à 100
Appliqué par commit 6c852f8c0bdca7cc85dd1edbdb939887bd35ffe3.
Mis à jour par Benjamin Dauvergne il y a plus de 4 ans
- Statut changé de Résolu (à déployer) à Solution déployée
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.