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

stack overflow during consult/1 #329

Open
Jean-Luc-Picard-2021 opened this issue Aug 10, 2024 · 2 comments
Open

stack overflow during consult/1 #329

Jean-Luc-Picard-2021 opened this issue Aug 10, 2024 · 2 comments

Comments

@Jean-Luc-Picard-2021
Copy link

Jean-Luc-Picard-2021 commented Aug 10, 2024

I don't know exactly where it happens, but it happens:

tests$ ~/go/bin/1pl
Top level for ichiban/prolog v1.2.1
This is for testing purposes only!
See https://github.com/ichiban/prolog for more details.
Type Ctrl-C or 'halt.' to exit.

?- ['suite.p'].
runtime: goroutine stack exceeds 1000000000-byte limit
runtime: sp=0xc05b402360 stack=[0xc05b402000, 0xc07b402000]
fatal error: stack overflow
runtime stack: runtime.throw({0x588e80?, 0xc0000bbe68?})
/usr/local/go/src/runtime/panic.go:1023 +0x5c fp=0xc0000bbe18 sp=0xc0000bbde8 pc=0x437a5c
runtime.newstack()
/usr/local/go/src/runtime/stack.go:1103 +0x5bd fp=0xc0000bbfc8 sp=0xc0000bbe18 pc=0x45305d
runtime.morestack()
/usr/local/go/src/runtime/asm_amd64.s:616 +0x7a fp=0xc0000bbfd0 sp=0xc0000bbfc8 pc=0x469b3a
goroutine 10 gp=0xc0001a2000 m=9 mp=0xc000081008 [running]:
runtime.deductAssistCredit(0x10?)
/usr/local/go/src/runtime/malloc.go:1337 +0x70 fp=0xc05b402370 sp=0xc05b402368 pc=0x40e3f0
runtime.mallocgc(0x10, 0x55dd60, 0x1)
/usr/local/go/src/runtime/malloc.go:1025 +0xcc fp=0xc05b4023f8 sp=0xc05b402370 pc=0x40db4c
runtime.newobject(0x0?)
/usr/local/go/src/runtime/malloc.go:1390 +0x25 fp=0xc05b402420 sp=0xc05b4023f8 pc=0x40e4c5
regexp.(*Regexp).replaceAll(0xc00010e1e0, {0x0, 0x0, 0x0}, {0xc0a616f104, 0x6}, 0x2, 0xc05b402548)
/usr/local/go/src/regexp/regexp.go:621 +0x76 fp=0xc05b402508 sp=0xc05b402420 pc=0x4cb0f6
regexp.(*Regexp).ReplaceAllStringFunc(0xc05b402a10?, {0xc0a616f104?, 0x4887ba?}, 0x69dac0?)
Etc...

Possibly it does loop somewhere? Or there is a memory leak,
like something gets allocated but not deallocated? Even worse
the memory leak is in some go system utility?

I don't know, the stack trace also shows Lexer and Parser,
I have only copied the first few lines.

The test folder was this one:

tests.zip

@ichiban
Copy link
Owner

ichiban commented Aug 11, 2024

Hi! Thank you for reporting!

I managed to reproduce the error with a shorter code:

$ cat test.pl 
:- ['test.pl'].
$ $(go env GOPATH)/bin/1pl
Top level for ichiban/prolog v1.2.1
This is for testing purposes only!
See https://github.com/ichiban/prolog for more details.
Type Ctrl-C or 'halt.' to exit.
?- ['test.pl'].
runtime: goroutine stack exceeds 1000000000-byte limit
...

You can avoid this bug by stopping consulting 'suite.p' inside suite.p recursively.

I'll fix it later- it should have result in either an exception or ignoring recursive file load. So, let's keep this issue opened until the fix is ready.

@Jean-Luc-Picard-2021
Copy link
Author

Jean-Luc-Picard-2021 commented Aug 11, 2024

Ok, my bad, I copy pasted the command line
I tried into the suite.p file, and forget to remove
the suite.p entry.

It shouldn't loop for ensure_loaded/1 but it
is allowed to loop for include/1. But for consult/1
it depends whether it has ensure_loaded/1

traits or not.

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

2 participants