Re: mpv coredump

2020-02-16 Thread Thomas Klausner
On Sun, Feb 16, 2020 at 06:15:40PM +0100, Kamil Rytarowski wrote:
> On 16.02.2020 17:44, Tom Ivar Helbekkmo wrote:
> > Thomas Klausner  writes:
> > 
> >>> To generate a diff of this commit:
> >>> cvs rdiff -u -r1.164 -r1.165 src/lib/libpthread/pthread.c
> >>> cvs rdiff -u -r1.101 -r1.102 src/lib/libpthread/pthread_int.h
> >>> cvs rdiff -u -r1.74 -r1.75 src/lib/libpthread/pthread_mutex.c
> >>> cvs rdiff -u -r1.18 -r1.19 src/lib/libpthread/pthread_tsd.c
> >>
> >> If I revert this, mpv works again.
> > 
> > Also, the GNU zip utilities (gzip, gunzip, gzcat) just hang (in state
> > "parked") when run on aarch64 after the above commit.  Reverting it lets
> > them work correctly again.
> > 
> > (Noticed while installing an upgrade - the upgrade stopped progressing
> > after base.tgz had been unpacked.)
> > 
> > -tih
> > 
> 
> Please test pthread.c 1.166.
> 


I tried but that wasn't sufficient.

cd /usr/src/lib/libpthread
cvs update
USETOOLS=no make
USETOOLS=no make install

#  ident pthread.c
pthread.c:
 $NetBSD: pthread.c,v 1.166 2020/02/16 17:14:31 kamil Exp $
 $NetBSD: pthread.c,v 1.166 2020/02/16 17:14:31 kamil Exp $
# ldd /usr/pkg/bin/mpv | grep pthread
-lpthread.1 => /usr/lib/libpthread.so.1
# ls -l /usr/lib/libpthread*
-r--r--r--  1 root  wheel  108834 Feb 16 18:38 /usr/lib/libpthread.a
lrwxrwxr-x  1 root  wheel  27 Feb 16 18:38 /usr/lib/libpthread.so -> 
../../lib/libpthread.so.1.4
lrwxrwxr-x  1 root  wheel  27 Feb 16 18:38 /usr/lib/libpthread.so.1 -> 
../../lib/libpthread.so.1.4
lrwxrwxr-x  1 root  wheel  27 Feb 16 18:38 /usr/lib/libpthread.so.1.4 -> 
../../lib/libpthread.so.1.4
-r--r--r--  1 root  wheel  629712 Feb 16 10:14 /usr/lib/libpthread_g.a
-r--r--r--  1 root  wheel  122880 Feb 16 18:38 /usr/lib/libpthread_p.a
# ls -l /lib/libpthread*
lrwxrwxr-x  1 root  wheel 17 Feb 16 18:38 /lib/libpthread.so -> 
libpthread.so.1.4
lrwxrwxr-x  1 root  wheel 17 Feb 16 18:38 /lib/libpthread.so.1 -> 
libpthread.so.1.4
-r--r--r--  1 root  wheel  97744 Feb 16 18:38 /lib/libpthread.so.1.4

# mpv file
segfault
# gdb mpv mpv.core

