diff mbox

[RFC] nptl_db/db_info: fix the incorrect initial size for dtvp

Message ID 1437399237-23720-1-git-send-email-zhengjunling@huawei.com
State New
Headers show

Commit Message

Zheng Junling July 20, 2015, 1:33 p.m. UTC
When debugging a program on ARMv7 with thread-local storage declared using
"__thread", attempting to print a thread-local variable will result in the
following message:

Cannot find thread-local storage for Thread <snip> (LWP <snip>), executable
file /tmp/tls: capability not available

This can be traced back to uclibc libpthread/nptl_db/td_thr_tls_get_addr.c
which gdb uses to look up the address of the TLS. The function returns
TD_NOCAPAB due to a mismatch in size between the DTV pointer and the size
recorded in the db description. The problem lies in libpthread/nptl_db/db_info.c
which initializes the db with the sizeof the union dtv. Instead it should
be the sizeof a pointer to union dtv.

Fixed the initial size for dtvp to sizeof a pointer, instead of sizeof
the union.

Refer to:
http://sourceware.org/ml/libc-alpha/2006-10/msg00088.html
https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=416b630981788c1f08e746e19765aa0e5c2a1360

Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
---
 libpthread/nptl_db/db_info.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Zheng Junling July 31, 2015, 10:37 a.m. UTC | #1
Ping...

On 2015/7/20 21:33, Junling Zheng wrote:
> When debugging a program on ARMv7 with thread-local storage declared using
> "__thread", attempting to print a thread-local variable will result in the
> following message:
> 
> Cannot find thread-local storage for Thread <snip> (LWP <snip>), executable
> file /tmp/tls: capability not available
> 
> This can be traced back to uclibc libpthread/nptl_db/td_thr_tls_get_addr.c
> which gdb uses to look up the address of the TLS. The function returns
> TD_NOCAPAB due to a mismatch in size between the DTV pointer and the size
> recorded in the db description. The problem lies in libpthread/nptl_db/db_info.c
> which initializes the db with the sizeof the union dtv. Instead it should
> be the sizeof a pointer to union dtv.
> 
> Fixed the initial size for dtvp to sizeof a pointer, instead of sizeof
> the union.
> 
> Refer to:
> http://sourceware.org/ml/libc-alpha/2006-10/msg00088.html
> https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=416b630981788c1f08e746e19765aa0e5c2a1360
> 
> Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
> ---
>  libpthread/nptl_db/db_info.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libpthread/nptl_db/db_info.c b/libpthread/nptl_db/db_info.c
> index a57a053..159a027 100644
> --- a/libpthread/nptl_db/db_info.c
> +++ b/libpthread/nptl_db/db_info.c
> @@ -60,7 +60,7 @@ extern bool __nptl_initial_report_events;
>     i.e. at the very end of the area covered by TLS_PRE_TCB_SIZE.  */
>  DESC (_thread_db_pthread_dtvp,
>        TLS_PRE_TCB_SIZE + offsetof (tcbhead_t, dtv)
> -      - (TLS_TCB_SIZE == 0 ? sizeof (tcbhead_t) : 0), union dtv)
> +      - (TLS_TCB_SIZE == 0 ? sizeof (tcbhead_t) : 0), union dtv *)
>  #endif
>  
>  
>
Zheng Junling Aug. 7, 2015, 2:28 a.m. UTC | #2
Ping again...

This patch fixed the following issue:
http://lists.uclibc.org/pipermail/uclibc/2015-May/048966.html

Does anybody suffer this problem ?

