Cobalt Preemption of kernel update_fast_timekeeper can cause deadlocks

Lange Norbert norbert.lange at
Fri Dec 21 14:31:13 CET 2018

> >>
> >> If you are calling into an "unknown" non-RT blob, dropping from RT
> >> may actually be required. We do not promote explicit mode switches
> >> because they are not needed if you control (wrap) all your code. This
> >> might be  an exception.
> >
> > The non-RT "blob" is the regular linux rootfs in my case, ie.
> > libstdc++ and I plan to use libnttg-ust and stuff like xml parsers.
> That's all fine - as long as you are not in RT context.

To make sure I am not in RT Context needs alot knowledge of callstacks.
Easy to do if you create the code from scratch, not so easy if you are porting.

> Actually, if you use a SCHED_WEAK thread for calling into both RT and non-
> RT, you will not have to do the explicit switching because those threads fall
> back to non-RT as soon as they have no RT business (lock ownership or
> blocking) anymore, and then you are safe.

Thanks for clearing up another misunderstanding.

> >>
> >>
> >> Irrespective of that, I would definitely be interested in a
> >> LD_PRELOAD-based checker that you can attach to an application
> >> easily, without the need to switch to link-time wrapping (which is not
> needed with non-posix skins).
> >
> > If you don’t know lttng-ust, you could spend a hour or two playing
> > with it, Eg you can interpose and trace any malloc/free by just preloading
> the wrapper:
> > LD_PRELOAD=liblttng-ust-libc-wrapper your_app
> >
> > This could help with non-posix skins mixing with dangerous other functions
> aswell.
> It takes more than that if you look at how we decide whether to raise an
> alarm or not (context detection, warning flag evaluation, signal raising). lttng-
> ust can be a nice tracing tool, but for a runtime equivalent to --mode-check, I
> would rather set up a tool that behaves like the link-time version.

It does not take a lot, I had a stab at writing a preload checker for clock_gettime that bugged me a long time (most time was spent figuring out I have to enable PTHREAD_WARNSW for anything to happen).
Most function could be done similarly. Malloc/free are tricky as the dl loading might call those functions,
Packages like lttng already solved those issues, which was the point I was trying to make.

With such checkers you can find issues related to external DSOs, something the linker tricks won't be able to.


This message and any attachments are solely for the use of the intended recipients. They may contain privileged and/or confidential information or other information protected from disclosure. If you are not an intended recipient, you are hereby notified that you received this email in error and that any review, dissemination, distribution or copying of this email and any attachment is strictly prohibited. If you have received this email in error, please contact the sender and delete the message and any attachment from your system.


Rechtsform/ Legal form: Gesellschaft mit beschränkter Haftung / Corporation

Firmensitz/ Registered seat: Wien

Firmenbuchgericht/ Court of registry: Handelsgericht Wien

Firmenbuchnummer/ Company registration: FN 61833 g

DVR: 0605077

UID-Nr.: ATU14756806

Thank You
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cobalt_preload_helper.c
URL: <>

More information about the Xenomai mailing list