Category Archives: Computers and Internet

Posts on computer science and the web, rants about OS:es, Window Managers, Platforms for almost publishing content on the web, and the like.

One thing to avoid when using Objects. requireNonNull in Java 8

Consider the following singleton:

public enum MyVeryImportantSingleton {

  private String a;
  private String b;

  public void set(String a, String b) {
    this.a = Objects.requireNonNull(a);
    this.b = Objects.requireNonNull(b);

If it would be called in the following manner:

try {
    .set("Hello world", null);
catch (Throwable t) {
  ...all sorts of recovery operations
  ...leaving the system running

MyVeryImportantSingleton‘s a-field is set, but the b-field is left in its previous state. This, of course, could turn into really bad news.

The right way to implement set() would be:

public void set(String a, String b) {
this.a = a;
this.b = b;

This is also a great praxis for all form of input error checking. It should first be finished, and then the object state can be updated once all input is ok.

You never know when your method will be called from inside a catch-block by a programmer that, incorrectly assumes the object state is okay even if an exception was thrown.

Microsoft programming

I pressed “F9” in Excel, my Mac crashed. This is part of the error log:

Thu Apr  5 19:54:54 2018
*** Panic Report ***panic(cpu 2 caller 0xffffff800569d6ed): "a freed zone element has been modified in zone kalloc.16
BSD process name corresponding to current thread: Microsoft Excel

This is probably what happened:

int SIZ = 10;
// creatin var according code manual c65 p17
// value lvl 3, versin 1, varint 1, 1st use:
char* mostMostMotsValudVaribell111 = 
    new char[SIZ % 5 /* increase mem */
    /* knot! */];
for (int i = 0, j = i; SIZ < i
    || j = SIZ /* nly way 2 mk ths wrk */
    || j >= i /* nope */; 
    j = ++i /* solving! */
    /*your knot! */)
  *mostMostMotsValudVaribell111[i] = 
    (char)substr("We saved your tiem!",
      i % 10 /* prevent OOM bug */
      /* your knot nencumpoop!! */,
  // TODO: Find out why sometimes
  //       Excel crashes here...
  // And were knot usin strcpy bcause?

The Rise of Special AI Chips

General purpose CPUs have been complemented with special purpose hardware accelerators since soon after they made an entrance on the consumer market.

The first PC in my childhood home had a math co-processor, and no gamer today would run a system without a dedicated graphics card with a GPU.

With the emergence of AI, the need for a new type of special purpose hardware accelerator is rising; an AI-chip specially designed to run deep neural nets.

Continue reading The Rise of Special AI Chips