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

CompiledCode>>refersToLiteral: can infinitely recurse #16812

Open
guillep opened this issue Jun 27, 2024 · 2 comments
Open

CompiledCode>>refersToLiteral: can infinitely recurse #16812

guillep opened this issue Jun 27, 2024 · 2 comments

Comments

@guillep
Copy link
Member

guillep commented Jun 27, 2024

In Pharo13 (and at least since Pharo 11), refersToLiteral: can infinitely recurse.
This happens if the method is part of the list of literals (and probably if it is in a literal array it happens too but I have not tested)

refersToLiteral: aLiteral
	"Answer true if any literal in this method is literal,
	even if embedded in array structure."

	1 to: self numLiterals - self literalsToSkip do: [ :index |
		"exclude selector or additional method state (penultimate slot)
		and methodClass or outerCode (last slot)"
		((self literalAt: index) refersToLiteral: aLiteral)
			ifTrue: [ ^ true ] ].

	^ false
@guillep guillep changed the title CompiledCode>>refersToLiteral: can recurse CompiledCode>>refersToLiteral: can infinitely recurse Jun 27, 2024
@Ducasse
Copy link
Member

Ducasse commented Jul 1, 2024

I was wondering if I should add a test. The problem is that when the test fails it would produce an infinite loop and this is a bad idea.
I was wondering how to write a test that does not loop still check the point.

@guillep
Copy link
Member Author

guillep commented Jul 1, 2024

If it loops, the CI should stop it with a timeout...
However, there is a risk that something triggers the loop again outside of the control of the test runner.
But I think it's worth trying.

The test should however be careful to not install the method in the system.

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

No branches or pull requests

2 participants