badssl.com

Today I discovered badssl.com, a very useful website to test various exceptional TLS/SSL cases. E.g., I tested what will happen if client supports TLS 1.3 only while server supports TLS 1.2 only:

# openssl s_client -connect tls-v1-2.badssl.com:1012 -tls1_3
CONNECTED(00000005)
01000000:error:0A000410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure:ssl/record/rec_layer_s3.c:1584:SSL alert number 40
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 7 bytes and written 253 bytes
Verification: OK
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
Early data was not sent
Verify return code: 0 (ok)
---

The gotcha of logging gdb output

By default, gdb‘s output file is appended, not overwrote. E.g: debug the same program for 2 times:

$ gdb foo
......
(gdb) set logging on
Copying output to gdb.txt.
Copying debug output to gdb.txt.
(gdb) r
......
$ ll gdb.txt
-rw-rw-r-- 1 nanxiao nanxiao 1067 Jul  9 18:06 gdb.txt
$ gdb foo
......
(gdb) set logging on
Copying output to gdb.txt.
Copying debug output to gdb.txt.
(gdb) r
......
$ ll gdb.txt
-rw-rw-r-- 1 nanxiao nanxiao 2134 Jul  9 18:08 gdb.txt

After second debug, the gdb.txt‘s size is doubled. To overwrite the output file, execute set logging overwrite on before set logging on:

$ gdb foo
......
(gdb) set logging overwrite on
(gdb) set logging on
Copying output to gdb.txt.
Copying debug output to gdb.txt.
(gdb) r
......
$ ll gdb.txt
-rw-rw-r-- 1 nanxiao nanxiao 1067 Jul  9 18:10 gdb.txt

A trick of setting breakpoint in pdb

When using pdb to debug a python program:

python -m pdb foo.py

I want to set a breakpoint, but meet following error:

(Pdb) b bar.py:46
*** 'bar.py' not found from sys.path

A small trick is setting breakpoint in main first and run the program:

(Pdb) b main
Breakpoint 1 at ......
(Pdb) r
......

After breakpoint set for main is hit, set breakpoint again at bar.py:46. This time it should work:

(Pdb) b bar.py:46
Breakpoint 2 at ......

How I improved myself in 2014

I graduated from school in 2008, and my first job is an embedded software engineer. After working for more than 2 years, I joined in another traditional telecommunication company (let me use A to stand for it). Fast forward to 2014, the business of A company seemed stagnated for a while: more and more people began to use OTT applications from the second decade of 21th century, and it was a big hurt to telecommunication companies like A. Though I still had salary increase every year, the amount can be ignored. But the good thing is A company has good work-life-balance culture. Besides that, my daily work is:
a) Add new trivial features for one system which is written in C and run on Solaris 10.
b) Answer technical questions which support engineers don’t know about.
Since I had been very familiar with the stuff I was in charge of, I knew I could not absorb new knowledge from A company, so I did following things to improve myself in 2014:

(1) Read English technical articles.
Yes, before 2014, I had mostly used Chinese key words to search related technical posts and read them. After switching to English, I am exposed to another world which has plentiful resource for me to explore.

(2) Write English blog.
I realised that if I just write Chinese articles, only the people who know Chinese can understand them. But if I record my thoughts in English, the people around the world can read them. Believe it or not, my current employer even referred one of my blog post before I became its employee.

(3) Learn git.
A company still used svn in 2014, and it was enough for our development procedure. But I knew git is the trend. I still remember I read Pro git and practised the commands from the book in a server; Pro git is the best tutorial of git until now.

(4) Study Go.
Go became popular in 2014, and the market for C developer began to shrink. The reason for me to learn Go is simple: hope to secure my future career. I even spent lot of time in trying to run Go on Solaris, but no success. The irony is until this year (2022), I am still a full-time C developer and never got a Go job.

On top of the above things, I also did others: wrote some DTrace tutorials in Chinese, joined some IRC chat rooms to learn English, etc. All in all, I learnt a lot of new things in 2014.

Not every software engineer can work in leading companies which have advanced technologies and did cool things, but everyone can improve himself/herself by self-learning. Hope my story can give others inspiration.