hotpatch | Changing function definitions at runtime in Rust
kandi X-RAY | hotpatch Summary
kandi X-RAY | hotpatch Summary
This crate is primarily used to load new function definitions from shared object files in an exceedingly easy way.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of hotpatch
hotpatch Key Features
hotpatch Examples and Code Snippets
Community Discussions
Trending Discussions on hotpatch
QUESTION
I thought hot-patching assumed that overwriting any instruction that is 2 or more bytes long with a 2 byte jump is safe for concurrent execution of the same code.
So instruction fetch is assumed to be atomic.
Is it indeed atomic, taking into account that with prefixes it is possible to have more than 8 bytes instruction, and it can cross any aligned boundary? (Or does hot-patching rely on 16-byte alignment of function start? If so, what's with size over 8 bytes, anyway?)
The context: LLVM has interception of API functions in https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/interception/interception_win.cpp. This is used at least for Address Sanitizer, maybe for something else too. It implements HotPatch as 3rd method (line 61):
...ANSWER
Answered 2021-Dec-05 at 00:12Instruction fetch is not architecturally guaranteed to be atomic. Although, in practice, an instruction cache fill transaction is, by definition atomic, meaning that the line being filled in the cache cannot change before the transaction completes (which happens when the whole line is stored in the IFU, but not necessarily in the instruction cache itself). The instruction bytes are also delivered to the input buffer of the instruction predecode unit at some atomic granularity. On modern Intel processors, the instruction cache line size is 64 bytes and the input width of the predcode unit is 16 bytes with an address aligned on a 16-byte boundary. (Note that the 16 bytes input can be delivered to the predecode unit before the entire transaction of fetching the cache line containing these 16 bytes completes.) Therefore, an instruction aligned on a 16-byte boundary is guaranteed to be fetched atomically, together with at least one byte of the following contiguous instruction, depending on the size of the instruction. But this is a microarchitectural guarantee, not architectural.
It seems to me that by instruction fetch atomicity you're referring to atomicity at the granularity of individual instructions, rather than some fixed number of bytes. Either way, instruction fetch atomicity is not required for hotpatching to work correctly. It's actually impractical because instruction boundaries are not known at the time of fetch.
If instruction fetch is atomic, it may still be possible to fetch, execute, and retire the instruction being modified with only one of the two bytes being written (or none of the bytes or both of the bytes). The allowed orders in which writes reach GO depend on the effective memory types of the target memory locations. So hotpatching would still not be safe.
Intel specifies in Section 8.1.3 of the SDM V3 how self-modifying code (SMC) and cross-modifying code (XMC) should work to guarantee correctness on all Intel processors. Regarding SMC, it says the following:
To write self-modifying code and ensure that it is compliant with current and future versions of the IA-32 architectures, use one of the following coding options:
(* OPTION 1 *)
Store modified code (as data) into code segment;
Jump to new code or an intermediate location;
Execute new code;(* OPTION 2 *)
Store modified code (as data) into code segment;
Execute a serializing instruction; (* For example, CPUID instruction *)
Execute new code;The use of one of these options is not required for programs intended to run on the Pentium or Intel486 processors, but are recommended to ensure compatibility with the P6 and more recent processor families.
Note that the last statement is incorrect. The writer probably intended to say instead: "The use of one of these options is not required for programs intended to run on the Pentium or later processors, but are recommended to ensure compatibility with the Intel486 processors." This is explained in Section 11.6, from which I want to quote an important statement:
A write to a memory location in a code segment that is currently cached in the processor causes the associated cache line (or lines) to be invalidated. This check is based on the physical address of the instruction. In addition, the P6 family and Pentium processors check whether a write to a code segment may modify an instruction that has been prefetched for execution. If the write affects a prefetched instruction, the prefetch queue is invalidated. This latter check is based on the linear address of the instruction
Briefly, prefetch buffers are used to maintain instruction fetch requests and their results. Starting with the P6, they were replaced with streaming buffers, which have a different design. The manual still uses the term "prefetch buffers" for all processors. The important point here is that, with respect to what is guaranteed architecturally, the check in the prefetch buffers is done using linear addresses, not physical addresses. That said, probably all Intel processors do these checks using physical addresses, which can be proved experimentally. Otherwise, this can break the fundamental sequential program order guarantee. Consider the following sequence of operations being executed on the same processor:
QUESTION
As per the tittle, I am unable to get the EGL14.eglGetCurrentContext()
inside an Android Java class. More precisely, the returned context is equal to EGL14.EGL_NO_CONTEXT
.
My interpretation is that the code is called from the main Unity thread yet the code is not able to get the OpenGL context.
Multithreaded rendering is disabled. The project is a Unity project exported to Android. This C# code calls the Java initSurface
method from an Update
function of a MonoBehavior
:
ANSWER
Answered 2021-Apr-13 at 11:18It was occurring because Unity was using Vulkan instead of OpenGLES all along. Disabling the Automatic Graphics API in the Player settings and dragging OpenGLES2 on top fixes the issue.
QUESTION
i am really new to Android Studio and java programming.
im trying to create a new project, just to experimenting and learning.
this app there is long text and i using string to format it and also as resources.
however, after 1400+ text and formatting, the activity crash.
may i know is there some limit on string resources ?
and what is the way to overcome the problems ?
i figured out to use raw text, but on my current understanding, there is no way to format it like strings.
really appreciate if anyone can help.
\edit
here is the error
...ANSWER
Answered 2021-Feb-20 at 10:54String.length()
method returns the length of the string. The length of the string is equal to the number of Unicode units in the string. The Java platform uses the UTF-16 representation in char arrays (each character takes two bytes), String, and StringBuffer classes.
The method returns the length which is of type int. So, the String maximum size
is the same as the range of integer data type
. The maximum length that would be returned by the method would be Integer.MAX_VALUE
.
The size of int in Java is 4 bytes (included a signed bit, i.e. MSB). The range of integer data type is -231 to 231-1 (-2147483648 to 2147483647). Remember that we cannot use negative values for indexing. The indexing is done within the maximum range. It means that we cannot store the 2147483648th character. Therefore, the maximum length of String in Java is 0 to 2147483647. So, we can have a String with the length of 2,147,483,647 characters, theoretically.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install hotpatch
Rust is installed and managed by the rustup tool. Rust has a 6-week rapid release process and supports a great number of platforms, so there are many builds of Rust available at any time. Please refer rust-lang.org for more information.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page