Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault in pfCatch (XT=2536) at ../../csrc/pf_inner.c:335 #6

Closed
tbm opened this issue Jul 9, 2015 · 5 comments
Closed

Segfault in pfCatch (XT=2536) at ../../csrc/pf_inner.c:335 #6

tbm opened this issue Jul 9, 2015 · 5 comments

Comments

@tbm
Copy link

tbm commented Jul 9, 2015

Using current pforth from github and the system.fth file from Debian's pforth package (which is at V21), I get a segfault. I put the system.fth file here: http://www.cyrius.com/tmp/system.fth

Starting program: /home/tbm/pforth-21/a/pforth/build/unix/pforth -i ../../../../system.fth
PForth V27-LE/64, built Jul 9 2015 16:56:37
Including: ../../../../system.fth
CELL redefined.
CELLS redefined.

Program received signal SIGSEGV, Segmentation fault.
0x0000000000402090 in pfCatch (XT=2536) at ../../csrc/pf_inner.c:335
335 Token = READ_CELL_DIC(InsPtr++);
(gdb) where
#0 0x0000000000402090 in pfCatch (XT=2536) at ../../csrc/pf_inner.c:335
#1 0x00000000004095d5 in FindAndCompile (theWord=0x60eac0 "\a0BRANCHIG L PRIMITIVESILING ", '-' <repeats 40 times>, "*")

at ../../csrc/pfcompil.c:765

#2 0x00000000004097f6 in ffInterpret () at ../../csrc/pfcompil.c:849
#3 0x000000000040994f in ffOuterInterpreterLoop () at ../../csrc/pfcompil.c:919
#4 0x00000000004099a1 in ffIncludeFile (InputFile=0x62f790) at ../../csrc/pfcompil.c:942
#5 0x0000000000401bcd in pfIncludeFile (FileName=0x7fffffffecad "../../../../system.fth") at ../../csrc/pf_core.c:373
#6 0x0000000000401e8d in pfDoForth (DicFileName=0x0, SourceName=0x7fffffffecad "../../../../system.fth", IfInit=1) at ../../csrc/pf_core.c:550
#7 0x000000000040579e in main (argc=3, argv=0x7fffffffea28) at ../../csrc/pf_main.c:140

(gdb)

@vuokko
Copy link
Contributor

vuokko commented Jul 12, 2015

First of all, Why do you use old system.fth? pforth should compile nicely with current system.fth.
Use loadp4th.fth to compile your application in ./pforth with pforth.dic and inside ./pforth_standalone.

Second the segfault comes from 0BRANCH in definition of IF which is same in both. With quick look I can't see differences.

@tbm
Copy link
Author

tbm commented Jul 16, 2015

I tried to compile V21 from Debian on ARM64 and it segfaulted. So I searched and saw that V27 is available. This compiled and worked fine on ARM64. For some reason, I tried V27 with the V21 system.fth and received the segfault, which I reproduced on x86_64. What I did may not make much sense, but there should never be a segfault, so I reported it. I hope that explains it.

I don't know anything about pforth. I was just looking for packages in Debian that were not available on ARM64 yet.

@philburk
Copy link
Owner

Hello tbm, thanks for reporting this.

I tried V27 with the V21 system.fth and received the segfault,

There were quite a few changes between V21 and V27, including support for 64-bit operation. I think the segfault was probably due to 32 vs 64-bit pointer mismatch caused by version skew.

What I did may not make much sense, but there should never be a segfault,

Well, maybe. If I wrote a pure Java program and got a segfault then I would say there was a bug in the compiler. A Java program should never segfault. But Forth is an unruly beast with no separation between the compiler, the run-time, and the user program. A segfault caused by version skew involving system.fth is not unexpected..

@vuokko
Copy link
Contributor

vuokko commented Jul 23, 2015

I found the problems. Just for the record:

First are cell and cells. Both are now in C side. Second change was in does> to add >R and R> around [comile] ; That way it compiled. I didn't test any further.

@philburk
Copy link
Owner

You are welcome to try and get files from different versions to work together. But they are not intended to be mixed. We recommend using all files from the same version of pForth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants