fosstodon.org is one of the many independent Mastodon servers you can use to participate in the fediverse.
Fosstodon is an invite only Mastodon instance that is open to those who are interested in technology; particularly free & open source software. If you wish to join, contact us for an invite.

Administered by:

Server stats:

11K
active users

mattst88 :gentoo:

Another fun adventure, this time with a happy ending.

A unit test in libXmu failed on x86-32 (gitlab.freedesktop.org/xorg/li). I looked for the typical things first like bad casts but didn't see anything wrong.

I noticed that the unit test program runs two subtests and the log indicates that it completed the first successfully before crashing, but when I ran it under gdb the back trace showed it in the first unit test when the segfault occurred. Very strange.

GitLabStrToShap test fails on x86-32 (#2) · Issues · xorg / lib / libXmu · GitLabDownstream bug: https://bugs.gentoo.org/928419 test/StrToShap.log shows: TAP...

Single stepping in , I ultimately came across a longjmp() call (apparently libXt handles errors this way?), and it was this call that triggered the failure.

Turns out each of the subtests checks some exceptional case and expects a function call to fail by longjmp()'ing, but only the first unit test actually prepared for the jump with a call to setjmp().

As a result, when the second subtest triggered its own longjmp() it jumped to the first subtest's function that had already completed!

@mattst88 I wish I knew the official way to clear the jmpenv before exiting the function makes it invalid so that this would have been a crash at the longjmp() instead of a corrupted stack, but I've not found one documented yet.

@alanc @mattst88 I bet memset would go a long ways 😉

@keithp @mattst88 yeah, that was what I'd suggested in the bug report Matt linked above as the best answer I could think of, but it still seems like a missing API (or at least missing documentation if memset is the right way).

@alanc @mattst88 Hrm. Seems like longjmp "consumes" the setjmp value, so a useful change to its implementation would be to mutate it so it cannot be re-used.

@keithp @alanc: That sounds like a very good idea.