Stream: git-wasmtime

Topic: wasmtime / issue #4980 Cranelift JITModule and multithrea...


view this post on Zulip Wasmtime GitHub notifications bot (Sep 29 2022 at 18:58):

mokhaled2992 edited issue #4980:

Hi everyone,

This is asking for help/advice. I have JIT struct very similar to the one in the toy demo. I only generate code that builds a wrapper function that only calls a rust function. Mainly following those examples (jit-minimal) and (cranelift-call rust function). Now I instantiate one single instance for each thread from that JIT struct and use each independently only in their own thread to call the function through the pointer I get from that respective JITModule instance. The problem is that I'm getting segmentation faults randomly (as in sometimes they happen sometimes not) when I try to call the functions through the returned pointers and this happens only in multi threaded testing, I never had this issue a single time when I tested my code in single threaded environment. Are there any limitations to using the JITModule in multithreaded environments or any common pitfalls that I should watch for? If needed, I can try to write a minimal example (although wouldn't be very different from the samples above).

I even tried without calling free_memory at all and still the same problem (only when running in multiple threads as mentioned)

Random guessing, Is there anything shared across JITModules? Perhaps something related to those relocation tables?

view this post on Zulip Wasmtime GitHub notifications bot (Sep 29 2022 at 18:59):

mokhaled2992 edited issue #4980:

Hi everyone,

This is asking for help/advice. I have JIT struct very similar to the one in the toy demo. I only generate code that builds a wrapper function that only calls a rust function. Mainly following those examples jit-minimal and cranelift-call rust function. Now I instantiate one single instance for each thread from that JIT struct and use each independently only in their own thread to call the function through the pointer I get from that respective JITModule instance. The problem is that I'm getting segmentation faults randomly (as in sometimes they happen sometimes not) when I try to call the functions through the returned pointers and this happens only in multi threaded testing, I never had this issue a single time when I tested my code in single threaded environment. Are there any limitations to using the JITModule in multithreaded environments or any common pitfalls that I should watch for? If needed, I can try to write a minimal example (although wouldn't be very different from the samples above).

I even tried without calling free_memory at all and still the same problem (only when running in multiple threads as mentioned)

Random guessing, Is there anything shared across JITModules? Perhaps something related to those relocation tables?

view this post on Zulip Wasmtime GitHub notifications bot (Sep 29 2022 at 18:59):

mokhaled2992 edited issue #4980:

Hi everyone,

This is asking for help/advice. I have JIT struct very similar to the one in the toy demo. I only generate code that builds a wrapper function that only calls a rust function. Mainly following those examples; jit-minimal and cranelift-call rust function. Now I instantiate one single instance for each thread from that JIT struct and use each independently only in their own thread to call the function through the pointer I get from that respective JITModule instance. The problem is that I'm getting segmentation faults randomly (as in sometimes they happen sometimes not) when I try to call the functions through the returned pointers and this happens only in multi threaded testing, I never had this issue a single time when I tested my code in single threaded environment. Are there any limitations to using the JITModule in multithreaded environments or any common pitfalls that I should watch for? If needed, I can try to write a minimal example (although wouldn't be very different from the samples above).

I even tried without calling free_memory at all and still the same problem (only when running in multiple threads as mentioned)

Random guessing, Is there anything shared across JITModules? Perhaps something related to those relocation tables?

view this post on Zulip Wasmtime GitHub notifications bot (Sep 29 2022 at 19:15):

bjorn3 commented on issue #4980:

I think incorrect premissions is the most likely issue. If selinux-fix fixes it, incorrect permissions is almost definitively the issue. Not quite sure why that would happen without selinux-fix though.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 30 2022 at 15:41):

mokhaled2992 commented on issue #4980:

@bjorn3 Thanks man :heart:️. The selinux-fix did the job. Perhaps a note somewhere in the demo or in the README abot this feature flag would be great and saves alot of frustration :)

view this post on Zulip Wasmtime GitHub notifications bot (Sep 30 2022 at 15:41):

mokhaled2992 edited a comment on issue #4980:

@bjorn3 Thanks man :heart:️. The selinux-fix did the job. Perhaps a note somewhere in the demo or in the README about this feature flag would be great and saves alot of frustration :)

view this post on Zulip Wasmtime GitHub notifications bot (Sep 30 2022 at 15:42):

mokhaled2992 closed issue #4980:

Hi everyone,

This is asking for help/advice. I have JIT struct very similar to the one in the toy demo. I only generate code that builds a wrapper function that only calls a rust function. Mainly following those examples; jit-minimal and cranelift-call rust function. Now I instantiate one single instance for each thread from that JIT struct and use each independently only in their own thread to call the function through the pointer I get from that respective JITModule instance. The problem is that I'm getting segmentation faults randomly (as in sometimes they happen sometimes not) when I try to call the functions through the returned pointers and this happens only in multi threaded testing, I never had this issue a single time when I tested my code in single threaded environment. Are there any limitations to using the JITModule in multithreaded environments or any common pitfalls that I should watch for? If needed, I can try to write a minimal example (although wouldn't be very different from the samples above).

I even tried without calling free_memory at all and still the same problem (only when running in multiple threads as mentioned)

Random guessing, Is there anything shared across JITModules? Perhaps something related to those relocation tables?

view this post on Zulip Wasmtime GitHub notifications bot (Sep 30 2022 at 16:18):

bjorn3 commented on issue #4980:

Opened https://github.com/bytecodealliance/wasmtime/issues/4986.


Last updated: Dec 23 2024 at 12:05 UTC