From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Thu, 28 Apr 2011 11:26:27 +0200 (CEST) From: Mauro Salvini Message-ID: <3161507.241303982782859.JavaMail.SYSTEM@pc-msalvini> In-Reply-To: <27947354.221303982673109.JavaMail.SYSTEM@pc-msalvini> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_21_30682745.1303982782859" Subject: Re: [Xenomai-help] rt_task_join() call hangs in shared lib destructor List-Id: Help regarding installation and common use of Xenomai List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gilles Chanteperdrix Cc: xenomai@xenomai.org ------=_Part_21_30682745.1303982782859 Content-Type: multipart/alternative; boundary="----=_Part_22_20399973.1303982782859" ------=_Part_22_20399973.1303982782859 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit > It looks like a typical pthread_join deadlock. The thread you are > joining is locked on a pthread mutex, that some other thread (I would > say, the one calling pthread_join) has. It can not work. You should not > call pthread_join while holding a mutex. Yes, it looks like this, but I don't use any mutex in my task. It looks like dlclose() locks a mutex used also by pthread_join() (that was called into shared object destructor), and here is deadlock. But executing realtime task as normal thread does not raise this issue. Another strange behaviour: if task was not created with rt_task_create()-rt_task_start(), but becomes real time from a thread with rt_task_shadow(), it works properly. Summarizing: - create task with rt_task_create()-rt_task_start() and join it in shared object destructor with rt_task_join() -> deadlock - create a thread with pthread_create(), make it real-time with rt_task_shadow() and join it in destructor with rt_task_join() -> works fine - create a thread with pthread_create(), join it in destructor with pthread_join() -> works fine Same behaviors on kernel 2.6.37 with Xenomai 2.5.6 Ipipe 2.9-00 . > If this is not the issue, would you please take the time to post a > self-contained test case which I can run to reproduce the issue? Was attached on my first mail, I re-attach it to this mail. I also added 2nd and 3rd case explained above: you can select each case with three #defines into TestMod.c. Many thanks, regards. ------=_Part_22_20399973.1303982782859 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable <= div style=3D'font-family: Times New Roman; font-size: 12pt; color: #000000'= >
> It looks like a typical pthread_join deadlock. The thread you are<= br>> joining is locked on a pthread mutex, that some other thread (I wou= ld
> say, the one calling pthread_join) has. It can not work. You sho= uld not
> call pthread_join while holding a mutex.

Yes, it loo= ks like this, but I don't use any mutex in my task. It looks like dlclose()= locks a mutex used also by pthread_join() (that was called into shared obj= ect destructor), and here is deadlock. But executing realtime task as norma= l thread does not raise this issue.

Another strange behaviour: if ta= sk was not created with rt_task_create()-rt_task_start(), but becomes real = time from a thread with rt_task_shadow(), it works properly.

Summari= zing:
- create task with rt_task_create()-rt_task_start() and join it in= shared object destructor with rt_task_join() -> deadlock
- create a = thread with pthread_create(), make it real-time with rt_task_shadow() and j= oin it in destructor with rt_task_join() -> works fine
- create a thr= ead with pthread_create(), join it in destructor with pthread_join() -> works fine

Same behaviors on kernel 2.6.37 with Xenomai 2.5.6 Ipipe = 2.9-00.

> If this is not the issue, would you please take the tim= e to post a
> self-contained test case which I can run to reproduce t= he issue?

Was attached on my first mail, I re-attach it to this mail= . I also added 2nd and 3rd case explained above: you can select each case w= ith three #defines into TestMod.c.

Many thanks, regards.

------=_Part_22_20399973.1303982782859-- ------=_Part_21_30682745.1303982782859 Content-Type: application/x-zip-compressed; name=sample.zip Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename=sample.zip UEsDBBQAAAAIAA9anD6D1bBs+AAAAIgBAAANACYAc2FtcGxlL21haW4uY05VIgBOVUNYDQAAAHMA YQBtAHAAbABlAC8AbQBhAGkAbgAuAGMAdY1dS8MwFIavDeQ/HOpNVkanF175ATqnXnQblBZvhBJz MheWJiVJB0P976alyhh4d96P87yUnCsjdIcSbvzBz5qGm2x7R49sF3B3YqHeiNNaZ5QPOJiUKBOg 4coA6y/uPsQUxJa7NO3FfkLJJyVnjbZix7UGBst5Xs+rolisSvga1FNVVsUCJtex6ELdukiqeRds rYwK7LIPYrS3ClNoLL5wg1rCLaC2rYzLkGQzrd5L6cPSYuZtAlMoyvyxXq1f48hwPufrh/scRtjv zoYl8dNxd4CeJfHN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