码农故事


  • 首页

  • 关于

  • 标签

  • 归档

文件替换导致进程内存损坏

发表于 2018-12-20

某客户的一台机器,无法访问文件上传端口(端口4430),但是可以访问webui端口(端口443),两者都是Apache提供的服务,只是运行时指定了不同的配置文件。

疑问1:为何443端口可以访问而4430端口无法访问?

其运行方式如:

1
httpd -f 无法访问配置.conf

排除-网络原因

先在本机访问4430,连接上了便没了下文:

1
2
3
~ $ wget --no-check-certificate https://127.0.0.1:4430/
--2018-12-19 16:36:04-- https://127.0.0.1:4430/
Connecting to 127.0.0.1:4430... connected.

由于本机也不正常,基本可排除网络方面导致的原因,例如防火墙等。

定位-发生进程

查看4430关联的进程:

1
2
~ $ netstat -nap | grep 4430
tcp6 129 0 :::4430 :::* LISTEN 652/httpd

关联进程652,其启动时间为2018-12-04 09:15:09,最开始出现SIGSEGV是在2018-12-10 11:50:24,当前时间为2018-12-20,说明进程运行了很多天了。

阅读全文 »

自签名证书制作

发表于 2018-12-14

X509 是一种证书标准,定义了证书应该包含的内容,也是SSL使用的证书标准,可以参考rfc5280。

编码格式

存储证书时主要有:

  1. pem(Privacy Enhanced Mail)文本编码
    以”—–BEGIN—–”开头,以”—–END—–” 结尾,内容是BASE64编码。
    Apache和*NIX服务器偏向于使用此类编码格式。
    可通过如下方式查看:

    1
    openssl x509 -in your.pem -text -noout
  2. der(Distinguished Encoding Rules)二进制编
    二进制格式不可读,Java和Windows服务器偏向于使用这种编码格式。
    可通过如下方式查看:

    1
    openssl x509 -in your.der -inform der -text -noout
阅读全文 »

Chrony时间同步

发表于 2018-12-09

目前Centos使用Chrony来提供NTP服务。

将Chrony当成客户端

我们可以将Chrony当成客户端来使用,此时,你需要将你想要同步的NTP server加入配置(例如myserver为NTP server):

1
2
server ~ $ cat /etc/chrony.conf
server myserver iburst

然后重启:

1
server ~ $ systemctl restart chronyd

查看和服务器的连通状态

下面MS是^*,^(脱字符号) 是服务器的意思,*(星号)代表当前处于同步状态,?(问号)表示连接断开。例如,我将服务器时钟调快一个小时,在客户端会显示yyyy为 -36000s。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
server ~ $ chronyc sources -v
210 Number of sources = 1
.-- Source mode '^' = server, '=' = peer, '#' = local clock.
/ .- Source state '*' = current synced, '+' = combined , '-' = not combined,
| / '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
|| .- xxxx [ yyyy ] +/- zzzz
|| / xxxx = adjusted offset,
|| Log2(Polling interval) -. | yyyy = measured offset,
|| \ | zzzz = estimated error.
|| | |
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* myserver 3 6 377 39 -1274s[ -3600s] +/- 29ms

阅读全文 »

PHP Session阻塞验证

发表于 2018-12-05

在function.session-start看到,session_start后,会一直持有锁,建议使用session_write_close/session_commit释放锁,对此表示有点意外,因为这个session_start函数名字取得作实不咋地,怎么看也不想是一段加锁函数,于是写一段代码来验证:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
print_r(date('h:i:s')." enter<br>");
session_start();
print_r(date('h:i:s')." start in session sleep<br>");
$_SESSION['a'] = date('h:i:s');
sleep(10);
print_r(date('h:i:s')." end in session sleep<br>");
// $_SESSION can still be read, but writing will not update the session.
// the lock is removed and other scripts can now read the session
session_write_close(); //别名session_commit
print_r(date('h:i:s')." start after session write sleep<br>");
sleep(10);
print_r(date('h:i:s')." end after session write sleep<br>");
?>

阅读全文 »

gCurrOpUniqueID溢出导致Chrome进程崩溃

发表于 2018-11-27

背景

有一个大屏展示页面,利用Canvas做了大量的2D图像绘制,在某客户处发现,当大屏持续开启一个周左右,Chrome会崩溃,崩溃UI类似:

crash1.png
crash2.png

我们从客户的Chrome://crashes里面获取到了崩溃的dump文件(位于:C:\Users\你的用户名\AppData\Local\Google\Chrome\User Data\Crashpad\reports)(注:下面的截图是我们自己的截图,不是客户的)。

crash3.png

阅读全文 »

Cookies之Git命令

发表于 2018-10-27

配置

gitlib秘钥配置

需要自己生成一个秘钥

1
ssh-keygen -t rsa -C "youremail@example.com"

然后将公钥(默认在~/.ssh/id_rsa.pub)放到网站的个人配置页面,里面有SSH keys添加子页:

