Feature #9851
hard code the FWD version string in the JNI code at build time
100%
Related issues
History
#1 Updated by Greg Shah over 1 year ago
- Related to Bug #9740: Client running in batch mode stops with a crash on Windows added
#3 Updated by Greg Shah over 1 year ago
/In #6662, we inserted code to set the FWD_VERSION environment variable in the environment of a child process when we launch it via OS-COMMAND or similar statement. This allows code run in that child process to detect if it is running in FWD or in OE. The value passed down is from the jar.
We've sometimes seen scenarios where the JNI library (libp2j.so/p2j.dll) is build from a different revision than is the FWD code in its matching p2j.jar. This is usually a consequence of a build or deployment failure.
The idea here:
- At build time, we should create a static string literal in the native module that encodes the version.
- At initialization of the native module, we should check if there is a mismatch between
p2j.jarand the native module. Any mismatch would be a fatal failure and we would need to exit in a manner that makes the root cause very obvious. - Instead of passing down the version string in process launching, we can always use the hard coded version.
- As a side-benefit, one will be able to look at the binary module and see the version string (e.g.
strings libp2j.so | grep "_p2j_").
#4 Updated by Lorian Sandu over 1 year ago
Greg Shah wrote:
The idea here:
- At build time, we should create a static string literal in the native module that encodes the version.
- How could we get the version at build time?
- Is
init.cthe proper file to add the static variable?
#5 Updated by Greg Shah over 1 year ago
How could we get the version at build time?
In build.gradle you can see we write it into code like Version.java.
Is
init.cthe proper file to add the static variable?
Yes, that is a reasonable place for it.
#6 Updated by Lorian Sandu over 1 year ago
Greg Shah wrote:
How could we get the version at build time?
In
build.gradleyou can see we write it into code likeVersion.java.
Hmm, ok. Should this version be set when for example "ant native" is called?
What i mean is: should we set this through the make file?
#7 Updated by Greg Shah over 1 year ago
In
build.gradleyou can see we write it into code likeVersion.java.Hmm, ok. Should this version be set when for example "ant native" is called?
Yes, sort of. We should not be using ant native directly but it should be processed when we run gradlew native.
What i mean is: should we set this through the
makefile?
We could but I think it is harder to do that than to write the file out in the gradle processing and just leave makefile alone. I sy this because the make tools are less capable than gradle.
#8 Updated by Lorian Sandu over 1 year ago
Got it. Is there a way to find the code for gradlew native ? I looked into build.gradle but did not find anything.
#9 Updated by Greg Shah over 1 year ago
Got it. Is there a way to find the code for
gradlew native? I looked intobuild.gradlebut did not find anything.
I think you'll have to add it. When people shift to this version, they will need to use gradle instead of ant.
#10 Updated by Lorian Sandu over 1 year ago
Greg Shah wrote:
Got it. Is there a way to find the code for
gradlew native? I looked intobuild.gradlebut did not find anything.I think you'll have to add it. When people shift to this version, they will need to use gradle instead of ant.
But since ./gradlew native works, it must be executing some code right? Can i find somewhere what is it doing under the hood?
There are also other gradlew commands we use (./gradlew core etc.)
#11 Updated by Greg Shah about 1 year ago
In
build.gradleyou can see we write it into code likeVersion.java.Hmm, ok. Should this version be set when for example "ant native" is called?
Yes, sort of. We should not be using
ant nativedirectly but it should be processed when we rungradlew native.
I was wrong about this. I don't recall the reason but the native build is all still in ant. Look at the native targets there. We won't change that for this task.
What i mean is: should we set this through the
makefile?We could but I think it is harder to do that than to write the file out in the gradle processing and just leave
makefilealone. I sy this because themaketools are less capable than gradle.
So the change here should be in the build.xml for ant.
#12 Updated by Greg Shah about 1 year ago
- Status changed from New to WIP
#13 Updated by Roger Borrello about 1 year ago
- File build.gradle added
I'm not sure if it helps, but the build.gradle in branch 7133a has improvements in how the build version is created. Previously, a build using FWD from xfer could not retrieve proper version. It builds up the manifest. Perhaps it could be included, and leveraged for the JNI.
I attached it so you wouldn't need the whole branch.
#14 Updated by Lorian Sandu about 1 year ago
- Assignee set to Lorian Sandu
#15 Updated by Lorian Sandu about 1 year ago
- Status changed from WIP to Review
- reviewer Greg Shah added
9851a / rev 15934 :
- Hard code the FWD_VERSION in the native code at compile time.
- Check for mismatch between FWD versions when the native library is loaded in ClientCore.loadNativeLibrary().
Greg, please review.
I’ve added a severe log entry to report version mismatches. If a more aggressive handling is needed later, I can adjust it accordingly.
Additionally, in reference to your observation from #9851-3, executingstrings libp2j.so | grep "_p2j_"
successfully displayed the embedded version string 4.0.0_p2j_9851a/_15934, which provides a convenient way to verify the native module version.
#16 Updated by Greg Shah about 1 year ago
- Status changed from Review to Internal Test
- % Done changed from 0 to 100
Code Review Task Branch 9851a Revision 15934
The change is good. Have you tested the build process and the resulting p2j.dll on Windows?
#17 Updated by Lorian Sandu about 1 year ago
Greg Shah wrote:
Code Review Task Branch 9851a Revision 15934
The change is good. Have you tested the build process and the resulting
p2j.dllon Windows?
Yes, tested on both Windows (p2j.dll) and Linux (libp2j.so).
In terms of regression testing, other than harness is there anything else i should test?
#18 Updated by Greg Shah about 1 year ago
The changes should be fairly safe. Please check Hotel GUI and Hotel ChUI and something with batch processes. If the clients all start properly, we are good to go.
#19 Updated by Lorian Sandu about 1 year ago
The testing passed.
9851a can be added to the merge queue.
#20 Updated by Greg Shah about 1 year ago
- Status changed from Internal Test to Merge Pending
You can merge to trunk now.
#21 Updated by Lorian Sandu about 1 year ago
- Status changed from Merge Pending to Test
Branch 9851a was merged into trunk as rev. 15945 and archived.
- Hard code the FWD_VERSION in the native code at compile time.
- Check for mismatch between FWD versions when the native library is loaded in ClientCore.loadNativeLibrary(). (Refs #9851)
Important note : p2j needs to be rebuilt (./gradlew all or ./gradlew core) since the changes affect native code.
#22 Updated by Lorian Sandu about 1 year ago
Greg, I believe I’ve found an issue where the FWD version cannot be detected, either in standard Java code or in native code.
When the FWD version is not recognized, the hardcoded value in our native code is "undefined". However, in the p2j.code, ClientCore.loadNativeLibrary() and Version.getFWDVersionUnformatted() return "FWD version undefined". These values are not the same, which make the appservers not to start.
I created 9851b and committed to rev 15946.
Please review.
#23 Updated by Roger Borrello about 1 year ago
I do want to reiterate that many cases where the FWD version becomes "unknown" are resolved by 7133a, since it can handle bzr repositories from xfer, and other places other than our internal configuration. It is rebased and ready for review/merge, and may prevent some downstream conditions.
#24 Updated by Greg Shah about 1 year ago
Roger Borrello wrote:
I do want to reiterate that many cases where the FWD version becomes "unknown" are resolved by 7133a, since it can handle bzr repositories from xfer, and other places other than our internal configuration. It is rebased and ready for review/merge, and may prevent some downstream conditions.
You did not set #7133 to Review status and set the reviewer.
#25 Updated by Greg Shah about 1 year ago
- Status changed from Test to Merge Pending
Code Review Task Branch 9851b Revision 15946
No objections. This should be quite safe.
You can merge 9851b to trunk now.
#26 Updated by Lorian Sandu about 1 year ago
- Status changed from Merge Pending to Test
Branch 9851b was merged into trunk as rev. 15948 and archived.
- Changed
Version.getFWDVersionUnformatted()to return "undefined" when the version is not set