<?xml version="1.0" encoding="UTF-8" ?>

<bugzilla version="5.2"
          urlbase="https://bugzilla.altlinux.org/"
          
          maintainer="jenya@basealt.ru"
>

    <bug>
          <bug_id>9599</bug_id>
          
          <creation_ts>2006-05-22 12:52:26 +0400</creation_ts>
          <short_desc>libpthread Segfault [x86_64]</short_desc>
          <delta_ts>2006-09-15 01:48:38 +0400</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>4</classification_id>
          <classification>Development</classification>
          <product>Sisyphus</product>
          <component>glibc-core</component>
          <version>unstable</version>
          <rep_platform>all</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>blocker</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Anton Farygin">rider</reporter>
          <assigned_to name="Gleb F-Malinovskiy">glebfm</assigned_to>
          <cc>glebfm</cc>
    
    <cc>ldv</cc>
    
    <cc>vsu</cc>
    
    <cc>zerg</cc>
          
          <qa_contact>qa-sisyphus</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>38194</commentid>
    <comment_count>0</comment_count>
    <who name="Anton Farygin">rider</who>
    <bug_when>2006-05-22 12:52:26 +0400</bug_when>
    <thetext>после каких-то обновлений системных библиотек gimp2-2.2.10-alt1.1
стал вываливаться с segfault.

на i586 воспроизвести не удалось.

strace показывает что падает где-то в районе pthread, но что именно - непонятно.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38206</commentid>
    <comment_count>1</comment_count>
    <who name="Anton Farygin">rider</who>
    <bug_when>2006-05-22 18:22:12 +0400</bug_when>
    <thetext>пересборка избавится от segfault не помогла.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38209</commentid>
    <comment_count>2</comment_count>
    <who name="Anatoly Yakushin">jaa</who>
    <bug_when>2006-05-23 00:35:09 +0400</bug_when>
    <thetext>Попробую новую версию собрать на неделе.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38227</commentid>
    <comment_count>3</comment_count>
    <who name="Anton Farygin">rider</who>
    <bug_when>2006-05-23 10:44:04 +0400</bug_when>
    <thetext>я подозреваю что новая версия GIMP проблемы не решит.

Судя по всему здесь где-то грабли в библиотеках, с которыми gimp слинкован. во
всяком случае:
1) GIMP не пересобирался
2) пересборка не помогает
3) обновлялось что-то из того, с чем он слинкован

2ldv: очень похоже на проблему с gnupg</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38236</commentid>
    <comment_count>4</comment_count>
    <who name="Anton Farygin">rider</who>
    <bug_when>2006-05-23 15:26:11 +0400</bug_when>
    <thetext>ltrace показывает вот это:
9330 g_free(0xc61d90, 3, 0x422f38, 0, 0x2b7a0db72540)                          
      = 0
9330 g_free(0, 3, 0x422f38, 0, 0x732e6964696d5f72)                             
      = 1
9330 g_free(0xc62820, 3, 0x422f38, 0, 0x2064656e69666564)                      
      = 0
9330 g_free(0xc62930, 3, 0x422f38, 0, 0x2b7a0db72540)                          
      = 0
9330 g_free(0, 3, 0x422f38, 0, 0x2b7a0db72540)                                 
      = 1
9330 g_free(0, 3, 0x422f38, 0, 64)                                             
      = 1
9330 g_direct_hash(1039, 1039, 0x2b7a0d679832, 557, 192)                       
      = 1039
9330 g_direct_equal(550, 1039, 61, 557, 192)                                   
      = 0
9330 g_direct_equal(713, 1039, 61, 557, 192)                                   
      = 0
9330 g_direct_equal(876, 1039, 61, 557, 192)                                   
      = 0
9330 g_free(0, 3, 0x422f38, 0, 128)                                            
      = 1
9330 --- SIGSEGV (Segmentation fault) ---
9330 +++ killed by SIGSEGV +++
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38237</commentid>
    <comment_count>5</comment_count>
    <who name="Anton Farygin">rider</who>
    <bug_when>2006-05-23 15:31:15 +0400</bug_when>
    <thetext>по наитию было выяснено, что падают любые gnome приложения.

