You could surround the appropriate code with a try catch block, not ideal
but better than a crash!
On Dec 11, 2013 1:36 PM, "Martin Heller" <[email protected]> wrote:

> Well, that is what I am writing, the filename is not in a valid UTF-8
> format. Originally the filename appeared due to a programming error (not
> converting filename to UTF-8).
>
> However, what concerns me is that files with such filenames can appear
> in the filesystem (intentionally or unintentionally), and an application
> crash is not a very good response to such occurence.
>
> Martin
>
> On 12/11/2013 07:19 PM, Harri Smått wrote:
> > Looking at the crash log it seems so that the filename is not valid
> > UTF-8 format.. Do you happen to have any idea how such a filename took
> > place to begin with?
> >
> > —
> > H
> >
> > On 11 Dec 2013, at 16:43, Martin Heller <[email protected]
> > <mailto:[email protected]>> wrote:
> >
> >> Hello,
> >>
> >> I have encountered a crash in the java.io.File.list() method when
> >> trying to list contents of a directory containing a file with filename
> >> with invalid encoding.
> >> The crash has been observed on multiple devices running Android 4.1,
> >> 4.3 and 4.4.
> >>
> >> Has anyone encountered this crash? Is there any way to avoid it if
> >> such file is present in the filesystem?
> >>
> >> Please see the attached offending file and the logcat dump below.
> >>
> >> Thanks,
> >>
> >> Martin Heller
> >>
> >>
> >> 12-11 17:22:46.876: W/dalvikvm(7850): JNI WARNING: input is not valid
> >> Modified UTF-8: illegal continuation byte 0x61
> >> 12-11 17:22:46.876: W/dalvikvm(7850):              string: 'PY�aern
> >> ~lueou k� koH.txt'
> >> 12-11 17:22:46.876: W/dalvikvm(7850):              in
> >> Ljava/io/File;.listImpl:(Ljava/lang/String;)[Ljava/lang/String;
> >> (NewStringUTF)
> >> 12-11 17:22:46.876: I/dalvikvm(7850): "Application Main Thread" prio=5
> >> tid=1 NATIVE
> >> 12-11 17:22:46.876: I/dalvikvm(7850):   | group="main" sCount=0
> >> dsCount=0 obj=0x41b22578 self=0x40016120
> >> 12-11 17:22:46.876: I/dalvikvm(7850):   | sysTid=7850 nice=0 sched=0/0
> >> cgrp=apps handle=1075810300
> >> 12-11 17:22:46.876: I/dalvikvm(7850):   | state=R schedstat=( 0 0 0 )
> >> utm=257 stm=76 core=1
> >> 12-11 17:22:46.892: I/dalvikvm(7850):   #00  pc 000012fe
> >> /system/lib/libcorkscrew.so (unwind_backtrace_thread+29)
> >> 12-11 17:22:46.892: I/dalvikvm(7850):   #01  pc 0005fff6
> >> /system/lib/libdvm.so (dvmDumpNativeStack(DebugOutputTarget const*,
> >> int)+33)
> >> 12-11 17:22:46.892: I/dalvikvm(7850):   #02  pc 00054080
> >> /system/lib/libdvm.so (dvmDumpThreadEx(DebugOutputTarget const*,
> >> Thread*, bool)+395)
> >> 12-11 17:22:46.892: I/dalvikvm(7850):   #03  pc 000540ee
> >> /system/lib/libdvm.so (dvmDumpThread(Thread*, bool)+25)
> >> 12-11 17:22:46.892: I/dalvikvm(7850):   #04  pc 000386a8
> >> /system/lib/libdvm.so
> >> 12-11 17:22:46.892: I/dalvikvm(7850):   #05  pc 00039a74
> >> /system/lib/libdvm.so
> >> 12-11 17:22:46.892: I/dalvikvm(7850):   #06  pc 0003be46
> >> /system/lib/libdvm.so
> >> 12-11 17:22:46.900: I/dalvikvm(7850):   #07  pc 0002c516
> >> /system/lib/libjavacore.so (_jobjectArray*
> >> toStringArray<VectorCounter, VectorGetter>(_JNIEnv*, VectorCounter*,
> >> VectorGetter*)+73)
> >> 12-11 17:22:46.900: I/dalvikvm(7850):   #08  pc 0002c572
> >> /system/lib/libjavacore.so (toStringArray(_JNIEnv*,
> >> std::vector<std::string, std::allocator<std::string> > const&)+9)
> >> 12-11 17:22:46.900: I/dalvikvm(7850):   #09  pc 00014d66
> >> /system/lib/libjavacore.so
> >> 12-11 17:22:46.900: I/dalvikvm(7850):   #10  pc 0001dc4c
> >> /system/lib/libdvm.so (dvmPlatformInvoke+112)
> >> 12-11 17:22:46.900: I/dalvikvm(7850):   #11  pc 0004dece
> >> /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*,
> >> Method const*, Thread*)+397)
> >> 12-11 17:22:46.900: I/dalvikvm(7850):   #12  pc 00027060
> >> /system/lib/libdvm.so
> >> 12-11 17:22:46.900: I/dalvikvm(7850):   #13  pc 0002b5ec
> >> /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*,
> JValue*)+184)
> >> 12-11 17:22:46.900: I/dalvikvm(7850):   #14  pc 000601de
> >> /system/lib/libdvm.so (dvmInvokeMethod(Object*, Method const*,
> >> ArrayObject*, ArrayObject*, ClassObject*, bool)+349)
> >> 12-11 17:22:46.900: I/dalvikvm(7850):   #15  pc 00067dde
> >> /system/lib/libdvm.so
> >> 12-11 17:22:46.900: I/dalvikvm(7850):   #16  pc 00027060
> >> /system/lib/libdvm.so
> >> 12-11 17:22:46.900: I/dalvikvm(7850):   #17  pc 0002b5ec
> >> /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*,
> JValue*)+184)
> >> 12-11 17:22:46.900: I/dalvikvm(7850):   #18  pc 0005ff20
> >> /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*,
> >> bool, JValue*, std::__va_list)+291)
> >> 12-11 17:22:46.900: I/dalvikvm(7850):   #19  pc 00049b66
> >> /system/lib/libdvm.so
> >> 12-11 17:22:46.900: I/dalvikvm(7850):   #20  pc 0004b694
> >> /system/lib/libandroid_runtime.so
> >> 12-11 17:22:46.900: I/dalvikvm(7850):   #21  pc 0004c326
> >> /system/lib/libandroid_runtime.so (android::AndroidRuntime::start(char
> >> const*, char const*)+377)
> >> 12-11 17:22:46.900: I/dalvikvm(7850):   #22  pc 0000105a
> >> /system/bin/app_process
> >> 12-11 17:22:46.900: I/dalvikvm(7850):   #23  pc 0000db4c
> >> /system/lib/libc.so (__libc_init+47)
> >> 12-11 17:22:46.900: I/dalvikvm(7850):   at
> >> java.io.File.listImpl(Native Method)
> >> 12-11 17:22:46.900: I/dalvikvm(7850):   at
> >> java.io.File.list(File.java:749)
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> >> Groups "Android Developers" group.
> >> To post to this group, send email to
> >> [email protected]
> >> <mailto:[email protected]>
> >> To unsubscribe from this group, send email to
> >> [email protected]
> >> <mailto:[email protected]>
> >> For more options, visit this group at
> >> http://groups.google.com/group/android-developers?hl=en
> >> ---
> >> You received this message because you are subscribed to the Google
> >> Groups "Android Developers" group.
> >> To unsubscribe from this group and stop receiving emails from it, send
> >> an email to [email protected]
> >> <mailto:[email protected]>.
> >> For more options, visit https://groups.google.com/groups/opt_out.
> >> <file_list_crash.zip>
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]
> > For more options, visit this group at
> > http://groups.google.com/group/android-developers?hl=en
> > ---
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> > an email to [email protected].
> > For more options, visit https://groups.google.com/groups/opt_out.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Android Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to