bugProgramming from the Ground Up Book - Bugs: bug #19918, factorial doesn't dispose of the...


bug #19918: factorial doesn't dispose of the parameters pushed on the stack after it returns from the resursion

Submitter:  None
Submitted:  Mon 21 May 2007 11:33:31 AM UTC
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup

Sun 21 Oct 2007 05:27:52 PM UTC, comment #1: 

Yes, it does.  Each inner stack frame is destroyed just before the `ret' instruction call as the recursion works its way back out from the base case.

Jonathon <jwdonal>
Mon 21 May 2007 11:33:31 AM UTC, original submission:  

I'm reading version 1.0 of the book. The factorial function in the "Recursive Functions" section of Chapter 4 calls itself to compute the factorial of the number minus one but once the call returns, the pushed value is not disposed of. It's in contrast with what _start does when it calls factorial and the book advice which states that "You should always clean up your stack parameters after a function call returns."



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by jwdonal (Posted a comment)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.


    No changes have been made to this item

    Back to the top

    Powered by Savane 3.13-4b48.
    Corresponding source code