On 2019/02/03 22:49, Mikolaj Kucharski wrote: > Hi Stuart, > > On Fri, Feb 01, 2019 at 11:39:09PM +0000, Stuart Henderson wrote: > > +cc maintainer > > Thanks, I should include Frederic in my initial email. > > > It feels like bugs on the calcurse side to me. > > > > First problem - program calls notify_start_main_thread to start the > > notify thread. First thing this does is try to cancel any existing > > notify thread by calling notify_stop_main_thread - on an OS where > > pthread_t is just an identifier this would be a noop because there's a > > "is not null" check, but on OpenBSD pthread_t is a struct so this is > > never null, so it always tries to stop a (nonexistent) thread at first. > > This doesn't cause a crash but it is wrong to try to stop a thread that > > hasn't been started yet. > > > > Second problem - when you read help, first it stops the thread, then > > it calls notify_start_main_thread to try to start it again, but again > > (and this time I believe it will be the same on other OS too) it > > tries to pthread_cancel/pthread_join the thread which it already > > stopped. And this is where it goes boom on OpenBSD because pthread_cancel > > tries to dereference a pointer that has already been freed. > > > > Not sure if this is a *good* diff but it does avoid the crash and > > I don't think it's too terrible. > > > > Any comments/OKs? > > Your diff makes sense to me and it does make the crash go away. I've > looked after your email to upstream repo and found they also fix the > problem already in a slightly different way: > > https://git.calcurse.org/calcurse.git/commit/src/notify.c?id=30f411257ad3bc233184c08b846a2980a9c5d1f0 > > I've decided to redo OpenBSD ports diff with upstream's commit included. > Comments, OKs?
I've committed it, as this is quite an annoying bug. I see there are a number of other commits upstream fixing other thread/mutex related issues, segfaults, etc, but no newer release upstream yet.