gbd от gnumeric показало:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 16384 (LWP 9514)]
0x00002aee571276d1 in pthread_rwlock_wrlock () from /lib64/libpthread.so.0
(gdb) bt
#0  0x00002aee571276d1 in pthread_rwlock_wrlock () from /lib64/libpthread.so.0
#1  0x00002aee54d0fed3 in __ctype_b_loc () from /lib64/libc.so.6
#2  0x00002aee54d10282 in bindtextdomain () from /lib64/libc.so.6
#3  0x00002aee59ddc9c7 in gpg_err_init () from /usr/lib64/libgpg-error.so.0
#4  0x00002aee59ddcd86 in gpg_err_code_from_errno () from
/usr/lib64/libgpg-error.so.0
#5  0x00007fffffc52ce8 in ?? ()
#6  0x00002aee59cca660 in ?? ()
#7  0x00002aee547b49a8 in _r_debug ()
#8  0x00002aee59ddc86b in _init () from /usr/lib64/libgpg-error.so.0
#9  0x00002aee54ce6000 in ?? ()
#10 0x00002aee546a825b in call_init () from /lib64/ld-linux-x86-64.so.2
#11 0x00002aee546a837e in _dl_init_internal () from /lib64/ld-linux-x86-64.so.2
#12 0x00002aee5469eb7b in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38238</commentid>
    <comment_count>6</comment_count>
    <who name="Anton Farygin">rider</who>
    <bug_when>2006-05-23 16:06:40 +0400</bug_when>
    <thetext>$ ltrace -f gnumeric
--- SIGSEGV (Segmentation fault) ---
+++ killed by SIGSEGV +++

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38240</commentid>
    <comment_count>7</comment_count>
    <who name="Anton Farygin">rider</who>
    <bug_when>2006-05-23 16:15:01 +0400</bug_when>
    <thetext>экпериментальным путём было выявлено, что падают _все_ gnome2 приложения ;(</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38241</commentid>
    <comment_count>8</comment_count>
    <who name="Anton Farygin">rider</who>
    <bug_when>2006-05-23 16:15:38 +0400</bug_when>
    <thetext>кстати, все они падают сразу после того, как загрузят библиотеки
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38242</commentid>
    <comment_count>9</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2006-05-23 16:18:43 +0400</bug_when>
    <thetext>А какое из них самое простое?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38243</commentid>
    <comment_count>10</comment_count>
    <who name="Anton Farygin">rider</who>
    <bug_when>2006-05-23 16:30:29 +0400</bug_when>
    <thetext>если из gimp2 вынести всё, что слиновано с libpthread, то работает нормально.

а именно:
libcontroller_midi.so из libgimp

т.е. - все приложения, слинкованные с libpthread и gtk на x86_64 ведут себя плохо.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38246</commentid>
    <comment_count>11</comment_count>
    <who name="Anton Farygin">rider</who>
    <bug_when>2006-05-23 17:37:36 +0400</bug_when>
    <thetext>$ cat test.c
int main(void)
{
        return(0);
}

$gcc -Wl,--no-as-needed -o testa test.c -lgcrypt -lpthread
(gdb) run
Starting program: /home/rider/testa 
[Thread debugging using libthread_db enabled]
[New Thread 16384 (LWP 30704)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 16384 (LWP 30704)]
0x00002ab5495056d1 in pthread_rwlock_wrlock () from /lib64/libpthread.so.0
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38259</commentid>
    <comment_count>12</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2006-05-23 23:14:46 +0400</bug_when>
    <thetext>Это даже не libgcrypt, а libgpg-error.so.0:

$ cat foo.c
int main(void) {return 0;}
$ gcc -g -Wall -W -Werror -Wl,--no-as-needed -o foo foo.c -lpthread -lgpg-error
$ ./foo
Segmentation fault

$ LD_LIBRARY_PATH=/usr/lib64/debug gdb -q ./foo
Using host libthread_db library &quot;/usr/lib64/debug/libthread_db.so.1&quot;.
(gdb) r
Starting program: /usr/src/RPM/BUILD/glibc-2.3.6/linuxthreads/foo 
[Thread debugging using libthread_db enabled]
[New Thread 16384 (LWP 8673)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 16384 (LWP 8673)]
__pthread_rwlock_wrlock (rwlock=0x2aaaab07c140) at descr.h:248
248       return THREAD_SELF;
(gdb) bt
#0  __pthread_rwlock_wrlock (rwlock=0x2aaaab07c140) at descr.h:248
#1  0x00002aaaaae85ed3 in set_binding_values (domainname=0x2aaaaad5add2
&quot;libgpg-error&quot;, 
    dirnamep=0x7fffffffe840, codesetp=0x0) at bindtextdom.c:120
