we have client that has one of it's core applications made in Ruby on Rails. I'm working on agent that instruments this app automatically. On my local environment with versions of ruby 2.5.x and 2.6.x everything is working properly. Client has it's application in docker container with version of ruby 2.5.8. On application start agent is initilized, I see it in Dynatrace, but app is crashing because of segmentation fault on execution of method:
I was checking if the problem is correlated somehow to string content, but it's not.
> onesdk_initialize returned 0 --> ONESDK_SUCCESS
> onesdk_agent_get_current_state = 0 (ONESDK_AGENT_STATE_ACTIVE)
> onesdk_agent_get_version_string = '188.8.131.5200723-114512'
 Puma starting in cluster mode...
 * Version 3.8.2 (ruby 2.5.8-p224), codename: Sassy Salamander
 * Min threads: 0, max threads: 16
 * Environment: production
 * Process workers: 4
 * Preloading application
 * Listening on tcp://0.0.0.0:9293
 Use Ctrl-C to stop
 - Worker 0 (pid: 238) booted, phase: 0
 - Worker 3 (pid: 250) booted, phase: 0
 - Worker 1 (pid: 242) booted, phase: 0
 - Worker 2 (pid: 244) booted, phase: 0
/app/lib/one-agent/oneagentsdk.rb:175: [BUG] Segmentation fault at 0x0000000000000000
ruby 2.5.8p224 (2020-03-31 revision 67882) [x86_64-linux-gnu]
Does anyone have any idea what can be root cause of that?
Solved! Go to Solution.
@Armin Ruech might be able to shed some light on this.
Note however that the Ruby SDK Binding is merely not an officially supported OneAgent SDK
(see the disclaimer: https://github.com/Dynatrace/OneAgent-SDK-Ruby-Sample-Binding)
From the output (segmentation fault at null pointer), it looks like a null pointer is passed to the native SDK function
onesdk_webapplicationinfo_create_p called in that line. This might result from
nil being returned in either
onesdk_asciistr (line 96) or
onesdk_utf8str (line 109) for one of the three strings passed as arguments. I could also imagine that
String#encode does not work as expected and instead of throwing returns
nil, which in turn causes
FFI::MemoryPointer.from_string in line 113 to return a null pointer that gets stored in the
onesdk_string object. Could it be that the string object's encoding is set incorrectly or that it contains invalid bytes? You might want to step through the code or add some extra debug output for each parameter and step to get some more information.
I've checked everything, onesdk_string isn nil, memorypointer is set as well. I was replacing those 3 strings with something simple as well. Still there is kind of problem here related to segmentation fault. It's interesting thing. I was checking as well options to force encoding on ruby side but with no luck.
since there is apparently no simple solution to this issue, I'm afraid we can't help out here.
Unfortunately, troubleshooting or creating reproducer scenarios for unsupported technologies is out of our scope at the moment.
Of course, we will let you know in case a solution to this issue comes up.
For all others that may have this issue. For this particular environment there is some kind of issue when we were using OneAgent SDK called via FFI. I wrote own native extension for ruby which is working fine. In such case I can use SDK methods directly from ruby without and 3rd party gem needed. In this case it is working fine.