<div dir="ltr">Hey all, <div><br></div><div>I've been trying (with relatively good results so far) to make CentOS 6.2, SystemTap 2.4 and the Erlang VM compatible with each other, and noticed some problems with current implementation when we try to retrieve the string from user space address within our stap script. </div>
<div><br></div><div>Long story short: all strings are trimmed to the first 8 bytes, for instance:</div><div><br></div><div>dist outputv: node, port #Port<0,len 7, remote_node 'chatse, bytes 62<br></div><div><br></div>
<div>It turns out that the code responsible for formatting the probe arguments (let's start with port string name as an example) looks like (<a href="https://github.com/erlang/otp/blob/maint/erts/emulator/beam/dist.c#L1947">https://github.com/erlang/otp/blob/maint/erts/emulator/beam/dist.c#L1947</a>):</div>
<div><br></div><div> erts_snprintf(port_str, sizeof(port_str), "%T", prt-><a href="http://common.id">common.id</a>);<br></div><div><br></div><div>Where port_str is defined as (<a href="https://github.com/erlang/otp/blob/maint/erts/emulator/beam/dist.c#L1944">https://github.com/erlang/otp/blob/maint/erts/emulator/beam/dist.c#L1944</a>):</div>
<div><br></div><div> DTRACE_CHARBUF(port_str, 64);<br></div><div><br></div><div>Which in turn is expanded to (<a href="https://github.com/erlang/otp/blob/maint/erts/emulator/beam/dtrace-wrapper.h#L42">https://github.com/erlang/otp/blob/maint/erts/emulator/beam/dtrace-wrapper.h#L42</a>):</div>
<div><br></div><div> char port_str_BUFFER[size], *port_str = port_str_BUFFER<br></div><div><br></div><div>Now, whenever we call sizeof(port_str_BUFFER) we get an expected response (that is: 64). However, when we call sizeof(port_str) we ask for the size of the char pointer, not the size of the structure it's pointing at (it's going to vary depending on the architecture).</div>
<div><br></div><div>Shouldn't we use sizeof(DTRACE_CHARBUF_NAME(port_str)) instead when fetching sizes of the argument strings (that macro should be expanded to port_str_BUFFER in the example above)?</div><div><br></div>
<div>If you guys agree, I'll prepare appropriate patches and submit a PR for it. </div><div><br></div><div>Thanks, </div><div>Michal</div></div>