#2  0x00002aaaaae86282 in __bindtextdomain (domainname=Variable &quot;domainname&quot; is
not available.
) at bindtextdom.c:356
#3  0x00002aaaaad5a9c7 in gpg_err_init () from /usr/lib64/libgpg-error.so.0
#4  0x00002aaaaad5ad86 in gpg_err_code_from_errno () from
/usr/lib64/libgpg-error.so.0
#5  0x00007fffffffe938 in ?? ()
#6  0x00002aaaaaac1b80 in ?? ()
#7  0x00002aaaaabc19a8 in _r_debug ()
#8  0x00002aaaaad5a86b in _init () from /usr/lib64/libgpg-error.so.0
#9  0x00002aaaaad59040 in ?? ()
#10 0x00002aaaaaab525b in call_init () from /lib64/ld-linux-x86-64.so.2
#11 0x00002aaaaaab537e in _dl_init_internal () from /lib64/ld-linux-x86-64.so.2
#12 0x00002aaaaaaabb7b in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
#13 0x0000000000000001 in ?? ()

Так что это либо linuxthreads, либо libgpg-error.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38266</commentid>
    <comment_count>13</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2006-05-24 00:53:56 +0400</bug_when>
    <thetext>Нет, это не libpgg-error:

$ cat bar.c 
#define _GNU_SOURCE
#include &lt;bits/libc-lock.h&gt;
static void __attribute__((constructor)) myinit(void)
{
        pthread_rwlock_t lock;
        __libc_rwlock_wrlock(lock);
}
$ gcc -g -Wall -W -Werror -fpic -shared -o libbar.so bar.c
$ cat foo.c 
int main(void) {return 0;}
$ gcc -g -Wall -W -Werror -Wl,--no-as-needed -o foo foo.c -lpthread -L. -lbar
$ LD_LIBRARY_PATH=. ./foo
Segmentation fault
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38268</commentid>
    <comment_count>14</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2006-05-24 01:02:22 +0400</bug_when>
    <thetext>$ LD_LIBRARY_PATH=.:/usr/lib64/debug gdb -q ./foo
Using host libthread_db library &quot;/usr/lib64/debug/libthread_db.so.1&quot;.
(gdb) b __pthread_rwlock_wrlock
Function &quot;__pthread_rwlock_wrlock&quot; not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (__pthread_rwlock_wrlock) pending.
(gdb) r
Starting program: /usr/src/RPM/BUILD/glibc-2.3.6/linuxthreads/foo 
[Thread debugging using libthread_db enabled]
[New Thread 16384 (LWP 23293)]
Breakpoint 2 at 0x2aaaaabcd6d0: file rwlock.c, line 414.
Pending breakpoint &quot;__pthread_rwlock_wrlock&quot; resolved
[Switching to Thread 16384 (LWP 23293)]
Breakpoint 2, __pthread_rwlock_wrlock (rwlock=0x7fffffffe810) at rwlock.c:414
414     {
(gdb) display/i $pc
1: x/i $pc  0x2aaaaabcd6d0 &lt;__pthread_rwlock_wrlock&gt;:   push   %rbp
(gdb) stepi
248       return THREAD_SELF;
1: x/i $pc  0x2aaaaabcd6d1 &lt;__pthread_rwlock_wrlock+1&gt;: mov    %fs:0x10,%rbp
(gdb) stepi
Program received signal SIGSEGV, Segmentation fault.
__pthread_rwlock_wrlock (rwlock=0x7fffffffe810) at descr.h:248
248       return THREAD_SELF;
1: x/i $pc  0x2aaaaabcd6d1 &lt;__pthread_rwlock_wrlock+1&gt;: mov    %fs:0x10,%rbp
(gdb) p $fs
$1 = 0
(gdb) p $rbp
$2 = (void *) 0x7fffffffe850
(gdb) p &amp;lock
$4 = (__libc_lock_t *) 0x2aaaab07d580
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38269</commentid>
    <comment_count>15</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2006-05-24 01:08:23 +0400</bug_when>
    <thetext>Для сравнения те же тесты на glibc, собранном прежним компилятором:
(gdb) stepi
248       return THREAD_SELF;
1: x/i $pc  0x2aaaaabcd6a1 &lt;__pthread_rwlock_wrlock+1&gt;: mov    %fs:0x10,%rbp
(gdb) p $fs
$1 = 99
(gdb) p $rbp
$2 = (void *) 0x7fffffffe870
(gdb) p &amp;lock
$3 = (__libc_lock_t *) 0x2aaaab07cca0
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38270</commentid>
    <comment_count>16</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2006-05-24 01:37:43 +0400</bug_when>
    <thetext>А если линковать не &quot;-lpthread -L. -lbar&quot; а &quot;-L. -lbar -lpthread&quot;,
то c пересобранным glibc &quot;LD_LIBRARY_PATH=. ./foo&quot; не падает а виснет.

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38271</commentid>
    <comment_count>17</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2006-05-24 01:47:11 +0400</bug_when>
    <thetext>Всё интереснее: foo и libbar, собранные на свежем Сизифе, точно так же падают на
прежнем.
Просто тест не удаётся повторить на прежнем Сизифе:

old$ gcc -Wl,--no-as-needed -o foo foo.c -lpthread
old$ readelf -d foo |grep -w NEEDED
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]

