Bug 8449 - simple use case results in "no talloc stackframe around, leaking memory" error
Summary: simple use case results in "no talloc stackframe around, leaking memory" error
Alias: None
Product: Samba 3.6
Classification: Unclassified
Component: libsmbclient (show other bugs)
Version: 3.6.0
Hardware: x86 Linux
: P5 normal
Target Milestone: ---
Assignee: Karolin Seeger
QA Contact: Samba QA Contact
: 10420 (view as bug list)
Depends on:
Reported: 2011-09-11 10:29 UTC by Mr Temporary
Modified: 2014-07-17 18:32 UTC (History)
4 users (show)

See Also:

Examine, compile and run this tiny program. (444 bytes, text/x-csrc)
2011-09-11 10:29 UTC, Mr Temporary
no flags Details
patch for master to fix this (4.05 KB, patch)
2014-04-01 04:09 UTC, Andrew Bartlett
no flags Details
git-am fix for master. (4.12 KB, patch)
2014-04-01 19:51 UTC, Jeremy Allison
no flags Details
patches cherry-picked from master for 4.1 (15.24 KB, patch)
2014-07-02 11:12 UTC, Andrew Bartlett
obnox: review+
jra: review+

Note You need to log in before you can comment on or make changes to this bug.
Description Mr Temporary 2011-09-11 10:29:20 UTC
Created attachment 6877 [details]
Examine, compile and run this tiny program.

Running a program that creates a context, opens a directory and frees the context results in a "no talloc stackframe around, leaking memory" message being sent to stdout.

Steps to reproduce:

1) Compile the attached program: gcc test.c -lsmbclient -o reprod
2) Run it: ./reprod
3) Observe the error message being printed to stdout.

Be sure that the program is attempting to open a directory that you actually have access to (see line 10). Otherwise the error message is not printed out.
Comment 1 Partha 2013-04-08 07:16:21 UTC
I found a solution to avoid this situation.

In the function where you seeing this error, you need to allocate stack frame using the below way 

TALLOC_CTX *frame = talloc_stackframe();

and before your function exit you need to call


 Some one who knows better on these stack frame call can add here.
Comment 2 Andrew Bartlett 2014-04-01 04:09:40 UTC
Created attachment 9821 [details]
patch for master to fix this

This patch should fix the issue.
Comment 3 Jeremy Allison 2014-04-01 16:51:34 UTC
Andrew, can you reverse the:

errno = XXXX

to be :

errno = XXXXX

as it's possible TALLOC_FREE might set an errno (currently doesn't but it's safer not to assume).

Then I'll push to master and +1 for 4.0.next and 4.1.next.

Thanks !

Comment 4 Jeremy Allison 2014-04-01 19:51:35 UTC
Created attachment 9823 [details]
git-am fix for master.

Decided not to waste your time and did it myself :-).

If you +1 I'll push to master.


Comment 5 Robie Basak 2014-04-25 11:28:43 UTC
This issue (I think) is affecting the just-released Ubuntu 14.04. Downstream bug: https://launchpad.net/bugs/1257186. It seems to me that this is creating noise for us rather than having a more significant impact, but as a consequence we do have a ton of reports.

Though I'm not completely sure. I could not reproduce Mr Temporary's case successfully with 2:4.1.6+dfsg-1ubuntu2 (based on 4.1.6), and Jeremy's patch in comment 4 did not fix my test case (sudo passwd ... with libpam-smbpass enabled) either.

Is my problem a separate issue, or are there additional functions that need to be wrapped in talloc_stackframe()?
Comment 6 Andrew Bartlett 2014-07-02 11:12:45 UTC
Created attachment 10067 [details]
patches cherry-picked from master for 4.1

Attached are the cherry-picked patches for this issue both in libsmbclient and in pam_smbpass (which is what is causing most of the noise).
Comment 7 Andrew Bartlett 2014-07-02 11:14:36 UTC
*** Bug 10420 has been marked as a duplicate of this bug. ***
Comment 8 Jeremy Allison 2014-07-02 19:54:21 UTC
Comment on attachment 10067 [details]
patches cherry-picked from master for 4.1

Comment 9 Jeremy Allison 2014-07-02 20:04:03 UTC
Re-assigning to Karolin for inclusion in 4.0.next.
Comment 10 Karolin Seeger 2014-07-11 07:35:41 UTC
(In reply to comment #9)
> Re-assigning to Karolin for inclusion in 4.0.next.

Pushed to autobuild-v4-1-test.
Jeremy, did you really mean 4.0.next here?
Comment 11 Jeremy Allison 2014-07-11 17:02:07 UTC
No, it was a typo - 4.1.x is fine !
Comment 12 Karolin Seeger 2014-07-17 18:32:25 UTC
Pushed to v4-1-test.
Closing out bug report.