How to create a bug #1

We all need to learn how to create bugs, otherwise software development and engineering becomes way to boring.

I needed to update a Rust library to support vcpkg in manifest mode. I found that the library hasn't been maintained for over 3 years. It still works fine if you use vcpkg in classic mode, but that's not what I needed. So I forked the repo and created a release that supports vcpkg in manifest mode.

I discovered a small bug, that is want a crate is using vcpkg in manifest mode it got the path to the vcpkg_installed directory wrong. That is not the bug I want to talk about, and the fix was easy. I just needed to canonicalise the path. https://doc.rust-lang.org/stable/std/fs/fn.canonicalize.html

The documentation already spoils it, but I did not give it a good read:

On Windows, this converts the path to use extended length path syntax, which allows your program to use longer path names, but means you can only join backslash-delimited paths to it, and it may be incompatible with other applications (if passed to the application on the command-line, or written to a file another application may read).

The key thing: It only supports backslash-delimited paths. Now, when I had made this change everything worked, except on Windows. I got the weirdest errors, and I worked around it. But then I realised: It looks like Windows doesn't support forward slashes anymore. Most c/c++ source code use includes like 'library/lib.h' which the compiler just appends to the paths it has gotten.

Ta-da, this is how you create bugs! Now, the resolution it to use https://docs.rs/dunce/latest/dunce/fn.canonicalize.html instead, and scold at Rust for picking a highly incompatible path for Windows by default. Some Microsoft programs don't support it properly either.


要查看或添加评论,请登录

Patrick Vollebregt的更多文章

  • When to use CDKTF instead of regular Terraform HCL

    When to use CDKTF instead of regular Terraform HCL

    Terraform is an awesome product in the infrastructure as code space. It is provider agnostic, declarative and works…

  • X509CertBuddy: Kotlin port lessons learned

    X509CertBuddy: Kotlin port lessons learned

    I have been working on porting the x509CertBuddy plugin from Java to Kotlin. I got bitten by a nasty bug.

  • Snowflake

    Snowflake

    Snowflake is a dependency free implementation of the Snowflake ID algorithm in Go. Snowflake ID is a unique ID…

  • Energietransitie & EV's: Onze Rol en Toekomstige Kansen ???

    Energietransitie & EV's: Onze Rol en Toekomstige Kansen ???

    Afgelopen 16 maanden had ik de eer om bij Shell aan de ontwikkeling van een API te werken die essentieel is voor de…

    1 条评论
  • Inspect certs with X.509 Cert Buddy

    Inspect certs with X.509 Cert Buddy

    When working on #iso15118 related software I noticed that I had to manage a lot of X.509 #certificates.

    3 条评论
  • Kubernetes disaster recovery met Kubespray

    Kubernetes disaster recovery met Kubespray

    Ik heb zitten spelen met Kubespray voor het deployen van een Kubernetes cluster en ik probeerde wat disaster recovery…

  • Corona-app, we kunnen het ook niet doen...

    Corona-app, we kunnen het ook niet doen...

    Mijn grootste angst op IT gebied op dit moment is wel de Corona-app. Als een op blockchain gebaseerde oplossing, waar…

    2 条评论
  • Concurrency

    Concurrency

    Ongeveer 35 fortnights geleden beloofde ik dieper in te gaan op concurrency. Voor diegenen die op het puntje van hun…

    2 条评论
  • Go go go! (golang)

    Go go go! (golang)

    Go is een programmeertaal dat is ontwikkeld door Google. Er zitten twee mannen achter met een geschiedenis in…

社区洞察

其他会员也浏览了