The Crystal Programming Language Forum

Tracebacks in statically linked binaries?

Hello!

I’ve been trying to statically link my Crystal Discord bot so I can use a distroless Docker image, and it…mostly works. But the tracebacks look like this:

Unhandled exception: Errno: Error connecting to 'localhost:6379': Connection refused (Redis::CannotConnectError)
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???
  from ???

IOW, there’s no debugging information shown in the frames, but I definitely compiled with debug info enabled. Is there a trick to getting this to work? All I could find on Google was my old Alpine Linux static linking issue that’s unrelated (I’m already linking with libstdc++ for the mongo libraries), as well as someone asking this on IRC which was completely unresolved.

1 Like

Is that the full trace? Are you stripping your binaries?

Stack traces are empty on statically linked binaries :frowning:

From your issue: https://github.com/crystal-lang/crystal/issues/4276

…well I’ve failed myself :sob: Tried with -lunwind too again, still no luck. Was hoping it had improved by now, but alas it seems not…

Full trace, binaries have debug info and are not stripped.

What OS? If you run it in gdb can gdb show backtraces?

Linked on Alpine. If I run it in gdb it actually segfaults so I should add that to the mega-bug…

This is the kind of issues which I hope would make on the list for Crystal 1.0 release.

1.0 marks a point where breaking changes should stop happening. Fixing stack traces can happen before or after 1.0, it’s not related to breaking changes.

I totally agree. No breaking changes should happen in 1.x after 1.0 release.

OTOH if statically linked binaries considered a major use-case by hopefully a huge list of newcomers when Crystal is declared 1.0, then this issue with missing stack traces can be 1 additional point in cons list.

Of course I would put things like a reliable debugger higher on the list than this issue with statically linked binaries.

Anyways, it’s just my wishlist for things like debugger, monitoring and anything else that can help me to show that Crystal is reliable/safe enough to start new projects in it.Then one day I could use it in my job and not my pet projects.