Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

With GSI auth, free Entity variable before replacing it from the cache #347

Merged
merged 1 commit into from
Mar 23, 2016
Merged

With GSI auth, free Entity variable before replacing it from the cache #347

merged 1 commit into from
Mar 23, 2016

Conversation

jthiltges
Copy link
Contributor

We recently enabled GSI authentication with xrootd 4.2.3. It appears each GSI authentication causes about 6kB of memory to be leaked.

Toward the beginning of XrdSecProtocolgsi::Authenticate(), memory may be
allocated for the Entity with strdup():
https://github.com/xrootd/xrootd/blob/a76eccc1f2/src/XrdSecgsi/XrdSecProtocolgsi.cc#L1873

Later in the same function, the Entity may be replaced with an entry from the
cache:
https://github.com/xrootd/xrootd/blob/a76eccc1f2/src/XrdSecgsi/XrdSecProtocolgsi.cc#L1951

However, the memory allocated with strdup() is not free()d. This patch calls FreeEntity()
before replacing Entity with a copy from the cache.

Regards,
John

valgrind output for the largest lost block after 20 GSI authentications (xrootd 4.2.3):

==10420== 120,760 bytes in 20 blocks are definitely lost in loss record 2,541 of 2,543
==10420==    at 0x4A06A2E: malloc (vg_replace_malloc.c:270)
==10420==    by 0x324EE80EC1: strdup (in /lib64/libc-2.12.so)
==10420==    by 0x66E717F: XrdSecProtocolgsi::Authenticate(XrdSecBuffer*, XrdSecBuffer**, XrdOucErrInfo*) (XrdSecProtocolgsi.cc:1873)
==10420==    by 0x4C67959: XrdXrootdProtocol::do_Auth() (XrdXrootdXeq.cc:155)
==10420==    by 0x4F37148: XrdLink::DoIt() (XrdLink.cc:397)
==10420==    by 0x4F3A624: XrdScheduler::Run() (XrdScheduler.cc:333)
==10420==    by 0x4F3A818: XrdStartWorking(void*) (XrdScheduler.cc:85)
==10420==    by 0x4EFF3AE: XrdSysThread_Xeq (XrdSysPthread.cc:86)
==10420==    by 0x324F607AA0: start_thread (in /lib64/libpthread-2.12.so)
==10420==    by 0x324EEE893C: clone (in /lib64/libc-2.12.so)

Toward the beginning of XrdSecProtocolgsi::Authenticate(), memory may be
allocated for the Entity with strdup():
https://github.com/xrootd/xrootd/blob/a76eccc1f2/src/XrdSecgsi/XrdSecProtocolgsi.cc#L1873

Later in the same function, the Entity may be replaced with an entry from the
cache:
https://github.com/xrootd/xrootd/blob/a76eccc1f2/src/XrdSecgsi/XrdSecProtocolgsi.cc#L1951

However, the memory allocated with strdup() is not free()d. Call FreeEntity()
before replacing Entity with a copy.
@gganis gganis merged commit b711436 into xrootd:master Mar 23, 2016
@gganis
Copy link
Member

gganis commented Mar 23, 2016

Dear John,
Thanks for reporting and providing a patch.
I have just merged your request.

G Ganis

@jthiltges
Copy link
Contributor Author

Dear G Ganis,

Thank you very much for your help.

Best regards,
John

@jthiltges jthiltges deleted the gsi-auth-strdup branch March 23, 2016 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants