Re: Make m4 only call macros surrounded by brackets.

Zack Piper <[email protected]> Tue, 3 Mar 2015 14:38:55 +0000
Newsgroups gmane.comp.gnu.m4.general
Message-ID <[email protected]>
On Mon, Mar 02, 2015 at 06:53:56AM -0700, Eric Blake wrote:
> On 02/28/2015 04:21 PM, Zack Piper wrote:
> 
> > 
> > Hm, I found out how to do it. Unfortuently it seems to segfault when using "changeword(`#<\([_a-zA-Z0-9]*\)>)')", and then trying to invoke a macro:
> > 
> > (gdb) run gpp.m4
> > Starting program: /usr/local/bin/m4 gpp.m4
> > Got object file from memory but can't read symbols: File truncated.
> > 
> 
> A segfault is never good.  Can you please post the contents of gpp.m4,
> show the exact version of m4 you are testing, and possible provide more
> of the backtrace, so that we can debug what went wrong?
> 
> 
> -- 
> Eric Blake   eblake redhat com    +1-919-301-3266
> Libvirt virtualization library http://libvirt.org
> 

```{shell command="cat gpp.m4"}
define(`test', `hi')
changecom(`/*', `*/')
changeword(`#<\([_a-zA-Z0-9]*\)>')

#<test>
```

```{shell command="/usr/local/bin/m4 gpp.m4 --debug=V"}
m4debug: input read from gpp.m4
m4trace:gpp.m4:1: -1- id 1: define ...
m4trace:gpp.m4:1: -1- id 1: define(`test', `hi') -> ???
m4trace:gpp.m4:1: -1- id 1: define(...)

m4trace:gpp.m4:2: -1- id 2: changecom ...
m4trace:gpp.m4:2: -1- id 2: changecom(`/*', `*/') -> ???
m4trace:gpp.m4:2: -1- id 2: changecom(...)

m4trace:gpp.m4:3: -1- id 3: changeword ...
m4trace:gpp.m4:3: -1- id 3: changeword(`#<\([_a-zA-Z0-9]*\)>') -> ???
m4trace:gpp.m4:3: -1- id 3: changeword(...)


/usr/local/bin/m4: stack overflow
```

```{shell command="/usr/local/bin/m4 --version"}
m4 (GNU M4) 1.4.17
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Rene' Seindal.
```


```{gdb program="/usr/local/bin/m4"}
(gdb) run gpp.m4
Starting program: /usr/local/bin/m4 gpp.m4
Got object file from memory but can't read symbols: File truncated.





Program received signal SIGSEGV, Segmentation fault.
next_token (td=td@entry=0x7fffffffcf00, line=line@entry=0x7fffffffcefc) at input.c:918
918           if (regs.start[1] != -1)
(gdb) bt
#0  next_token (td=td@entry=0x7fffffffcf00, line=line@entry=0x7fffffffcefc) at input.c:918
#1  0x000000000040d77b in expand_input () at macro.c:67
#2  0x000000000040334b in process_file (name=0x7fffffffd6a0 "gpp.m4") at m4.c:350
#3  0x0000000000402fdd in main (argc=2, argv=0x7fffffffd138) at m4.c:642
(gdb)
```

I'm not great at using gdb, I hope that was an okay amount of backtrace.
-- 
I have nothing fancy or intelligent to put here.
signature.asc (application/pgp-signature, 819 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBAgAGBQJU9cd+AAoJEPu4cabIrwGu+L0QAM0SiTOmnNQZ6qWlYcuysNKM
K67//6/xczpTDla86DoY2GR05lH5E6NxlBaHzS/ELjGqYNmRlXKqZ+2RtbLLBC3Y
RNdAiAVmIxWz2lXIUtZAJgrlbfZzrr9cOx9gabDQIO0rpTT0XB6l72mPaAKLqSvV
m2elVefQIWwlp0TIwYSHEey6ey90FGxUtZt+5TQhfv4P4Pfz+Q4SLzzLKhCUyIZO
B1MfuyOvGQgTPo/lRcxJpwrLoHdABynNTo37RZ6NS6vFtTSjtQU+X4sPVXN+3DpR
Q9J2B1+f219q4X+s9q2uVsZR0FvPMbLRchprZw/3YKWKzhzbL/IHzRyfPA/g8QUl
GN25arnK+3j99f32IIzgklKdWxmOFeUaQWNDWxsnEvjf3UBpBNVP2TMxBMdL1E86
ndLLpkPGq5DcNpYhiCRkQX8VdmLw2oWr/ReYIP5l5t9+WJ2NL2Yw2fRQrJed9JPQ
duskacRNM5Piftycoy8y/EVp7VVNNYoP7UqKmnMZeVITQwybQLdEMQ9LC5ITnwWN
lTHTsOkZcH5oOq1OiLwL9UopFXt0uqGHasbv3nWqie32p5NB5dqQ/1S4yqAWrA2C
QPSk/HYlFsjYa20PsrK4pl6RIGiHgjHn8RSXAUGbN2NjJ3QWPvwd90D9xjSsxxpw
s9zHRmvrT4kzZgyRteQe
=taXZ
-----END PGP SIGNATURE-----