[erlang-bugs] SystemTap user_string trimmed output

Michał Ptaszek erlang@REDACTED
Tue Mar 11 11:11:30 CET 2014


Hey all,

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.

Long story short: all strings are trimmed to the first 8 bytes, for
instance:

dist outputv: node, port #Port<0,len 7, remote_node 'chatse, bytes 62

It turns out that the code responsible for formatting the probe
arguments (let's start with port string name as an example) looks like (
https://github.com/erlang/otp/blob/maint/erts/emulator/beam/dist.c#L1947):

        erts_snprintf(port_str, sizeof(port_str), "%T", prt->common.id);

Where port_str is defined as (
https://github.com/erlang/otp/blob/maint/erts/emulator/beam/dist.c#L1944):

        DTRACE_CHARBUF(port_str, 64);

Which in turn is expanded to (
https://github.com/erlang/otp/blob/maint/erts/emulator/beam/dtrace-wrapper.h#L42
):

        char port_str_BUFFER[size], *port_str = port_str_BUFFER

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).

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)?

If you guys agree, I'll prepare appropriate patches and submit a PR for it.

Thanks,
Michal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20140311/bdba67ea/attachment.htm>


More information about the erlang-bugs mailing list