| View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||||||||
| ID | Project | Category | View Status | Date Submitted | Last Update | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0000416 | mercury | Bug | public | 2016-08-31 17:04 | 2016-08-31 17:04 | ||||||||
| Reporter | maxime | ||||||||||||
| Assigned To | |||||||||||||
| Priority | normal | Severity | crash | Reproducibility | always | ||||||||
| Status | new | Resolution | open | ||||||||||
| Platform | Java backend | OS | OS Version | ||||||||||
| Product Version | |||||||||||||
| Target Version | Fixed in Version | ||||||||||||
| Summary | 0000416: mutable thread_local java backend missing initialValue() | ||||||||||||
| Description | In the java backend, when compiling a thread_local mutable, mmc generates a static field static java.lang.ThreadLocal<Type> module__mutable_variable_name_of_mutable = new java.lang.InheritableThreadLocal<Type>(); which is set via set(...) to the initial value into a initialise declaration (static code block). The issue is that the InheritableThreadLocal MUST override the initialValue() method, returning the initial value. Why? because in threads may have been created by a container before the static block has executed, leading in the end to a NullPointerException, because a such a thread from a thread-pool is executing code using the mutable, which does not have a parent-child relation with the thread in which the mutable was initialized. | ||||||||||||
| Steps To Reproduce | Create a module with a thread_local mutable, compile to a jar, create a main java, which creates threads before calling anything from the jar, then from multiple threads, use the mutable. | ||||||||||||
| Additional Information | The generated code should either be static java.lang.ThreadLocal<Type> module__mutable_variable_name_of_mutable = new java.lang.InheritableThreadLocal<Type>() { protected java.lang.Integer initialValue() {return <VALUE>;} }; Or static java.lang.ThreadLocal<Type> module__mutable_variable_name_of_mutable; and in the initialization code, instead of doing a set(...), do a new java.lang.InheritableThreadLocal<Type>() { protected java.lang.Integer initialValue() {return <VALUE>;} }; | ||||||||||||
| Tags | No tags attached. | ||||||||||||
| Attached Files |
| ||||||||||||
Issue History |
|||
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2016-08-31 17:04 | maxime | New Issue | |


