Hang on export_im and DestroyConstitute patch

David Liontooth <[email protected]> Wed, 21 Apr 2010 04:13:15 -0700
Newsgroups gmane.comp.video.transcode.user
Message-ID <[email protected]>
In transcode 1.1.x, but not in 1.0.x, this hangs when test.mp4 is a 
minute long:

transcode -q 0 -y im -F png -x mov,null -i test.mp4 -c 
0:01:10-0:01:10.1,0:02:10-0:02:10

That is to say, if more than one frame number given is past the end of 
the clip, transcode hangs.

The command of course calls export_im, but I can't tell if that is 
really where the problem lies.

gdb is not very informative:

Starting program: /usr/local/bin/transcode -q 0 -o ./ -y im -F png -x 
mov,null -i test.mp4 -c 0:01:10-0:01:10.1,0:02:10-0:02:10.1
[Thread debugging using libthread_db enabled]
libdvdread: Using libdvdcss version 1.2.10 for DVD access
libdvdnav:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.IFO failed
libdvdnav:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.BUP failed
libdvdread: Can't open file VIDEO_TS.IFO.
libdvdread: Using libdvdcss version 1.2.10 for DVD access
libdvdnav:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.IFO failed
libdvdnav:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.BUP failed
libdvdread: Can't open file VIDEO_TS.IFO.
[New Thread 0x7fffe0f6b910 (LWP 27266)]
[New Thread 0x7fffe076a910 (LWP 27267)]
[New Thread 0x7fffdff69910 (LWP 27268)]
[import_mov.so] VIDEO: codec=avc1, fps=29.970, width=448, height=336, 
frames=1799
[New Thread 0x7fffdaf1f910 (LWP 27269)]
[New Thread 0x7fffda71e910 (LWP 27270)]
[Thread 0x7fffdaf1f910 (LWP 27269) exited]
[Thread 0x7fffe076a910 (LWP 27267) exited]
[Thread 0x7fffda71e910 (LWP 27270) exited]

and then it just hangs until I interrupt:

^C
Program received signal SIGINT, Interrupt.
[Switching to Thread 0x7fffe0f6b910 (LWP 27266)]
0x00007ffff788321d in pause () from /lib/libpthread.so.0

I've been unable to use 1.1 ever since it was released because of this 
problem. Could someone please help me?

strace is perhaps more informative (I can send a full strace if that 
would be useful):

write(2, "[\33[34;1mimport_mov.so\33[0m] VIDEO"..., 93[import_mov.so] 
VIDEO: codec=avc1, fps=29.970, width=448, height=336, 
frames=1799                                                              
) = 
93                                                                                             

mmap(NULL, 8392704, PROT_READ|PROT_WRITE, 
MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 
0x7fbaa8d08000                                                                                                

mprotect(0x7fbaa8d08000, 4096, PROT_NONE) = 
0                                                     
clone(child_stack=0x7fbaa95081d0, 
flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, 
parent_tidptr=0x7fbaa95089e0, tls=0x7fbaa9508910, 
child_tidptr=0x7fbaa95089e0) = 
29452                                            
mmap(NULL, 8392704, PROT_READ|PROT_WRITE, 
MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 
0x7fbaa8507000                                                                                                

mprotect(0x7fbaa8507000, 4096, PROT_NONE) = 
0                                                     
clone(child_stack=0x7fbaa8d071d0, 
flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, 
parent_tidptr=0x7fbaa8d079e0, tls=0x7fbaa8d07910, 
child_tidptr=0x7fbaa8d079e0) = 
29453                                            
open("/usr/lib/locale/locale-archive", O_RDONLY) = 
4                                              
fstat(4, {st_mode=S_IFREG|0644, st_size=1575552, ...}) = 
0                                        
mmap(NULL, 1575552, PROT_READ, MAP_PRIVATE, 4, 0) = 
0x7fbaa8386000                                
close(4)                                = 
0                                                       
brk(0x1bfb000)                          = 
0x1bfb000                                               
getcwd("/home/tna/test", 4096)          = 
15                                                      
readlink("/proc/29444/exe", "/usr/local/bin/transcode", 4096) = 
24                                
stat("/usr/local/bin/transcode", {st_mode=S_IFREG|0755, st_size=1134632, 
...}) = 0                
access("/usr/local/bin/transcode", F_OK) = 
0                                                      
open("/proc/meminfo", O_RDONLY)         = 
4                                                       
fstat(4, {st_mode=S_IFREG|0444, st_size=0, ...}) = 
0                                              
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) 
= 0x7fbac65e1000         
read(4, "MemTotal:        8186476 kB\nMemF"..., 1024) = 
1024                                      
close(4)                                = 
0                                                       
munmap(0x7fbac65e1000, 4096)            = 
0                                                       
open("/usr/share/ImageMagick-6.6.0/config/policy.xml", O_RDONLY) = -1 
ENOENT (No such file or 
directory)                                                                                              

open("/usr/lib/ImageMagick-6.6.0/config/policy.xml", O_RDONLY) = 
4                                
lseek(4, 0, SEEK_END)                   = 
1938                                                    
mmap(NULL, 1938, PROT_READ, MAP_PRIVATE, 4, 0) = 
0x7fbac65e1000                                   
munmap(0x7fbac65e1000, 1938)            = 
0                                                       
close(4)                                = 
0                                                       
open("/usr/share/doc/ImageMagick-6.6.0/policy.xml", O_RDONLY) = -1 
ENOENT (No such file or 
directory)                                                                                                 

open("/usr/share/ImageMagick-6.6.0/policy.xml", O_RDONLY) = -1 ENOENT 
(No such file or directory) 
open("/home/tna/.magick/policy.xml", O_RDONLY) = -1 ENOENT (No such file 
or directory)            
open("policy.xml", O_RDONLY)            = -1 ENOENT (No such file or 
directory)                   
getrlimit(RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=1024}) = 
0                                      
brk(0x1cc7000)                          = 
0x1cc7000                                               
futex(0x694264, FUTEX_WAKE_OP_PRIVATE, 1, 1, 0x694260, {FUTEX_OP_SET, 0, 
FUTEX_OP_CMP_GT, 1}) = 1 
futex(0x694220, FUTEX_WAKE_PRIVATE, 1)  = 
1                                                       
futex(0x6943e4, FUTEX_WAIT_PRIVATE, 1, NULL) = 
0                                                  
futex(0x694320, FUTEX_WAKE_PRIVATE, 1)  = 0      

Once it gets into the futexes, it keeps going until "futex(0x6943e4, 
FUTEX_WAIT_PRIVATE, 3593, NULL" and then just sits there.

On an unrelated matter, you may have seen this already --- fixing it 
doesn't fix the hang above:

https://bugs.launchpad.net/ubuntu/+source/transcode/+bug/539106 points 
out that "A couple of months ago the API of imagemagick has changed and 
DestroyConstitute() was replaced by ConstituteComponentTerminus() ."

--- export/export_im.c  2009-02-21 13:01:57.000000000 -0800
+++ export/export_im-new.c      2010-04-21 00:50:33.500311684 -0700
@@ -220,7 +220,7 @@

   if(param->flag == TC_VIDEO) {
     DestroyImageInfo(image_info);
-    DestroyConstitute();
+    ConstituteComponentTerminus();
     DestroyMagick();

     free(tmp_buffer);

--- filter/filter_logoaway.c    2009-03-28 01:39:08.000000000 -0700
+++ filter/filter_logoaway-new.c        2010-04-21 00:52:45.300310393 -0700
@@ -865,7 +865,7 @@
     if (data[instance]->dumpimage != (Image *)NULL) {
       DestroyImage(data[instance]->dumpimage);
       DestroyImageInfo(data[instance]->dumpimage_info);
-      DestroyConstitute();
+      ConstituteComponentTerminus();
     }
     DestroyExceptionInfo(&data[instance]->exception_info);
     DestroyMagick();

Cheers,
Dave