[ 
https://issues.apache.org/jira/browse/TS-5096?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15747388#comment-15747388
 ] 

James Peach commented on TS-5096:
---------------------------------

Root cause for this is that we assumed all metrics have a prefix and try to 
install a metrics object. We can fix the crash by not doing an pointer 
arithmetic, but you can't reference this metric from Lua. The Lua metrics code 
works for metrics that are arranged in a tree, but if a root node in the tree 
is a metric itself, there is no way to implement that in Lua. All we can do is 
update a value with that name.

/cc [~kichan]

> Lua metrics crashes if the prefix is missing
> --------------------------------------------
>
>                 Key: TS-5096
>                 URL: https://issues.apache.org/jira/browse/TS-5096
>             Project: Traffic Server
>          Issue Type: Bug
>          Components: Lua, Metrics
>            Reporter: James Peach
>
> Using the example from the {{tslua.so}} documentation:
> {noformat}
> local test_stat;
> function __init__(args)
>     test_stat = ts.stat_create("test_stat",
>       TS_LUA_RECORDDATATYPE_INT,
>       TS_LUA_STAT_PERSISTENT,
>       TS_LUA_STAT_SYNC_COUNT)
> end
> {noformat}
> {{traffic_manager}} crashes in metrics update:
> {noformat}
> (gdb) where
> #0  0x00007ffff5c964ad in __cxa_throw () from /lib64/libstdc++.so.6
> #1  0x00007ffff5cbfdcf in std::__throw_length_error(char const*) () from 
> /lib64/libstdc++.so.6
> #2  0x00007ffff5d2a7ec in std::__cxx11::basic_string<char, 
> std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, 
> unsigned long) () from /lib64/libstdc++.so.6
> #3  0x00000000004bbcf4 in std::__cxx11::basic_string<char, 
> std::char_traits<char>, std::allocator<char> >::_M_construct<char const*> 
> (this=0x7fffffffdc10, __beg=0x92ec30 "test_stat", __end=0x0) at 
> /usr/include/c++/6.2.1/bits/basic_string.tcc:219
> #4  0x00007ffff5d2d515 in std::__cxx11::basic_string<char, 
> std::char_traits<char>, std::allocator<char> >::basic_string(char const*, 
> unsigned long, std::allocator<char> const&) () from /lib64/libstdc++.so.6
> #5  0x00000000004bd228 in install_metrics_object (rec_type=RECT_PLUGIN, 
> edata=0x7fffffffdcf0, registered=1,
>     name=0x92ec30 "test_stat", data_type=1, datum=0x7ffff7f7dc48) at 
> metrics.cc:214
> #6  0x00000000004a51a1 in RecDumpRecords (rec_type=46,
>     callback=0x4bd1a3 <install_metrics_object(RecT, void*, int, char const*, 
> int, RecData*)>, edata=0x7fffffffdcf0)
>     at RecCore.cc:1020
> #7  0x00000000004bd2dd in lua_metrics_install (L=0x40000378) at metrics.cc:229
> #8  0x0000000000449209 in update_metrics_namespace (L=0x40000378) at 
> metrics.cc:167
> #9  0x0000000000449944 in metrics_binding_evaluate (binding=...) at 
> metrics.cc:377
> #10 0x000000000044844d in main (argc=1, argv=0x7fffffffe578) at 
> traffic_manager.cc:772
> (gdb)
> #5  0x00000000004bd228 in install_metrics_object (rec_type=RECT_PLUGIN, 
> edata=0x7fffffffdcf0, registered=1,
>     name=0x92ec30 "test_stat", data_type=1, datum=0x7ffff7f7dc48) at 
> metrics.cc:214
> 214       prefixes->insert(std::string(name, len));
> (gdb) p len
> $1 = -9628720
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to