Core was generated by `mpv'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x7796410ebd31 in je_extent_heap_remove (ph=ph@entry=0x779630e05a58, 
phn=phn@entry=0x779631207340) at 
/usr/src/external/bsd/jemalloc/lib/../dist/src/extent.c:278
278 ph_gen(, extent_heap_, extent_heap_t, extent_t, ph_link, 
extent_snad_comp)
[Current thread is 1 (process 3)]
(gdb) bt
#0  0x7796410ebd31 in je_extent_heap_remove (ph=ph@entry=0x779630e05a58, 
phn=phn@entry=0x779631207340) at 
/usr/src/external/bsd/jemalloc/lib/../dist/src/extent.c:278
#1  0x779641113977 in arena_bin_slabs_nonfull_remove (slab=0x779631207340, 
bin=0x779630e059e0) at 
/usr/src/external/bsd/jemalloc/lib/../dist/src/arena.c:1484
#2  arena_dissociate_bin_slab (bin=0x779630e059e0, slab=0x779631207340, 
arena=0x779630e008c0) at 
/usr/src/external/bsd/jemalloc/lib/../dist/src/arena.c:1484
#3  arena_dalloc_bin_locked_impl (tsdn=tsdn@entry=0x77964c1f90a0, 
arena=arena@entry=0x779630e008c0, slab=0x779631207340, ptr=, 
junked=junked@entry=true) at 
/usr/src/external/bsd/jemalloc/lib/../dist/src/arena.c:1546
#4  0x779641114d49 in je_arena_dalloc_bin_junked_locked 
(tsdn=tsdn@entry=0x77964c1f90a0, arena=arena@entry=0x779630e008c0, 
extent=, ptr=) at 
/usr/src/external/bsd/jemalloc/lib/../dist/src/arena.c:1562
#5  0x7796410be7a5 in je_tcache_bin_flush_small 
(tsd=tsd@entry=0x77964c1f90a0, tcache=tcache@entry=0x77964c1f9260, 
tbin=tbin@entry=0x77964c1f93f0, binind=binind@entry=16, rem=5) at 
/usr/src/external/bsd/jemalloc/lib/../include/jemalloc/internal/tsd.h:138
#6  0x7796410bfc72 in je_tcache_event_hard (tsd=tsd@entry=0x77964c1f90a0, 
tcache=tcache@entry=0x77964c1f9260) at 
/usr/src/external/bsd/jemalloc/lib/../dist/src/tcache.c:54
#7  0x77964111afb5 in tcache_event (tcache=, tsd=) at 
/usr/src/external/bsd/jemalloc/lib/../include/jemalloc/internal/tcache_inlines.h:37
#8  tcache_alloc_large (slow_path=, zero=, 
binind=, size=, tcache=, 
arena=, tsd=) at 
/usr/src/external/bsd/jemalloc/lib/../include/jemalloc/internal/tcache_inlines.h:159
#9  arena_malloc (slow_path=, tcache=, 
zero=, ind=, size=, 
arena=, tsdn=) at 
/usr/src/external/bsd/jemalloc/lib/../include/jemalloc/internal/arena_inlines_b.h:98
#10 iallocztm (slow_path=, arena=, 
is_internal=, tcache=, zero=, 
ind=, size=, tsdn=) at 
/usr/src/external/bsd/jemalloc/lib/../include/jemalloc/internal/jemalloc_internal_inlines_c.h:53
#11 imalloc_no_sample (ind=, usize=, 
size=, tsd=, dopts=, 
sopts=) at 
/usr/src/external/bsd/jemalloc/lib/../dist/src/jemalloc.c:1742
#12 imalloc_body (tsd=, dopts=, sopts=) at /usr/src/external/bsd/jemalloc/lib/../dist/src/jemalloc.c:1938
#13 imalloc (dopts=, sopts=) at 
/usr/src/external/bsd/jemalloc/lib/../dist/src/jemalloc.c:2041
#14 malloc (size=) at 
/usr/src/external/bsd/jemalloc/lib/../dist/src/jemalloc.c:2071
#15 0x779642c1287b in luaM_realloc_ (L=L@entry=0x77964c07f000, 

Re: mpv coredump

2020-02-16 Thread Kamil Rytarowski
On 16.02.2020 17:44, Tom Ivar Helbekkmo wrote:
> Thomas Klausner  writes:
> 
>>> To generate a diff of this commit:
>>> cvs rdiff -u -r1.164 -r1.165 src/lib/libpthread/pthread.c
>>> cvs rdiff -u -r1.101 -r1.102 src/lib/libpthread/pthread_int.h
>>> cvs rdiff -u -r1.74 -r1.75 src/lib/libpthread/pthread_mutex.c
>>> cvs rdiff -u -r1.18 -r1.19 src/lib/libpthread/pthread_tsd.c
>>
>> If I revert this, mpv works again.
> 
> Also, the GNU zip utilities (gzip, gunzip, gzcat) just hang (in state
> "parked") when run on aarch64 after the above commit.  Reverting it lets
> them work correctly again.
> 
> (Noticed while installing an upgrade - the upgrade stopped progressing
> after base.tgz had been unpacked.)
> 
> -tih
> 

Please test pthread.c 1.166.



signature.asc
Description: OpenPGP digital signature


Re: mpv coredump

2020-02-16 Thread Tom Ivar Helbekkmo
Thomas Klausner  writes:

>> To generate a diff of this commit:
>> cvs rdiff -u -r1.164 -r1.165 src/lib/libpthread/pthread.c
>> cvs rdiff -u -r1.101 -r1.102 src/lib/libpthread/pthread_int.h
>> cvs rdiff -u -r1.74 -r1.75 src/lib/libpthread/pthread_mutex.c
>> cvs rdiff -u -r1.18 -r1.19 src/lib/libpthread/pthread_tsd.c
>
> If I revert this, mpv works again.

Also, the GNU zip utilities (gzip, gunzip, gzcat) just hang (in state
"parked") when run on aarch64 after the above commit.  Reverting it lets
them work correctly again.

(Noticed while installing an upgrade - the upgrade stopped progressing
after base.tgz had been unpacked.)

-tih
-- 
Most people who graduate with CS degrees don't understand the significance
of Lisp.  Lisp is the most important idea in computer science.  --Alan Kay


Re: mpv coredump

2020-02-16 Thread Kamil Rytarowski
On 16.02.2020 14:54, Thomas Klausner wrote:
> On Sun, Feb 16, 2020 at 01:02:32PM +0100, Kamil Rytarowski wrote:
>> On 16.02.2020 12:48, Thomas Klausner wrote:
>>> Hi!
>>>
>>> I've upgraded kernel + userland to 9.99.47/amd64.
>>> Now mpv (built on 9.99.43) dumps core immediately.
>>>
>>
>> Does it work if you just revert this:
>>
>> Modified Files:
>>  src/lib/libpthread: pthread.c pthread_int.h pthread_mutex.c
>>  pthread_tsd.c
>>
>> Log Message:
>> Enhance the pthread(3) + malloc(3) init model
>>
>> Separate the pthread_atfork(3) call from pthread_tsd_init()
>> and move it into a distinct function.
>>
>> Call inside pthread__init() late TSD initialization route, just after
>> "pthread_atfork(NULL, NULL, pthread__fork_callback);".
>>
>> Document that malloc(3) initialization is now controlled again and called
>> during the first pthread_atfork(3) call.
>>
>> Remove #if 0 code from pthread_mutex.c as we no longer initialize malloc
>> prematurely.
>>
>>
>> To generate a diff of this commit:
>> cvs rdiff -u -r1.164 -r1.165 src/lib/libpthread/pthread.c
>> cvs rdiff -u -r1.101 -r1.102 src/lib/libpthread/pthread_int.h
>> cvs rdiff -u -r1.74 -r1.75 src/lib/libpthread/pthread_mutex.c
>> cvs rdiff -u -r1.18 -r1.19 src/lib/libpthread/pthread_tsd.c
> 
> If I revert this, mpv works again.
>  Thomas
> 

I'm going to try to reproduce.



signature.asc
Description: OpenPGP digital signature


Re: mpv coredump

2020-02-16 Thread Thomas Klausner
On Sun, Feb 16, 2020 at 01:02:32PM +0100, Kamil Rytarowski wrote:
> On 16.02.2020 12:48, Thomas Klausner wrote:
> > Hi!
> > 
> > I've upgraded kernel + userland to 9.99.47/amd64.
> > Now mpv (built on 9.99.43) dumps core immediately.
> > 
> 
> Does it work if you just revert this:
> 
> Modified Files:
>   src/lib/libpthread: pthread.c pthread_int.h pthread_mutex.c
>   pthread_tsd.c
> 
> Log Message:
> Enhance the pthread(3) + malloc(3) init model
> 
> Separate the pthread_atfork(3) call from pthread_tsd_init()
> and move it into a distinct function.
> 
> Call inside pthread__init() late TSD initialization route, just after
> "pthread_atfork(NULL, NULL, pthread__fork_callback);".
> 
> Document that malloc(3) initialization is now controlled again and called
> during the first pthread_atfork(3) call.
> 
> Remove #if 0 code from pthread_mutex.c as we no longer initialize malloc
> prematurely.
> 
> 
> To generate a diff of this commit:
> cvs rdiff -u -r1.164 -r1.165 src/lib/libpthread/pthread.c
> cvs rdiff -u -r1.101 -r1.102 src/lib/libpthread/pthread_int.h
> cvs rdiff -u -r1.74 -r1.75 src/lib/libpthread/pthread_mutex.c
> cvs rdiff -u -r1.18 -r1.19 src/lib/libpthread/pthread_tsd.c

If I revert this, mpv works again.
 Thomas


Re: mpv coredump

2020-02-16 Thread Kamil Rytarowski
On 16.02.2020 12:48, Thomas Klausner wrote:
> Hi!
> 
> I've upgraded kernel + userland to 9.99.47/amd64.
> Now mpv (built on 9.99.43) dumps core immediately.
> 

Does it work if you just revert this:

Modified Files:
src/lib/libpthread: pthread.c pthread_int.h pthread_mutex.c
pthread_tsd.c

Log Message:
Enhance the pthread(3) + malloc(3) init model

Separate the pthread_atfork(3) call from pthread_tsd_init()
and move it into a distinct function.

Call inside pthread__init() late TSD initialization route, just after
"pthread_atfork(NULL, NULL, pthread__fork_callback);".

Document that malloc(3) initialization is now controlled again and called
during the first pthread_atfork(3) call.

Remove #if 0 code from pthread_mutex.c as we no longer initialize malloc
prematurely.


To generate a diff of this commit:
cvs rdiff -u -r1.164 -r1.165 src/lib/libpthread/pthread.c
cvs rdiff -u -r1.101 -r1.102 src/lib/libpthread/pthread_int.h
cvs rdiff -u -r1.74 -r1.75 src/lib/libpthread/pthread_mutex.c
cvs rdiff -u -r1.18 -r1.19 src/lib/libpthread/pthread_tsd.c

Alternatively please try to revert:

Modified Files:
src/external/bsd/jemalloc/dist/src: tcache.c

Log Message:
jemalloc: Avoid variable length array with length 0

Cherry-pick upstrem patch.

https://github.com/jemalloc/jemalloc/pull/1768


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 src/external/bsd/jemalloc/dist/src/tcache.c


I hope that the problem is in the latter.

> Core was generated by `mpv'.
> Program terminated with signal SIGSEGV, Segmentation fault.
> #0  0x794efd8ebd31 in je_extent_heap_remove (ph=ph@entry=0x794eec804fb8, 
> phn=phn@entry=0x794eecc097c0)
> at /usr/src/external/bsd/jemalloc/lib/../dist/src/extent.c:278
>   
>   
>  278 ph_gen(, extent_heap_, extent_heap_t, extent_t, ph_link, 
> extent_snad_comp)
> [Current thread is 1 (process 5)] 
> (gdb) bt
> #0  0x794efd8ebd31 in je_extent_heap_remove (ph=ph@entry=0x794eec804fb8, 
> phn=phn@entry=0x794eecc097c0) at 
> /usr/src/external/bsd/jemalloc/lib/../dist/src/extent.c:278
> #1  0x794efd913977 in arena_bin_slabs_nonfull_remove 
> (slab=0x794eecc097c0, bin=0x794eec804f40) at 
> /usr/src/external/bsd/jemalloc/lib/../dist/src/arena.c:1484
> #2  arena_dissociate_bin_slab (bin=0x794eec804f40, slab=0x794eecc097c0, 
> arena=0x794eec8008c0) at 
> /usr/src/external/bsd/jemalloc/lib/../dist/src/arena.c:1484
> #3  arena_dalloc_bin_locked_impl (tsdn=tsdn@entry=0x794f085a30a0, 
> arena=arena@entry=0x794eec8008c0, slab=0x794eecc097c0, ptr=, 
> junked=junked@entry=true) at 
> /usr/src/external/bsd/jemalloc/lib/../dist/src/arena.c:1546
> #4  0x794efd914d49 in je_arena_dalloc_bin_junked_locked 
> (tsdn=tsdn@entry=0x794f085a30a0, arena=arena@entry=0x794eec8008c0, 
> extent=, ptr=) at 
> /usr/src/external/bsd/jemalloc/lib/../dist/src/arena.c:1562
> #5  0x794efd8be7a5 in je_tcache_bin_flush_small 
> (tsd=tsd@entry=0x794f085a30a0, tcache=tcache@entry=0x794f085a3260, 
> tbin=0x794f085a3300, binind=binind@entry=6, rem=100)
> at 
> /usr/src/external/bsd/jemalloc/lib/../include/jemalloc/internal/tsd.h:138
> #6  0x794efd91cced in tcache_dalloc_small (slow_path=false, binind=6, 
> ptr=0x794f0804ef60, tcache=0x794f085a3260, tsd=) at 
> /usr/src/external/bsd/jemalloc/lib/../include/jemalloc/internal/tcache_inlines.h:178
> #7  arena_dalloc (slow_path=false, alloc_ctx=, 
> tcache=0x794f085a3260, ptr=0x794f0804ef60, tsdn=) at 
> /usr/src/external/bsd/jemalloc/lib/../include/jemalloc/internal/arena_inlines_b.h:224
> #8  idalloctm (slow_path=false, is_internal=false, alloc_ctx= pointer>, tcache=0x794f085a3260, ptr=0x794f0804ef60, tsdn=)
> at 
> /usr/src/external/bsd/jemalloc/lib/../include/jemalloc/internal/jemalloc_internal_inlines_c.h:118
> #9  ifree (slow_path=false, tcache=0x794f085a3260, ptr=0x794f0804ef60, 
> tsd=) at 
> /usr/src/external/bsd/jemalloc/lib/../dist/src/jemalloc.c:2255
> #10 free (ptr=0x794f0804ef60) at 
> /usr/src/external/bsd/jemalloc/lib/../dist/src/jemalloc.c:2429
> #11 0x0050e09a in ta_free (ptr=) at ../ta/ta.c:270
> #12 0x0046c76c in free_str_list (dst=0x794eed9ff3a0) at 
> ../options/m_option.c:1280
> #13 0x00475ca8 in m_option_free (opt=0x794eed9ff3e0, 
> dst=0x794eed9ff3a0) at ../options/m_option.h:533
> #14 m_property_do (log=, prop_list=0x794f08868c00, 
> name=name@entry=0x794f081abd88 "property-list", action=action@entry=6, 
> arg=0x794eed9ff4f0, ctx=ctx@entry=0x794f088ea040) at 
> ../options/m_property.c:128
> #15 0x0048c6fe in mp_property_do (name=0x794f081abd88 
> "property-list", action=action@entry=6, val=, 
> val@entry=0x794eed9ff4f0, ctx=0x794f088ea040) at ../player/command.c:3605
> #16 0x0047ca5c in getproperty_fn (arg=arg@entry=0x794eed9ff560) at 
> ../player/client.c:1356
> #17 0x0047ebd