19 Jan 2006 03:37
dangling pointer bug and proposed patch
john <jbrzusto <at> fastmail.fm>
2006-01-19 02:37:55 GMT
2006-01-19 02:37:55 GMT
Hello, There is a dangling pointer bug in GNU m4, exposed by this example: $ m4 -dqeat define(`f',`one')f(undefine(`f')`two') m4trace: -(Continue reading)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($ <at> ), 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,
RSS Feed