On 2015/7/31 18:37, Junling Zheng wrote:
> Ping...
> 
> On 2015/7/20 21:33, Junling Zheng wrote:
>> When debugging a program on ARMv7 with thread-local storage declared using
>> "__thread", attempting to print a thread-local variable will result in the
>> following message:
>>
>> Cannot find thread-local storage for Thread <snip> (LWP <snip>), executable
>> file /tmp/tls: capability not available
>>
>> This can be traced back to uclibc libpthread/nptl_db/td_thr_tls_get_addr.c
>> which gdb uses to look up the address of the TLS. The function returns
>> TD_NOCAPAB due to a mismatch in size between the DTV pointer and the size
>> recorded in the db description. The problem lies in libpthread/nptl_db/db_info.c
>> which initializes the db with the sizeof the union dtv. Instead it should
>> be the sizeof a pointer to union dtv.
>>
>> Fixed the initial size for dtvp to sizeof a pointer, instead of sizeof
>> the union.
>>
>> Refer to:
>> http://sourceware.org/ml/libc-alpha/2006-10/msg00088.html
>> https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=416b630981788c1f08e746e19765aa0e5c2a1360
>>
>> Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
>> ---
>>  libpthread/nptl_db/db_info.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libpthread/nptl_db/db_info.c b/libpthread/nptl_db/db_info.c
>> index a57a053..159a027 100644
>> --- a/libpthread/nptl_db/db_info.c
>> +++ b/libpthread/nptl_db/db_info.c
>> @@ -60,7 +60,7 @@ extern bool __nptl_initial_report_events;
>>     i.e. at the very end of the area covered by TLS_PRE_TCB_SIZE.  */
>>  DESC (_thread_db_pthread_dtvp,
>>        TLS_PRE_TCB_SIZE + offsetof (tcbhead_t, dtv)
>> -      - (TLS_TCB_SIZE == 0 ? sizeof (tcbhead_t) : 0), union dtv)
>> +      - (TLS_TCB_SIZE == 0 ? sizeof (tcbhead_t) : 0), union dtv *)
>>  #endif
>>  
>>  
>>
> 
> 
> _______________________________________________
> uClibc mailing list
> uClibc@uclibc.org
> http://lists.busybox.net/mailman/listinfo/uclibc
> 
>
Bernhard Reutner-Fischer Aug. 8, 2015, 8:03 a.m. UTC | #3
On August 7, 2015 4:28:10 AM GMT+02:00, Junling Zheng <zhengjunling@huawei.com> wrote:
>Ping again...

Sorry for the delay, will apply the outstanding patches this weekend.

Cheers,
>
>This patch fixed the following issue:
>http://lists.uclibc.org/pipermail/uclibc/2015-May/048966.html
>
>Does anybody suffer this problem ?
>
>On 2015/7/31 18:37, Junling Zheng wrote:
>> Ping...
>> 
>> On 2015/7/20 21:33, Junling Zheng wrote:
>>> When debugging a program on ARMv7 with thread-local storage declared
>using
>>> "__thread", attempting to print a thread-local variable will result
>in the
>>> following message:
>>>
>>> Cannot find thread-local storage for Thread <snip> (LWP <snip>),
>executable
>>> file /tmp/tls: capability not available
>>>
>>> This can be traced back to uclibc
>libpthread/nptl_db/td_thr_tls_get_addr.c
>>> which gdb uses to look up the address of the TLS. The function
>returns
>>> TD_NOCAPAB due to a mismatch in size between the DTV pointer and the
>size
>>> recorded in the db description. The problem lies in
>libpthread/nptl_db/db_info.c
>>> which initializes the db with the sizeof the union dtv. Instead it
>should
>>> be the sizeof a pointer to union dtv.
>>>
>>> Fixed the initial size for dtvp to sizeof a pointer, instead of
>sizeof
>>> the union.
>>>
>>> Refer to:
>>> http://sourceware.org/ml/libc-alpha/2006-10/msg00088.html
>>>
>https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=416b630981788c1f08e746e19765aa0e5c2a1360
>>>
>>> Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
>>> ---
>>>  libpthread/nptl_db/db_info.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/libpthread/nptl_db/db_info.c
>b/libpthread/nptl_db/db_info.c
>>> index a57a053..159a027 100644
>>> --- a/libpthread/nptl_db/db_info.c
>>> +++ b/libpthread/nptl_db/db_info.c
>>> @@ -60,7 +60,7 @@ extern bool __nptl_initial_report_events;
>>>     i.e. at the very end of the area covered by TLS_PRE_TCB_SIZE. 
>*/
>>>  DESC (_thread_db_pthread_dtvp,
>>>        TLS_PRE_TCB_SIZE + offsetof (tcbhead_t, dtv)
>>> -      - (TLS_TCB_SIZE == 0 ? sizeof (tcbhead_t) : 0), union dtv)
>>> +      - (TLS_TCB_SIZE == 0 ? sizeof (tcbhead_t) : 0), union dtv *)
>>>  #endif
>>>  
>>>  
>>>
>> 
>> 
>> _______________________________________________
>> uClibc mailing list
>> uClibc@uclibc.org
>> http://lists.busybox.net/mailman/listinfo/uclibc
>> 
>> 
>
>
>_______________________________________________
>uClibc mailing list
>uClibc@uclibc.org
>http://lists.busybox.net/mailman/listinfo/uclibc
Zheng Junling Sept. 21, 2015, 1:53 a.m. UTC | #4
On 2015/8/8 16:03, Bernhard Reutner-Fischer wrote:
> On August 7, 2015 4:28:10 AM GMT+02:00, Junling Zheng <zhengjunling@huawei.com> wrote:
>> Ping again...
> 
> Sorry for the delay, will apply the outstanding patches this weekend.

Hi, Bernhard

I found that uclibc-ng had already contained this fix.

Should it be applied into uClibc?

Thanks

Junling

> 
> Cheers,
>>
>> This patch fixed the following issue:
>> http://lists.uclibc.org/pipermail/uclibc/2015-May/048966.html
>>
>> Does anybody suffer this problem ?
>>
>> On 2015/7/31 18:37, Junling Zheng wrote:
>>> Ping...
>>>
>>> On 2015/7/20 21:33, Junling Zheng wrote:
>>>> When debugging a program on ARMv7 with thread-local storage declared
>> using
>>>> "__thread", attempting to print a thread-local variable will result
>> in the
>>>> following message:
>>>>
>>>> Cannot find thread-local storage for Thread <snip> (LWP <snip>),
>> executable
>>>> file /tmp/tls: capability not available
>>>>
>>>> This can be traced back to uclibc
>> libpthread/nptl_db/td_thr_tls_get_addr.c
>>>> which gdb uses to look up the address of the TLS. The function
>> returns
>>>> TD_NOCAPAB due to a mismatch in size between the DTV pointer and the
>> size
>>>> recorded in the db description. The problem lies in
>> libpthread/nptl_db/db_info.c
>>>> which initializes the db with the sizeof the union dtv. Instead it
>> should
>>>> be the sizeof a pointer to union dtv.
>>>>
>>>> Fixed the initial size for dtvp to sizeof a pointer, instead of
>> sizeof
>>>> the union.
>>>>
>>>> Refer to:
>>>> http://sourceware.org/ml/libc-alpha/2006-10/msg00088.html
>>>>
>> https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=416b630981788c1f08e746e19765aa0e5c2a1360
>>>>
>>>> Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
>>>> ---
>>>>  libpthread/nptl_db/db_info.c | 2 +-
>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/libpthread/nptl_db/db_info.c
>> b/libpthread/nptl_db/db_info.c
>>>> index a57a053..159a027 100644
>>>> --- a/libpthread/nptl_db/db_info.c
>>>> +++ b/libpthread/nptl_db/db_info.c
>>>> @@ -60,7 +60,7 @@ extern bool __nptl_initial_report_events;
>>>>     i.e. at the very end of the area covered by TLS_PRE_TCB_SIZE. 
>> */
>>>>  DESC (_thread_db_pthread_dtvp,
>>>>        TLS_PRE_TCB_SIZE + offsetof (tcbhead_t, dtv)
>>>> -      - (TLS_TCB_SIZE == 0 ? sizeof (tcbhead_t) : 0), union dtv)
>>>> +      - (TLS_TCB_SIZE == 0 ? sizeof (tcbhead_t) : 0), union dtv *)
>>>>  #endif
>>>>  
>>>>  
>>>>
>>>
>>>
>>> _______________________________________________
>>> uClibc mailing list
>>> uClibc@uclibc.org
>>> http://lists.busybox.net/mailman/listinfo/uclibc
>>>
>>>
>>
>>
>> _______________________________________________
>> uClibc mailing list
>> uClibc@uclibc.org
>> http://lists.busybox.net/mailman/listinfo/uclibc
> 
> 
> 
> .
>
Zheng Junling Dec. 23, 2015, 1:53 a.m. UTC | #5
Ping again...:(

On 2015/9/21 9:53, Junling Zheng wrote:
> On 2015/8/8 16:03, Bernhard Reutner-Fischer wrote:
>> On August 7, 2015 4:28:10 AM GMT+02:00, Junling Zheng <zhengjunling@huawei.com> wrote:
>>> Ping again...
>>
>> Sorry for the delay, will apply the outstanding patches this weekend.
> 
> Hi, Bernhard
> 
> I found that uclibc-ng had already contained this fix.
> 
> Should it be applied into uClibc?
> 
> Thanks
> 
> Junling
> 
>>
>> Cheers,
>>>
>>> This patch fixed the following issue:
>>> http://lists.uclibc.org/pipermail/uclibc/2015-May/048966.html
>>>
>>> Does anybody suffer this problem ?
>>>
>>> On 2015/7/31 18:37, Junling Zheng wrote:
>>>> Ping...
>>>>
>>>> On 2015/7/20 21:33, Junling Zheng wrote:
>>>>> When debugging a program on ARMv7 with thread-local storage declared
>>> using
>>>>> "__thread", attempting to print a thread-local variable will result
>>> in the
>>>>> following message:
>>>>>
>>>>> Cannot find thread-local storage for Thread <snip> (LWP <snip>),
>>> executable
>>>>> file /tmp/tls: capability not available
>>>>>
>>>>> This can be traced back to uclibc
>>> libpthread/nptl_db/td_thr_tls_get_addr.c
>>>>> which gdb uses to look up the address of the TLS. The function
>>> returns
>>>>> TD_NOCAPAB due to a mismatch in size between the DTV pointer and the
>>> size
>>>>> recorded in the db description. The problem lies in
>>> libpthread/nptl_db/db_info.c
>>>>> which initializes the db with the sizeof the union dtv. Instead it
>>> should
>>>>> be the sizeof a pointer to union dtv.
>>>>>
>>>>> Fixed the initial size for dtvp to sizeof a pointer, instead of
>>> sizeof
>>>>> the union.
>>>>>
>>>>> Refer to:
>>>>> http://sourceware.org/ml/libc-alpha/2006-10/msg00088.html
>>>>>
>>> https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=416b630981788c1f08e746e19765aa0e5c2a1360
>>>>>
>>>>> Signed-off-by: Junling Zheng <zhengjunling@huawei.com>
>>>>> ---
>>>>>  libpthread/nptl_db/db_info.c | 2 +-
>>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/libpthread/nptl_db/db_info.c
>>> b/libpthread/nptl_db/db_info.c
>>>>> index a57a053..159a027 100644
>>>>> --- a/libpthread/nptl_db/db_info.c
>>>>> +++ b/libpthread/nptl_db/db_info.c
>>>>> @@ -60,7 +60,7 @@ extern bool __nptl_initial_report_events;
>>>>>     i.e. at the very end of the area covered by TLS_PRE_TCB_SIZE. 
>>> */
>>>>>  DESC (_thread_db_pthread_dtvp,
>>>>>        TLS_PRE_TCB_SIZE + offsetof (tcbhead_t, dtv)
>>>>> -      - (TLS_TCB_SIZE == 0 ? sizeof (tcbhead_t) : 0), union dtv)
>>>>> +      - (TLS_TCB_SIZE == 0 ? sizeof (tcbhead_t) : 0), union dtv *)
>>>>>  #endif
>>>>>  
>>>>>  
>>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> uClibc mailing list
>>>> uClibc@uclibc.org
>>>> http://lists.busybox.net/mailman/listinfo/uclibc
>>>>
>>>>
>>>
>>>
>>> _______________________________________________
>>> uClibc mailing list
>>> uClibc@uclibc.org
>>> http://lists.busybox.net/mailman/listinfo/uclibc
>>
>>
>>
>> .
>>
> 
> 
> _______________________________________________
> uClibc mailing list
> uClibc@uclibc.org
> http://lists.busybox.net/mailman/listinfo/uclibc
> 
>
diff mbox

Patch

diff --git a/libpthread/nptl_db/db_info.c b/libpthread/nptl_db/db_info.c
index a57a053..159a027 100644
--- a/libpthread/nptl_db/db_info.c
+++ b/libpthread/nptl_db/db_info.c
@@ -60,7 +60,7 @@  extern bool __nptl_initial_report_events;
    i.e. at the very end of the area covered by TLS_PRE_TCB_SIZE.  */
 DESC (_thread_db_pthread_dtvp,
       TLS_PRE_TCB_SIZE + offsetof (tcbhead_t, dtv)
-      - (TLS_TCB_SIZE == 0 ? sizeof (tcbhead_t) : 0), union dtv)
+      - (TLS_TCB_SIZE == 0 ? sizeof (tcbhead_t) : 0), union dtv *)
 #endif