-
Notifications
You must be signed in to change notification settings - Fork 202
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
About transferring PCRE2 compilation results in shared memory. #579
Comments
In theory, your idea is possible. However, you need to share executable memory, and I am not sure operating systems like (support/allow) that. The first thing you need to check that the shared memory has executable permissions. If the crash happens at the first instruction of the jit code (gdb disassembly can show that), it is likely that you have no permission for that. |
Btw, the defaullt allocator may allocate multiple memory chunks. You might need a custom allocator which satisfies all your needs: |
Thank you very much for your reply. I am currently using my own memory pool to handle all the memory allocations. I will continue to try based on your suggestions. Thank you!
|
Does the JIT generate position-independent-code? If the memory is mapped into two different processes, the addresses of the jump targets won't be the same. |
No. I suspect he maps the code to the same address. |
Hello! I am currently working on a project that requires the use of the PCRE2 library for string extraction tasks. Since this project involves network packet forwarding, the performance and latency requirements are very high.
I would like to compile the regular expression patterns in one process and, after the PCRE2 automaton compilation is complete (including JIT compilation), pass all relevant information directly to my data forwarding process so that it can use it directly without spending additional time on compilation.
Currently, my solution is to create a memory pool using shared memory in the compilation process (hereinafter referred to as Process A) and map it to my address space. At the same time, I register the memory pool management functions in the PCRE2 context. After completing the pattern compilation and JIT compilation, I notify the data forwarding process (hereinafter referred to as Process B) of the starting address of this memory.
After Process B receives the message, it opens the shared memory and maps it to the same address space location, then begins executing the PCRE2 matching operations. However, it always crashes and throws a segmentation fault.
Here is the stack trace information I obtained using GDB:
Could you please advise me on how to resolve this issue? Or do I have to perform JIT compilation again in the execution process, and cannot simply compile in one process and execute in another through shared memory?
Thank you very much for your help!
The text was updated successfully, but these errors were encountered: