Tag

debug

12 posts

Debugging is a methodical process of finding and reducing the number of bugs, or defects, in a computer program or a piece of electronic hardware, thus making it behave as expected. Debugging tends to be harder when various subsystems are tightly coupled, as changes in one may cause bugs to emerge in another.

Code

vsftpd: GnuTLS error -15: An unexpected TLS packet

TL;DR: Configuring vsftp is a difficult work and we always meet various of errors. In this post, I am going to introduce one possible solution of error "GnuTLS error -15: An unexpected TLS packet was received." when you are using vsftpd.

Code

inliner warnings with Map literal and -optimize

scala在编译&优化的时候,有时候会返回个inline warning.但是,实际上我们写代码已经不能再优化了. 比如如下这个例子: [scala] yu:~ yu$ scala -version Scala code runner version 2.11.7 -- Copyright 2002-2013, LAMP/EPFL yu:~ yu$ scala -optimize -Yinline-warnings Welcome to Scala version 2.11.7 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_05). Type in expressions to have them evaluated. Type :help for more information.

scala> object O { Map( | "a" -> 0, "b" -> 1, "c" -> 2, "d" -> 3, "e" -> 4, | "a" -> 0, "b" -> 1, "c" -> 2, "d" -> 3, "e" -> 4, | "a" -> 0, "b" -> 1, "c" -> 2, "d" -> 3, "e" -> 4, | "f" -> 5, "g" -> 6, "h" -> 7, "i" -> 8) } warning: At the end of the day, could not inline @inline-marked method ->extension warning: At the end of the day, could not inline @inline-marked method ->extension warning: At the end of the day, could not inline @inline-marked method ->extension warning: At the end of the day, could not inline @inline-marked method ->extension defined object O

[/scala]

我们可以看到有个issue ,讲的就是这件事.它是12年底建立的,但一直没啥好的回答...可怜我为了关掉这个warning连带好几个其它warning都不能用了.

不过,今年五月终于有结果了.

Code

mysql添加自增索引后一个报错解

现在有一个mysql数据库表,需要给主键加上自增。很容易可以找到命令类似于下面这样

SQL
alter table `table_name` 
change column `id` 
`id` int(10) unsigned auto_increment not null ;

但是,一直没问题的代码这次失效了,报错如下:

SQL
ERROR 1062: ALTER TABLE causes auto_increment resequencing, 
resulting in duplicate entry '1' for key 'PRIMARY'

Code

mozjs185 在哪里?

安装某个东西,cmake的时候,报错如下

-- checking for module 'mozjs185'
--   package 'mozjs185' not found
如往常,copy这个module的名字,然后
# yum search mozjs185
结果是Not Found (废话,如果不是not found,还写这个干啥...) 直接杀到网上找结果。

Code

warning: suggest parentheses around assignment used as truth value

使用C代码遍历获得内容的时候,我写了如下的代码

C
...
MYSQL_RES *mysqlres = mysql_store_result(&conn);
MYSQL_ROW row;
while(row = mysql_fetch_row(mysqlres))
{
....
}

然后gcc报warning

dbcon.cc:103:38: 
warning: suggest parentheses around assignment used as truth value [-Wparentheses]

Code

一个bug的fix记录:跨文件的追踪

某个C文件又添加一个新的头文件,rebuild这个工程,结果此C文件报错。

Bash
src/xxxx.c: In function ‘foo’:
src/xxxx.c:27:1: error: parameter ‘some_pp’ is initialized
src/xxxx.c:27:1: warning: initialization from incompatible pointer type [enabled by default]

Code

fix记录:注意返回值

sqlite3使用sqlite3_exec,原型如下:

C
int sqlite3_exec(
	sqlite3*,                                  /* An open database */
	const char *sql,                           /* SQL to be evaluated */
	int (*callback)(void*,int,char**,char**),  /* Callback function */
	void *,                                    /* 1st argument to callback */
	char **errmsg                              /* Error msg written here */
);

其中有个参数是callback类型的。查询到的数据放在callback中处理。

Code

error: file ‘/boot/grub2/locale/en.mo.gz’ not found

从fedora 17或者更早的时候开始,启动grub2,系统会弹出一行错误提示,然而在你迅雷不及掩耳盗铃之时,grub已经弹到了menu,直到某一天,区区利用虚拟机的暂停功能,终于看到了那行错误提示,上曰:

error: file '/boot/grub2/locale/en.mo.gz' not found

Redhat其实早就看到这错误了,Bug report一大坨,可惜到目前,fedora 18了都,还是要手工改。

Code

implicit declaration of function ‘xxx’

随手几行测试代码,编译居然报了一排warning,仔细查看,都是类似如下格式的:

Bash
xxx\xx.c||In function 'xxx':|
xxx\xx.c|14|warning: implicit declaration of function 'memset' [-Wimplicit-function-declaration]|
xxx\xx.c|14|warning: incompatible implicit declaration of built-in function 'memset' [enabled by default]|

Code

C语言写宏注意事项,一次debug的教训

现在有代码如下.

宏定义设置好:

C
#define ERROR_RET(x) error_code=x;return false;

然后期望在以后某处调用如下:

C
void fun()
{
    if(sth) ERROR_RET(eno);
    ....
}

编译护结果始终不理想.逻辑和想的不一样啊...查了别的代码好久,一直以为其它地方数据处理有问题.