new$ gcc -Wl,--no-as-needed -o foo foo.c -lpthread
new$ readelf -d foo |grep -w NEEDED
 0x0000000000000001 (NEEDED)             Shared library: [libpthread.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38272</commentid>
    <comment_count>18</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2006-05-24 01:52:17 +0400</bug_when>
    <thetext>Zerg, где ты нашёл такую странную библиотеку?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38273</commentid>
    <comment_count>19</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2006-05-24 02:07:40 +0400</bug_when>
    <thetext>Тест неправильный был, такой имеет смысл:
$ cat bar.c 
#define _GNU_SOURCE
#include &lt;bits/libc-lock.h&gt;
static void __attribute__((constructor)) myinit(void)
{
        static pthread_rwlock_t lock;
        __libc_rwlock_wrlock(lock);
}

$ gcc -g -Wall -W -Werror -Wl,--no-as-needed -o foo foo.c -L. -lpthread -lbar
$ LD_LIBRARY_PATH=. ./foo
Segmentation fault
$ gcc -g -Wall -W -Werror -Wl,--no-as-needed -o foo foo.c -L. -lbar -lpthread
$ LD_LIBRARY_PATH=. ./foo
$ 
Что вполне логично.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38274</commentid>
    <comment_count>20</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2006-05-24 02:18:36 +0400</bug_when>
    <thetext>Кто бы мне объяснил, почему $fs так разительно отличаются на одинаковых foo и
libbar.so - разница только в glibc...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38276</commentid>
    <comment_count>21</comment_count>
    <who name="Anton Farygin">rider</who>
    <bug_when>2006-05-24 09:40:28 +0400</bug_when>
    <thetext>Давай пойдём другим путём ;)

Насколько я знаю - fedora тоже успешно собирает эти самые библиотеки. Наверняка,
если бы оно у них падало - давно бы поймали.

Вопрос - почему у них не падают ?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38277</commentid>
    <comment_count>22</comment_count>
    <who name="Anton Farygin">rider</who>
    <bug_when>2006-05-24 09:41:12 +0400</bug_when>
    <thetext>хотя.. у них же glibc сильно другая ?
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38285</commentid>
    <comment_count>23</comment_count>
    <who name="Sergey V Turchin">zerg</who>
    <bug_when>2006-05-24 14:52:16 +0400</bug_when>
    <thetext>(In reply to comment #18)
&gt; Zerg, где ты нашёл такую странную библиотеку?
ftp://ftp.gnupg.org/gcrypt/libgpg-error</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38324</commentid>
    <comment_count>24</comment_count>
    <who name="Anton Farygin">rider</who>
    <bug_when>2006-05-25 21:10:31 +0400</bug_when>
    <thetext>Чего в итоге то делать с этим ?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38327</commentid>
    <comment_count>25</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2006-05-26 01:49:58 +0400</bug_when>
    <thetext>Надо фиксить asm для x86-64.  В nptl есть изменения, похожие на те, что нужны и
здесь.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38328</commentid>
    <comment_count>26</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2006-05-26 03:18:49 +0400</bug_when>
    <thetext>Корректировка asm&apos;а не помогла.  Больше идей нет.
Подготовка новой glibc займёт не меньше недели.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38329</commentid>
    <comment_count>27</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2006-05-26 03:54:14 +0400</bug_when>
    <thetext>$fs не проинициализирован потому что __pthread_initialize_minimal() не была
вызвана.  Кто-то её соптимизировал, наверное.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38331</commentid>
    <comment_count>28</comment_count>
    <who name="Anton Farygin">rider</who>
    <bug_when>2006-05-26 12:32:08 +0400</bug_when>
    <thetext>я думаю что надо забить и просто переходить на новую версию libc</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>38338</commentid>
    <comment_count>29</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2006-05-26 19:02:44 +0400</bug_when>
    <thetext>Fixed in 2.3.6-alt7.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>