基本配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
git config --global user.name "你的名字"
git config --global user.email "你的邮箱"
# windows下载代码编码格式,不会进行转换,提交不转换(默认安装会转换成windows)
git config --global core.autocrlf false
# 拒绝提交包含混合换行符的文件
git config --global core.safecrlf true
# 文件名大小写敏感,有人又不需要大小写敏感,因为windows是大小写不敏感的
git config --global core.ignorecase true
# 避免git gui中的中文乱码
git config --global gui.encoding utf-8
# 避免git status显示的中文文件名乱码
git config --global core.quotepath off
# 彩色显示
git config --global color.ui true
# windows支持长路径,要不然代码路径太长会报错
git config --global core.longpaths true
# windows默认下载git代码,没有显示链接link属性问题
git config --global core.symlinks true
# 为查看历史配置一个别名
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"

别名效果示例:

1
2
3
4
$ git lg
* 1d14eae - (HEAD, origin/master, master) specification v1 (23 minutes ago) <你的名字>
* 9f7c372 - add README (2 hours ago) <你的名字>
*

阅读全文 »

句柄泄漏引发的逻辑错误

发表于 2018-06-01

现象

后端现象是,某个配置文件 “changedir/某配置文件.json” 不定期会被删除。但是不知道是什么进程删除的。

inotify和audit监控

使用inotify监控,的确看到有删除动作,但是同样没法看到是什么进程删除了。
于是改用 audit 监控,监控出来,如下信息:

1
2
3
4
5
6
~ # ausearch -f changedir/某配置文件.json | tail
time->Thu May 31 18:00:50 2018
type=PATH msg=audit(1527760850.765:209600): item=1 name="changedir/某配置文件.json" inode=2722142 dev=08:02 mode=0100644 ouid=0 ogid=0 rdev=00:00 objtype=DELETE
type=PATH msg=audit(1527760850.765:209600): item=0 name="changedir/" inode=2720150 dev=08:02 mode=040755 ouid=2 ogid=2 rdev=00:00 objtype=PARENT
type=CWD msg=audit(1527760850.765:209600): cwd="数据根目录"
type=SYSCALL msg=audit(1527760850.765:209600): arch=c000003e syscall=87 success=yes exit=0 a0=7ffa4402a460 a1=1 a2=7ffa59a22f88 a3=fffffff0 items=2 ppid=10311 pid=23637 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=1 comm="python" exe="/usr/bin/python2.7" key=(null)

可以看到,进程号pid=23637,进程名为python,删除了文件。但是,我们执行:

1
ps auxf | grep 23637

并没有发现进程。

阅读全文 »

谁KILL了进程定位工具之auditd

发表于 2018-01-31

测试部让查一个BUG,某台虚拟机的fantom启动不来。

我准备调试一下:

1
2
3
4
~ # python -mpdb /home/fantom/share/Python-2.7/lib/supervisor/supervisord.py -c /home/fantom/apps/super/default/conf/fantom/supervisord.conf
> /home/fantom/share/Python-2.7/lib/supervisor/supervisord.py(31)<module>()
-> """
(Pdb) Killed

发现刚启动就被KILL了。

是谁这么暗箭伤人?操作系统给了我们杀死其他进程的能力,但自己被杀时,却连仇家都找不到。大概是怕冤冤相报何时了。

auditd

想要找到是谁干的,Linux下有一个比较厉害审计工具,auditd,他可以审计很多系统调用,包括kill。

看下如何配置:

阅读全文 »

Elasticsearch 聚合

发表于 2017-12-29

Elasticsearch是可以自动判断字段的类型的,这个步骤本可以不要,但是,我发现在5.3版本测试的时候,如果不设置fielddata=true,后面的汇聚会报:

1
Fielddata is disabled on text fields by default. Set fielddata=true

于是,为color、make两个文本字段设置fielddata=true选项,这个步骤要在插入数据前,类似于提前创建表:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
PUT
cars
{
"mappings": {
"transations": {
"properties": {
"color": {
"type": "text",
"fielddata": true
},
"make": {
"type": "text",
"fielddata" : true,
}
}
}
}
}

阅读全文 »

内存气泡导致文件损坏错误分析

发表于 2017-11-14

今天测试发现,升级新包后,原来可以插入Elasticsearch的数据,插入不了了,具体错误,我缩减到了一行代码,如下,可重现:

1
python -c "from pandas.formats.format import detect_console_encoding"

输出错误:

1
2
3
4
5
6
7
8
9
10
11
12
File "/home/fantom/share/Python-2.7/lib/site-packages/pandas/__init__.py", line 37, in <module>
import pandas.core.config_init
File "/home/fantom/share/Python-2.7/lib/site-packages/pandas/core/config_init.py", line 18, in <module>
from pandas.formats.format import detect_console_encoding
File "/home/fantom/share/Python-2.7/lib/site-packages/pandas/formats/format.py", line 13, in <module>
from pandas.types.missing import isnull, notnull
File "/home/fantom/share/Python-2.7/lib/site-packages/pandas/types/missing.py", line 12, in <module>
from .common import (is_string_dtype, is_datetimelike,
File "/home/fantom/share/Python-2.7/lib/site-packages/pandas/types/common.py", line 8, in <module>
from pandas import lib, algos
File "pandas/algos.pyx", line 1, in init pandas.algos (pandas/algos.c:155772)
SystemError: Negative size passed to PyString_FromStringAndSize

阅读全文 »
12…6

mnstory.net

58 日志
69 标签
© 2019 mnstory.net