trafficserver icon indicating copy to clipboard operation
trafficserver copied to clipboard

traffic_layout remove command core dumped

Open wk333 opened this issue 2 years ago • 4 comments

[root@localhost ~]# mkdir test
[root@localhost ~]# cd test
[root@localhost test]# traffic_layout init
creating runroot - /root/test
WARNING: Unable to copy 'cachedir' - No such file or directory
NOTE: Creating 'cachedir': /var/cache/trafficserver
WARNING: Unable to copy 'sysconfdir' - No such file or directory
NOTE: Creating 'sysconfdir': /etc/trafficserver
WARNING: Unable to copy 'runtimedir' - No such file or directory
NOTE: Creating 'runtimedir': /run/trafficserver
WARNING: Unable to copy 'logdir' - No such file or directory
NOTE: Creating 'logdir': /var/log/trafficserver
Copying from /usr ...
[root@localhost test]# ls
bin  include  lib64  runroot.yaml  sbin  share
[root@localhost test]# cat runroot.yaml 
prefix: .
exec_prefix: .
bindir: ./bin
sbindir: ./sbin
sysconfdir: /etc/trafficserver
datadir: ./share
includedir: ./include
libdir: ./lib64/trafficserver
libexecdir: ./lib64/trafficserver/plugins
localstatedir: /var
runtimedir: /run/trafficserver
logdir: /var/log/trafficserver
cachedir: /var/cache/trafficserver[root@localhost test]# 
[root@localhost test]# traffic_layout remove
NOTE: using cwd as TS_RUNROOT
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::substr: __pos (which is 11) > this->size() (which is 5)
Aborted(core dumped)
[root@localhost test]# 

wk333 avatar Aug 26 '22 10:08 wk333

environment centos8 yum install trafficserver from http://rpmfind.net/linux/RPM/epel/8/x86_64/Packages/t/trafficserver-9.1.3-1.el8.x86_64.html

wk333 avatar Aug 30 '22 01:08 wk333

@bryancall beside the crash, are we missing this in 9.1?

brbzull0 avatar Sep 20 '22 16:09 brbzull0

This issue has been automatically marked as stale because it has not had recent activity. Marking it stale to flag it for further consideration by the community.

github-actions[bot] avatar Sep 21 '23 01:09 github-actions[bot]

I was able to reproduce the crash on master branch.

It looks like traffic_layout assumes these directories below are under a run-root directory. If some of them are not under a run-root directory, the command fails to calculate string lengths and causes the crash. https://github.com/apache/trafficserver/blob/188a12834cf1b3692b62e2d5e3abd68912d3390b/src/traffic_layout/engine.h#L57-L60

To reproduce, use the preset below (on master)

{                                                                                                                                
  "name": "problematic_layout",                                                                                                  
  "hidden": true,                                                                                                                
  "cacheVariables": {                                                                                                            
    "CMAKE_INSTALL_CACHEDIR": "/tmp/problematic_layout_test_directory/trafficserver"                                             
  } 
}

maskit avatar Jun 06 '24 22:06 maskit