vermaseren / form

The FORM project for symbolic manipulation of very big expressions
GNU General Public License v3.0
1.14k stars 136 forks source link

Index matches to -1 but crashes in output #149

Closed benruijl closed 7 years ago

benruijl commented 7 years ago

The following program crashes:

#-
Index mu1;
CF g;

L F = g(-1);
id g(mu1?) = mu1;

Print +s;
.end

with the following backtrack:

Program received signal SIGSEGV, Segmentation fault.
0x000000000042cd23 in FindVector (num=800000209) at dict.c:291
291     return(VARNAME(vectors,num));
(gdb) bt
#0  0x000000000042cd23 in FindVector (num=800000209) at dict.c:291
#1  0x00000000004d8ba2 in WriteSubTerm (sterm=sterm@entry=0x7fffed459014, first=first@entry=1) at sch.c:1651
#2  0x00000000004d975a in WriteInnerTerm (term=term@entry=0x7fffed459010, first=1, first@entry=0) at sch.c:2036
#3  0x00000000004da228 in WriteTerm (term=0x7fffed459010, lbrac=lbrac@entry=0x7fffffffe57c, first=first@entry=0, prtf=prtf@entry=9, br=br@entry=0) at sch.c:2365
#4  0x00000000004da741 in WriteAll () at sch.c:2569
#5  0x0000000000437dc2 in DoExecute (par=4, skip=skip@entry=0) at execute.c:812
#6  0x000000000044e576 in ExecModule (moduletype=<optimized out>) at module.c:274
#7  0x00000000004b123e in PreProcessor () at pre.c:898
#8  0x00000000004e940a in main (argc=2, argv=0x7fffffffe738) at startup.c:1586
tueda commented 7 years ago

The manual says, in "Pattern matching" chapter,

id f(mu?,mu?) = 4; would match both f(ka,ka) and f(2,2).

and in "Variables - Indices" section,

In addition to the symbolic indices there is a number of fixed indices with a numeric value. The values of these indices runs from zero to an installation dependent number (usually 127).

In my environment, fixed indices are from 0 to 128, which match with g(mu?fixed_), so -1 is out of the range, though FORM should not crash.

I guess what you need in your case is something like

id g(n?int_) = ...
id g(mu?index_) = ...

to distinguish indices from numbers.

vermaseren commented 7 years ago

Hi Takahiro,

Till a fixed value (typically 1-127) a wildcard index can match such an integer as it can be seen as a fixed index. This runs in parallel with that you can sum an index litterally as in sum i,1,2,5,7; in which you generate 4 terms. Of course the value of those indices should be at most 127 unless you change that value in the setup. Internally the value that controls this is OffsetIndex in one of the structs.

Jos

On 24 nov. 2016, at 16:35, Takahiro Ueda notifications@github.com wrote:

The manual says, in "Pattern matching" chapter,

id f(mu?,mu?) = 4; would match both f(ka,ka) and f(2,2).

and in "Variables - Indices" section,

In addition to the symbolic indices there is a number of fixed indices with a numeric value. The values of these indices runs from zero to an installation dependent number (usually 127).

I guess what you need in your case is something like

id g(n?int) = ... id g(mu?index) = ... to distinguish indices from numbers.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/vermaseren/form/issues/149#issuecomment-262802180, or mute the thread https://github.com/notifications/unsubscribe-auth/AFLxEjKaY5iSoOj2rP-YyfuQnJsmGl8Eks5rBa65gaJpZM4K7uVh.

benruijl commented 7 years ago

Sadly this patch does not work for symmetric functions yet:

#-
Index mu1;
CF f(s);
L F = f(-1);

id f(mu1?) = mu1;

Print +s;
.end
tueda commented 7 years ago

I needed a copy-and-paste of the patch to another function.