comp.lang.ada
 help / color / mirror / Atom feed
* Ada DLL called from C
@ 2016-08-09 10:11 Dmitry A. Kazakov
  2016-08-09 16:18 ` Pascal Obry
  0 siblings, 1 reply; 6+ messages in thread
From: Dmitry A. Kazakov @ 2016-08-09 10:11 UTC (permalink / raw)


Does anyone use an Ada encapsulated library with C main?

I have a problem that under Windows (MinGW) initialization runs in 
deadlock in System.Tasking.Stages.Activate_Tasks when attempting 
Lock_RTS. It seems that the critical section is already taken.

Under Linux initialization runs OK.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Ada DLL called from C
  2016-08-09 10:11 Ada DLL called from C Dmitry A. Kazakov
@ 2016-08-09 16:18 ` Pascal Obry
  2016-08-09 16:29   ` Dmitry A. Kazakov
  0 siblings, 1 reply; 6+ messages in thread
From: Pascal Obry @ 2016-08-09 16:18 UTC (permalink / raw)


Le mardi 09 août 2016 à 12:11 +0200, Dmitry A. Kazakov a écrit :
> Does anyone use an Ada encapsulated library with C main?
> 
> I have a problem that under Windows (MinGW) initialization runs in 
> deadlock in System.Tasking.Stages.Activate_Tasks when attempting 
> Lock_RTS. It seems that the critical section is already taken.

You can't have a task (threads) created during the DLL activation. This
is a Windows limitation.

-- 
  Pascal Obry /  Magny Les Hameaux (78)

  The best way to travel is by means of imagination

  http://www.obry.net

  gpg --keyserver keys.gnupg.net --recv-key F949BD3B

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Ada DLL called from C
  2016-08-09 16:18 ` Pascal Obry
@ 2016-08-09 16:29   ` Dmitry A. Kazakov
  2016-08-09 16:45     ` Pascal Obry
  0 siblings, 1 reply; 6+ messages in thread
From: Dmitry A. Kazakov @ 2016-08-09 16:29 UTC (permalink / raw)


On 2016-08-09 18:18, Pascal Obry wrote:
> Le mardi 09 août 2016 à 12:11 +0200, Dmitry A. Kazakov a écrit :
>> Does anyone use an Ada encapsulated library with C main?
>>
>> I have a problem that under Windows (MinGW) initialization runs in
>> deadlock in System.Tasking.Stages.Activate_Tasks when attempting
>> Lock_RTS. It seems that the critical section is already taken.
>
> You can't have a task (threads) created during the DLL activation. This
> is a Windows limitation.

You mean a DLL may not have library-level tasks? I was not aware of 
this, but that could be the reason indeed. I have some library-level tasks.

1. Do you know the reason why?

2. Why binder does not warn me about that? It is a statically detectable 
case.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Ada DLL called from C
  2016-08-09 16:29   ` Dmitry A. Kazakov
@ 2016-08-09 16:45     ` Pascal Obry
  2016-08-09 17:05       ` Pascal Obry
  2016-08-09 17:15       ` Dmitry A. Kazakov
  0 siblings, 2 replies; 6+ messages in thread
From: Pascal Obry @ 2016-08-09 16:45 UTC (permalink / raw)


Le mardi 09 août 2016 à 18:29 +0200, Dmitry A. Kazakov a écrit :
> You mean a DLL may not have library-level tasks? I was not aware of 
> this, but that could be the reason indeed. I have some library-level
> tasks.

A DLL cannot create tasks during its initialization indeed. This means
that you cannot create task in DllMain entry point. So a DLL cannot
have a library level task. You can use an access to task and initialize
it later.

> 1. Do you know the reason why?

I don't know, that's just a plain limitation of Windows. Nothing to do
with GNAT.

> 2. Why binder does not warn me about that? It is a statically
> detectable case.

The binder does not know you're building a task, does it?

-- 
  Pascal Obry /  Magny Les Hameaux (78)

  The best way to travel is by means of imagination

  http://www.obry.net

  gpg --keyserver keys.gnupg.net --recv-key F949BD3B

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Ada DLL called from C
  2016-08-09 16:45     ` Pascal Obry
@ 2016-08-09 17:05       ` Pascal Obry
  2016-08-09 17:15       ` Dmitry A. Kazakov
  1 sibling, 0 replies; 6+ messages in thread
From: Pascal Obry @ 2016-08-09 17:05 UTC (permalink / raw)


Le mardi 09 août 2016 à 18:45 +0200, Pascal Obry a écrit :
> The binder does not know you're building a task, does it?

I meant "building a DLL" above of course!

-- 
  Pascal Obry /  Magny Les Hameaux (78)

  The best way to travel is by means of imagination

  http://www.obry.net

  gpg --keyserver keys.gnupg.net --recv-key F949BD3B


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Ada DLL called from C
  2016-08-09 16:45     ` Pascal Obry
  2016-08-09 17:05       ` Pascal Obry
@ 2016-08-09 17:15       ` Dmitry A. Kazakov
  1 sibling, 0 replies; 6+ messages in thread
From: Dmitry A. Kazakov @ 2016-08-09 17:15 UTC (permalink / raw)


On 2016-08-09 18:45, Pascal Obry wrote:
> Le mardi 09 août 2016 à 18:29 +0200, Dmitry A. Kazakov a écrit :
>> You mean a DLL may not have library-level tasks? I was not aware of
>> this, but that could be the reason indeed. I have some library-level
>> tasks.
>
> A DLL cannot create tasks during its initialization indeed. This means
> that you cannot create task in DllMain entry point. So a DLL cannot
> have a library level task. You can use an access to task and initialize
> it later.
>
>> 1. Do you know the reason why?
>
> I don't know, that's just a plain limitation of Windows. Nothing to do
> with GNAT.

Well, under Windows you cannot create threads while in DllMain. More 
precisely you can, but the thread will not be activated until you leave 
DllMain. It is not a limitation that Ada RTS could not work around. But 
it looks that it does not.

>> 2. Why binder does not warn me about that? It is a statically
>> detectable case.
>
> The binder does not know you're building a task, does it?

It should know I am building a DLL. At least gprbuild knows that and it 
can pass the information further.

Thank you for the hint! You've saved me weeks of struggling with GDB.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-08-09 17:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-09 10:11 Ada DLL called from C Dmitry A. Kazakov
2016-08-09 16:18 ` Pascal Obry
2016-08-09 16:29   ` Dmitry A. Kazakov
2016-08-09 16:45     ` Pascal Obry
2016-08-09 17:05       ` Pascal Obry
2016-08-09 17:15       ` Dmitry A. Kazakov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox