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

StackOverflow when using new Permision system in ClassLoader #25

Closed
mathieu-veron opened this Issue Apr 25, 2017 · 5 comments

Comments

Projects
None yet
2 participants
@mathieu-veron
Copy link

mathieu-veron commented Apr 25, 2017

Hello,
I'm in the context of a tomcat 6 webapp, using janino 3.0.7
My code is much like the documented code in the security section

What happens is a stackoverflow originated by
SecurityMamanger.checkRead calling the SandBox.checkPermission

In my case here is the loop created

SecurityMamanger.checkRead:888
code : checkPermission(new FilePermission(file,SecurityConstants.FILE_READ_ACTION));

SandBox$1.checkPermission:82
code : acc = Sandbox.CONFINED_CLASS_LOADERS.get(clasS.getClassLoader());

Class.getClassLoader:683
ClassLoader.checkClassLoaderPermission:1528

   who again call :  SandBox$1.checkPermission:82

And so we are from here stuck in a loop which lead to a S.O.

@aunkrig

This comment has been minimized.

Copy link
Member

aunkrig commented May 1, 2017

The reason being is that the sandbox's security manager invokes "Class.getClassLoader()", which in turn calls the security manager's "checkPermission()" method. Bummer.

@aunkrig

This comment has been minimized.

Copy link
Member

aunkrig commented May 1, 2017

This problem occurs iff the class loader of the "Sandbox.class" is not an ancestor of the context class's class loader.

@aunkrig

This comment has been minimized.

Copy link
Member

aunkrig commented May 1, 2017

Would you please be so kind and post the complete stack trace, so I can see which class requests READ permission?

@aunkrig

This comment has been minimized.

Copy link
Member

aunkrig commented May 1, 2017

Also, please try and change the following lines in "sandbox.java":

for (Class<?> clasS : this.getClassContext()) {
    if (clasS == this.getClass()) return;    // <= That should prevent infinite recursion.

aunkrig added a commit that referenced this issue May 1, 2017

aunkrig added a commit that referenced this issue May 1, 2017

@mathieu-veron

This comment has been minimized.

Copy link

mathieu-veron commented May 3, 2017

Hello,
Just grab the compiler 3.0.8 snapshot from the trunk, and it solve the issue (and the unit test are still working). thx. Do you still need the full stack trace ?

@aunkrig aunkrig closed this Sep 25, 2017

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