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

Add cycle-checking for JsrValue constructor (to avoid SOE) #75

Open
dantesun opened this issue Aug 12, 2020 · 3 comments
Open

Add cycle-checking for JsrValue constructor (to avoid SOE) #75

dantesun opened this issue Aug 12, 2020 · 3 comments
Labels
pr-welcome Issue for which progress most likely if someone submits a Pull Request

Comments

@dantesun
Copy link

dantesun commented Aug 12, 2020

I am sorry but I can't provide more information. My guess this error happend when using JSON.asString to serialize a JsrValue object. The jackson-jr version is 2.11.2.

java.lang.StackOverflowError
	at com.fasterxml.jackson.jr.private_.json.WriterBasedJsonGenerator.writeStartObject(WriterBasedJsonGenerator.java:296)
	at com.fasterxml.jackson.jr.ob.impl.JSONWriter.writeBeanValue(JSONWriter.java)
	at com.fasterxml.jackson.jr.ob.impl.BeanWriter.writeValue(BeanWriter.java)
	at com.fasterxml.jackson.jr.ob.impl.JSONWriter._writeValue(JSONWriter.java)
	at com.fasterxml.jackson.jr.ob.impl.JSONWriter.writeBeanValue(JSONWriter.java)
	at com.fasterxml.jackson.jr.ob.impl.BeanWriter.writeValue(BeanWriter.java)
	at com.fasterxml.jackson.jr.ob.impl.JSONWriter._writeValue(JSONWriter.java)
	at com.fasterxml.jackson.jr.ob.impl.JSONWriter.writeBeanValue(JSONWriter.java)
	at com.fasterxml.jackson.jr.ob.impl.BeanWriter.writeValue(BeanWriter.java)
	at com.fasterxml.jackson.jr.ob.impl.JSONWriter._writeValue(JSONWriter.java)
	at com.fasterxml.jackson.jr.ob.impl.JSONWriter.writeBeanValue(JSONWriter.java)
	at com.fasterxml.jackson.jr.ob.impl.BeanWriter.writeValue(BeanWriter.java)
	at com.fasterxml.jackson.jr.ob.impl.JSONWriter._writeValue(JSONWriter.java)
	at com.fasterxml.jackson.jr.ob.impl.JSONWriter.writeBeanValue(JSONWriter.java)
	at com.fasterxml.jackson.jr.ob.impl.BeanWriter.writeValue(BeanWriter.java)
	at com.fasterxml.jackson.jr.ob.impl.JSONWriter._writeValue(JSONWriter.java)
	at com.fasterxml.jackson.jr.ob.impl.JSONWriter.writeBeanValue(JSONWriter.java)
	at com.fasterxml.jackson.jr.ob.impl.BeanWriter.writeValue(BeanWriter.java)
	at com.fasterxml.jackson.jr.ob.impl.JSONWriter._writeValue(JSONWriter.java)
	at com.fasterxml.jackson.jr.ob.impl.JSONWriter.writeBeanValue(JSONWriter.java)
	at com.fasterxml.jackson.jr.ob.impl.BeanWriter.writeValue(BeanWriter.java)
	at com.fasterxml.jackson.jr.ob.impl.JSONWriter._writeValue(JSONWriter.java)
	at com.fasterxml.jackson.jr.ob.impl.JSONWriter.writeBeanValue(JSONWriter.java)
	at com.fasterxml.jackson.jr.ob.impl.BeanWriter.writeValue(BeanWriter.java)
	at com.fasterxml.jackson.jr.ob.impl.JSONWriter._writeValue(JSONWriter.java)
	at com.fasterxml.jackson.jr.ob.impl.JSONWriter.writeBeanValue(JSONWriter.java)
	at com.fasterxml.jackson.jr.ob.impl.BeanWriter.writeValue(BeanWriter.java)
	at com.fasterxml.jackson.jr.ob.impl.JSONWriter._writeValue(JSONWriter.java)
	at com.fasterxml.jackson.jr.ob.impl.JSONWriter.writeBeanValue(JSONWriter.java)
	at com.fasterxml.jackson.jr.ob.impl.BeanWriter.writeValue(BeanWriter.java)
	at com.fasterxml.jackson.jr.ob.impl.JSONWriter._writeValue(JSONWriter.java)
	at com.fasterxml.jackson.jr.ob.impl.JSONWriter.writeBeanValue(JSONWriter.java)
@cowtowncoder
Copy link
Member

cowtowncoder commented Aug 16, 2020

This would likely result from a cyclic data structure; those can not be serialized by jackson-jr.
If this is not the root cause, it would be necessary to have a reproduction.

@dantesun
Copy link
Author

Please considering add 'clone' support for JrsValue. The current constructor of JrsObject will not check for cyclic data structure.

    public JrsObject(Map<String, JrsValue> values) {
        _values = values;
    }

@cowtowncoder
Copy link
Member

I will leave this as an RFE, in case someone has an idea of implementation.
Implementing support for cyclic data structures is usually a bit complicated thing to do (and tends to add processing overhead due to state keeping required) so this is unlikely to get implemented without contribution.

@cowtowncoder cowtowncoder added the pr-welcome Issue for which progress most likely if someone submits a Pull Request label Feb 16, 2024
@cowtowncoder cowtowncoder changed the title StackOverflowError when using JSON.asString to serialize a JsrValue Add cycle-checking for JsrValue constructor (to avoid SOE) Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-welcome Issue for which progress most likely if someone submits a Pull Request
Projects
None yet
Development

No branches or pull requests

2 participants