[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
dangling pointer bug and proposed patch
From: |
john |
Subject: |
dangling pointer bug and proposed patch |
Date: |
Wed, 18 Jan 2006 21:37:55 -0500 |
Hello,
There is a dangling pointer bug in GNU m4, exposed by this example:
$ m4 -dqeat
define(`f',`one')f(undefine(`f')`two')
m4trace: -1- define(`f', `one')
m4trace: -2- undefine(`f')
m4trace: -1- øò·øò·(`two') -> `øò·øò·H'
øò·øò·H
The problem is that undefining a macro while it is in the "collect
arguments" phase leaves a dangling symbol pointer on the stack. Bug
aside, the GNU m4 info file doesn't seem to specify what *should*
happen in this situation. I propose that when a macro whose arguments
have just been expanded discovers that its pre-argument-expansion
definition has been deleted, it should use the "current" definition
(i.e. the same definition a new invocation of the macro would use).
If no current definition exists, the macro should use the expansion
$0($@), which treats the macro as effectively undefined, except that
leading whitespace is stripped from the arguments.
I've written up the gory details (mostly to help me make sure I
understand them), including justification of the proposed behaviour,
in the attached PDF.
A patch for the proposed fix against m4-1.4.4 is also attached.
(The branch name m4-1.4.4.1 is just for my own convenience.)
Regards,
John B.
--
John Brzustowski - http://www.ProgramOrPerish.com
m4bug.pdf
Description: m4bug.pdf
m4_1.4.4-1.diff.gz
Description: Binary data
- dangling pointer bug and proposed patch,
john <=