[android-developers] There are so many Android app developers just insist the external storage access

2017-02-12 Thread Dewr
Even though Google provides ways to give and take between apps without 
losing the secure filesystem isolation - e.g. ACTION_GET_CONTENT and the 
sharing system - there are so many Android app developers who just insist 
the external storage access.

So I would really love to see Google provide normal users, every Android 
user, with the ability to 'setfacl' or the ability to group apps and set 
group permissions on files or directories.

Best Wishes,
Nicholas Gim
>From Seoul, South Korea

-- 
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 android-developers+unsubscr...@googlegroups.com.
To post to this group, send email to android-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/bac444a6-37ae-4646-bb2d-d8850e23301d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [android-developers] Re: SIGSEGV on free()

2011-03-23 Thread Dewr
thank you guys. I really appreciate your advice.
I have debugged by putting this 1 line code right after free(strBuf);
(though there is no repeating free(strBuf)...)

> strBuf = NULL;
>
thank you! :D

2011/3/24 Hari Edo 

>
> This has nothing to do with Android, per se.
>
>
> Calling free(x) when x is NULL is not harmful.
> Calling free(x) when x came from malloc() is not harmful.
> Calling free(x) twice with the same value of x will surely SIGSEGV.
> Calling free(x) with a bad value will likely SIGSEGV.
>
> Note case 3:  if you call free(x), follow it immediately with x=NULL,
> and you will probably not crash anymore.  Matching your malloc()/
> free()
> calls carefully and logically tends to fix such problems.
>
>
>
>
> On Mar 22, 4:26 am, Dewr  wrote:
> > I have tested it on Galaxy S and it worked well on Galaxy S (2.2). I have
> > not tried it on another Nexus One in order to know if my Nexus One is
> > faulty.
> >
> > and it seems like that AssetFileDescriptor is not the source of the
> problem,
> > because the problem is still ocurring while I didn't access asset files
> > directly but accessing copied ones.
> >
> >
> >
> > On Fri, Feb 25, 2011 at 1:10 PM, Dewr  wrote:
> > > it often causes SIGSEGV on third for-loop. but just a moment ago
> SIGSEGV on
> > > fourth loop.
> >
> > >> for ( i = 0 ; i < 4 ; i++ ) {
> > >> sprintf (temp, "%s%s", header[i], index[fileno[i]]);
> > >> *strBuf = getTextByIndex(&filebuf, temp);* *//malloc() in this
> > >> function.*
> > >> if (strBuf == NULL)
> > >>     buf_output[i] = NULL;
> > >> else
> >
> > >> {
> > >> buf_output[i] = (*gEnv)->NewStringUTF(gEnv, strBuf);
> > >> *free(strBuf);*
> > >> }
> > >> }
> >
> > > On Thu, Feb 24, 2011 at 1:15 PM, Dewr  wrote:
> >
> > >> Hello, I am porting a C program.
> >
> > >> The problem I've met is SIGSEGV on free(). I can't see what's the root
> > >> cause of it.
> > >> it doesn't occur sometimes, but very often.
> >
> > >> I am testing it on NexusOne 2.2.1
> > >> I am using Android NDK r5b and Android SDK and Eclipse ADT and Cygwin.
> >
> > >> I am using *android.content.res.AssetFileDescriptor* to read assets in
> C
> > >> modules.
> >
> > >> Here is the messages in ndk-gdb when the problem appears.
> >
> > >>> (gdb) c
> > >>> Continuing.
> >
> > >>> Breakpoint 2, Java_kr_co_pkbio_Unse_DangSaJuShinSal (env=0xaa50,
> > >>> obj=0x4495b970)
> > >>> at
> > >>>
> C:/DEWR/Product/Software-Engineering/Eclipse-Workspace/Unse/jni/unse.c:1
> > >>> 83
> > >>> *1083free(strBuf);*
> > >>> (gdb) next
> >
> > >>> *Program received signal SIGSEGV, Segmentation fault.*
> > >>> *0xafd11c80 in __libc_android_abort ()*
> > >>>from
> > >>>
> C:/DEWR/Product/Software-Engineering/Eclipse-Workspace/Unse/obj/local/a
> > >>> meabi/libc.so
> > >>> (gdb) bt
> > >>> #0  0xafd11c80 in __libc_android_abort ()
> > >>>from
> > >>>
> C:/DEWR/Product/Software-Engineering/Eclipse-Workspace/Unse/obj/local/a
> > >>> meabi/libc.so
> > >>> #1  0xbec233bc in ?? ()
> > >>> Cannot access memory at address 0xc
> > >>> (gdb) quit
> >
> > >> Here is the Java source code...
> >
> > >>> public static FileInfoForNativeCode openAssets(String fname) {
> > >>> if (Constants.VERBOSE_LOGS)
> > >>> Log.d(TAG, "openAssets("+fname+")");
> >
> > >>> *AssetFileDescriptor myDescriptor = null;*
> > >>> try {
> > >>> myDescriptor = context.getAssets().openFd(fname+".jet");
> > >>> } catch (IOException e) {
> > >>> e.printStackTrace();
> > >>> return null;
> > >>> }
> > >>> FileDescriptor fd = myDescriptor.getFileDescriptor();
> > >>> long off = myDescriptor.getStartOffset();
> > >>> long len = myDescriptor.getLength();
> >
> > >>> 

[android-developers] Re: [bionic-c-lib] SIGSEGV on free()

2011-03-22 Thread Dewr
I have tested it on Galaxy S and it worked well on Galaxy S (2.2). I have
not tried it on another Nexus One in order to know if my Nexus One is
faulty.

and it seems like that AssetFileDescriptor is not the source of the problem,
because the problem is still ocurring while I didn't access asset files
directly but accessing copied ones.

On Fri, Feb 25, 2011 at 1:10 PM, Dewr  wrote:

> it often causes SIGSEGV on third for-loop. but just a moment ago SIGSEGV on
> fourth loop.
>
>> for ( i = 0 ; i < 4 ; i++ ) {
>> sprintf (temp, "%s%s", header[i], index[fileno[i]]);
>> *strBuf = getTextByIndex(&filebuf, temp);* *//malloc() in this
>> function.*
>> if (strBuf == NULL)
>> buf_output[i] = NULL;
>> else
>>
>> {
>> buf_output[i] = (*gEnv)->NewStringUTF(gEnv, strBuf);
>> *free(strBuf);*
>> }
>> }
>>
>
> On Thu, Feb 24, 2011 at 1:15 PM, Dewr  wrote:
>
>> Hello, I am porting a C program.
>>
>> The problem I've met is SIGSEGV on free(). I can't see what's the root
>> cause of it.
>> it doesn't occur sometimes, but very often.
>>
>> I am testing it on NexusOne 2.2.1
>> I am using Android NDK r5b and Android SDK and Eclipse ADT and Cygwin.
>>
>> I am using *android.content.res.AssetFileDescriptor* to read assets in C
>> modules.
>>
>> Here is the messages in ndk-gdb when the problem appears.
>>
>>> (gdb) c
>>> Continuing.
>>>
>>> Breakpoint 2, Java_kr_co_pkbio_Unse_DangSaJuShinSal (env=0xaa50,
>>> obj=0x4495b970)
>>> at
>>> C:/DEWR/Product/Software-Engineering/Eclipse-Workspace/Unse/jni/unse.c:1
>>> 83
>>> *1083free(strBuf);*
>>> (gdb) next
>>>
>>> *Program received signal SIGSEGV, Segmentation fault.*
>>> *0xafd11c80 in __libc_android_abort ()*
>>>from
>>> C:/DEWR/Product/Software-Engineering/Eclipse-Workspace/Unse/obj/local/a
>>> meabi/libc.so
>>> (gdb) bt
>>> #0  0xafd11c80 in __libc_android_abort ()
>>>from
>>> C:/DEWR/Product/Software-Engineering/Eclipse-Workspace/Unse/obj/local/a
>>> meabi/libc.so
>>> #1  0xbec233bc in ?? ()
>>> Cannot access memory at address 0xc
>>> (gdb) quit
>>>
>>
>> Here is the Java source code...
>>
>>> public static FileInfoForNativeCode openAssets(String fname) {
>>> if (Constants.VERBOSE_LOGS)
>>> Log.d(TAG, "openAssets("+fname+")");
>>>
>>> *AssetFileDescriptor myDescriptor = null;*
>>> try {
>>> myDescriptor = context.getAssets().openFd(fname+".jet");
>>> } catch (IOException e) {
>>> e.printStackTrace();
>>> return null;
>>> }
>>> FileDescriptor fd = myDescriptor.getFileDescriptor();
>>> long off = myDescriptor.getStartOffset();
>>> long len = myDescriptor.getLength();
>>>
>>> if (Constants.VERBOSE_LOGS)
>>> Log.d(TAG, "fd:"+fd+" off:"+off+" len:"+len);
>>>
>>> return new FileInfoForNativeCode(off, len, fd);
>>> }
>>>
>>
>> Here is the C source code...
>>
>>> char* getTextByIndex (TextFileBufType *filebuf, char *index) {
>>> #define _INDEX_PREFIX_'@'
>>> inti, j, lenBuf;
>>> char*result;
>>> charindexPrefix = _INDEX_PREFIX_;
>>> intlenIndexPrefix = utf8len( &indexPrefix );
>>> intlenIndex = strlen(index);
>>>
>>> for ( i = 0 ; i < filebuf->total ; i++ ) {
>>> *//__android_log_print(ANDROID_LOG_DEBUG,"TAG", "JNI : %d ->
>>> %s", i, filebuf->text[i]);*
>>>
>>> if ( memcmp (filebuf->text[i], &indexPrefix, lenIndexPrefix) != 0
>>> )
>>> continue;
>>>
>>> if ( memcmp (filebuf->text[i]+lenIndexPrefix, index, lenIndex) !=
>>> 0 )
>>> continue;
>>>
>>> lenBuf = 0;
>>> lenBuf += strlen(filebuf->text[i]);
>>> lenBuf++;
>>> for ( j = i+1 ; j < filebuf->total ; j++ ) {
>>> if ( memcmp (filebuf->text[j], &indexPrefix, lenIndexPrefix)
>>> 

[android-developers] Re: [bionic-c-lib] SIGSEGV on free()

2011-02-24 Thread Dewr
it often causes SIGSEGV on third for-loop. but just a moment ago SIGSEGV on
fourth loop.

> for ( i = 0 ; i < 4 ; i++ ) {
> sprintf (temp, "%s%s", header[i], index[fileno[i]]);
> *strBuf = getTextByIndex(&filebuf, temp);* *//malloc() in this
> function.*
> if (strBuf == NULL)
> buf_output[i] = NULL;
> else
> {
> buf_output[i] = (*gEnv)->NewStringUTF(gEnv, strBuf);
> *free(strBuf);*
>     }
> }
>

On Thu, Feb 24, 2011 at 1:15 PM, Dewr  wrote:

> Hello, I am porting a C program.
>
> The problem I've met is SIGSEGV on free(). I can't see what's the root
> cause of it.
> it doesn't occur sometimes, but very often.
>
> I am testing it on NexusOne 2.2.1
> I am using Android NDK r5b and Android SDK and Eclipse ADT and Cygwin.
>
> I am using *android.content.res.AssetFileDescriptor* to read assets in C
> modules.
>
> Here is the messages in ndk-gdb when the problem appears.
>
>> (gdb) c
>> Continuing.
>>
>> Breakpoint 2, Java_kr_co_pkbio_Unse_DangSaJuShinSal (env=0xaa50,
>> obj=0x4495b970)
>> at
>> C:/DEWR/Product/Software-Engineering/Eclipse-Workspace/Unse/jni/unse.c:1
>> 83
>> *1083free(strBuf);*
>> (gdb) next
>>
>> *Program received signal SIGSEGV, Segmentation fault.*
>> *0xafd11c80 in __libc_android_abort ()*
>>from
>> C:/DEWR/Product/Software-Engineering/Eclipse-Workspace/Unse/obj/local/a
>> meabi/libc.so
>> (gdb) bt
>> #0  0xafd11c80 in __libc_android_abort ()
>>from
>> C:/DEWR/Product/Software-Engineering/Eclipse-Workspace/Unse/obj/local/a
>> meabi/libc.so
>> #1  0xbec233bc in ?? ()
>> Cannot access memory at address 0xc
>> (gdb) quit
>>
>
> Here is the Java source code...
>
>> public static FileInfoForNativeCode openAssets(String fname) {
>> if (Constants.VERBOSE_LOGS)
>> Log.d(TAG, "openAssets("+fname+")");
>>
>> *AssetFileDescriptor myDescriptor = null;*
>> try {
>> myDescriptor = context.getAssets().openFd(fname+".jet");
>> } catch (IOException e) {
>> e.printStackTrace();
>> return null;
>> }
>> FileDescriptor fd = myDescriptor.getFileDescriptor();
>> long off = myDescriptor.getStartOffset();
>> long len = myDescriptor.getLength();
>>
>> if (Constants.VERBOSE_LOGS)
>> Log.d(TAG, "fd:"+fd+" off:"+off+" len:"+len);
>>
>> return new FileInfoForNativeCode(off, len, fd);
>> }
>>
>
> Here is the C source code...
>
>> char* getTextByIndex (TextFileBufType *filebuf, char *index) {
>> #define _INDEX_PREFIX_'@'
>> inti, j, lenBuf;
>> char*result;
>> charindexPrefix = _INDEX_PREFIX_;
>> intlenIndexPrefix = utf8len( &indexPrefix );
>> intlenIndex = strlen(index);
>>
>> for ( i = 0 ; i < filebuf->total ; i++ ) {
>> *//__android_log_print(ANDROID_LOG_DEBUG,"TAG", "JNI : %d -> %s",
>> i, filebuf->text[i]);*
>>
>> if ( memcmp (filebuf->text[i], &indexPrefix, lenIndexPrefix) != 0
>> )
>> continue;
>>
>> if ( memcmp (filebuf->text[i]+lenIndexPrefix, index, lenIndex) !=
>> 0 )
>> continue;
>>
>> lenBuf = 0;
>> lenBuf += strlen(filebuf->text[i]);
>> lenBuf++;
>> for ( j = i+1 ; j < filebuf->total ; j++ ) {
>> if ( memcmp (filebuf->text[j], &indexPrefix, lenIndexPrefix)
>> == 0 )
>> break;
>>
>> lenBuf += strlen(filebuf->text[j]);
>> lenBuf++;
>> }
>>
>> *result = malloc(lenBuf);*
>> result[0] = 0;
>> strcat(result, filebuf->text[i]);
>> strcat(result, "\n");
>> for ( j = i+1 ; j < filebuf->total ; j++ ) {
>> if ( memcmp (filebuf->text[j], &indexPrefix, lenIndexPrefix)
>> == 0 )
>> break;
>>
>> strcat(result, filebuf->text[j]);
>> strcat(result, "\n");
>> }
>>
>> *//__android_log_print(ANDROID_LOG_DEBUG,"TAG", "JNI : %d!!! ->
>> %s", i, filebuf->text[i]);*
>

[android-developers] Re: [bionic-c-lib] SIGSEGV on free()

2011-02-24 Thread Dewr
I am controlling lifetime of AssetFileDescriptors. I don't use terminated
FileDescriptors.

Do I have to re-code I/O routines in Java or not to free allocated memories?

On Thu, Feb 24, 2011 at 1:15 PM, Dewr  wrote:

> Hello, I am porting a C program.
>
> The problem I've met is SIGSEGV on free(). I can't see what's the root
> cause of it.
> it doesn't occur sometimes, but very often.
>
> I am testing it on NexusOne 2.2.1
> I am using Android NDK r5b and Android SDK and Eclipse ADT and Cygwin.
>
> I am using *android.content.res.AssetFileDescriptor* to read assets in C
> modules.
>
> Here is the messages in ndk-gdb when the problem appears.
>
>> (gdb) c
>> Continuing.
>>
>> Breakpoint 2, Java_kr_co_pkbio_Unse_DangSaJuShinSal (env=0xaa50,
>> obj=0x4495b970)
>> at
>> C:/DEWR/Product/Software-Engineering/Eclipse-Workspace/Unse/jni/unse.c:1
>> 83
>> *1083free(strBuf);*
>> (gdb) next
>>
>> *Program received signal SIGSEGV, Segmentation fault.*
>> *0xafd11c80 in __libc_android_abort ()*
>>from
>> C:/DEWR/Product/Software-Engineering/Eclipse-Workspace/Unse/obj/local/a
>> meabi/libc.so
>> (gdb) bt
>> #0  0xafd11c80 in __libc_android_abort ()
>>from
>> C:/DEWR/Product/Software-Engineering/Eclipse-Workspace/Unse/obj/local/a
>> meabi/libc.so
>> #1  0xbec233bc in ?? ()
>> Cannot access memory at address 0xc
>> (gdb) quit
>>
>
> Here is the Java source code...
>
>> public static FileInfoForNativeCode openAssets(String fname) {
>> if (Constants.VERBOSE_LOGS)
>> Log.d(TAG, "openAssets("+fname+")");
>>
>> *AssetFileDescriptor myDescriptor = null;*
>> try {
>> myDescriptor = context.getAssets().openFd(fname+".jet");
>> } catch (IOException e) {
>> e.printStackTrace();
>> return null;
>> }
>> FileDescriptor fd = myDescriptor.getFileDescriptor();
>> long off = myDescriptor.getStartOffset();
>> long len = myDescriptor.getLength();
>>
>> if (Constants.VERBOSE_LOGS)
>> Log.d(TAG, "fd:"+fd+" off:"+off+" len:"+len);
>>
>> return new FileInfoForNativeCode(off, len, fd);
>> }
>>
>
> Here is the C source code...
>
>> char* getTextByIndex (TextFileBufType *filebuf, char *index) {
>> #define _INDEX_PREFIX_'@'
>> inti, j, lenBuf;
>> char*result;
>> charindexPrefix = _INDEX_PREFIX_;
>> intlenIndexPrefix = utf8len( &indexPrefix );
>> intlenIndex = strlen(index);
>>
>> for ( i = 0 ; i < filebuf->total ; i++ ) {
>> *//__android_log_print(ANDROID_LOG_DEBUG,"TAG", "JNI : %d -> %s",
>> i, filebuf->text[i]);*
>>
>> if ( memcmp (filebuf->text[i], &indexPrefix, lenIndexPrefix) != 0
>> )
>> continue;
>>
>> if ( memcmp (filebuf->text[i]+lenIndexPrefix, index, lenIndex) !=
>> 0 )
>> continue;
>>
>> lenBuf = 0;
>> lenBuf += strlen(filebuf->text[i]);
>> lenBuf++;
>> for ( j = i+1 ; j < filebuf->total ; j++ ) {
>> if ( memcmp (filebuf->text[j], &indexPrefix, lenIndexPrefix)
>> == 0 )
>> break;
>>
>> lenBuf += strlen(filebuf->text[j]);
>> lenBuf++;
>> }
>>
>> *result = malloc(lenBuf);*
>> result[0] = 0;
>> strcat(result, filebuf->text[i]);
>> strcat(result, "\n");
>> for ( j = i+1 ; j < filebuf->total ; j++ ) {
>> if ( memcmp (filebuf->text[j], &indexPrefix, lenIndexPrefix)
>> == 0 )
>> break;
>>
>> strcat(result, filebuf->text[j]);
>> strcat(result, "\n");
>> }
>>
>> *//__android_log_print(ANDROID_LOG_DEBUG,"TAG", "JNI : %d!!! ->
>> %s", i, filebuf->text[i]);*
>> *return result;*
>> }
>>
>> return NULL;
>>
>> #undef _INDEX_PREFIX_
>> }
>>
>> inline void readyFileInFile (FileInFile *fif, char *path)
>> {
>> jstring jstrFpath;
>> jobject finfo;
>> jobject descriptor;
>>
>> jstrFpath = (*gEnv)-

[android-developers] Re: [bionic-c-lib] SIGSEGV on free()

2011-02-23 Thread Dewr
malloc didn't return NULL. so memories maybe allocated correctly.

On Thu, Feb 24, 2011 at 1:15 PM, Dewr  wrote:

> Hello, I am porting a C program.
>
> The problem I've met is SIGSEGV on free(). I can't see what's the root
> cause of it.
> it doesn't occur sometimes, but very often.
>
> I am testing it on NexusOne 2.2.1
> I am using Android NDK r5b and Android SDK and Eclipse ADT and Cygwin.
>
> I am using *android.content.res.AssetFileDescriptor* to read assets in C
> modules.
>
> Here is the messages in ndk-gdb when the problem appears.
>
>> (gdb) c
>> Continuing.
>>
>> Breakpoint 2, Java_kr_co_pkbio_Unse_DangSaJuShinSal (env=0xaa50,
>> obj=0x4495b970)
>> at
>> C:/DEWR/Product/Software-Engineering/Eclipse-Workspace/Unse/jni/unse.c:1
>> 83
>> *1083free(strBuf);*
>> (gdb) next
>>
>> *Program received signal SIGSEGV, Segmentation fault.*
>> *0xafd11c80 in __libc_android_abort ()*
>>from
>> C:/DEWR/Product/Software-Engineering/Eclipse-Workspace/Unse/obj/local/a
>> meabi/libc.so
>> (gdb) bt
>> #0  0xafd11c80 in __libc_android_abort ()
>>from
>> C:/DEWR/Product/Software-Engineering/Eclipse-Workspace/Unse/obj/local/a
>> meabi/libc.so
>> #1  0xbec233bc in ?? ()
>> Cannot access memory at address 0xc
>> (gdb) quit
>>
>
> Here is the Java source code...
>
>> public static FileInfoForNativeCode openAssets(String fname) {
>> if (Constants.VERBOSE_LOGS)
>> Log.d(TAG, "openAssets("+fname+")");
>>
>> *AssetFileDescriptor myDescriptor = null;*
>> try {
>> myDescriptor = context.getAssets().openFd(fname+".jet");
>> } catch (IOException e) {
>> e.printStackTrace();
>> return null;
>> }
>> FileDescriptor fd = myDescriptor.getFileDescriptor();
>> long off = myDescriptor.getStartOffset();
>> long len = myDescriptor.getLength();
>>
>> if (Constants.VERBOSE_LOGS)
>> Log.d(TAG, "fd:"+fd+" off:"+off+" len:"+len);
>>
>> return new FileInfoForNativeCode(off, len, fd);
>> }
>>
>
> Here is the C source code...
>
>> char* getTextByIndex (TextFileBufType *filebuf, char *index) {
>> #define _INDEX_PREFIX_'@'
>> inti, j, lenBuf;
>> char*result;
>> charindexPrefix = _INDEX_PREFIX_;
>> intlenIndexPrefix = utf8len( &indexPrefix );
>> intlenIndex = strlen(index);
>>
>> for ( i = 0 ; i < filebuf->total ; i++ ) {
>> *//__android_log_print(ANDROID_LOG_DEBUG,"TAG", "JNI : %d -> %s",
>> i, filebuf->text[i]);*
>>
>> if ( memcmp (filebuf->text[i], &indexPrefix, lenIndexPrefix) != 0
>> )
>> continue;
>>
>> if ( memcmp (filebuf->text[i]+lenIndexPrefix, index, lenIndex) !=
>> 0 )
>> continue;
>>
>> lenBuf = 0;
>> lenBuf += strlen(filebuf->text[i]);
>> lenBuf++;
>> for ( j = i+1 ; j < filebuf->total ; j++ ) {
>> if ( memcmp (filebuf->text[j], &indexPrefix, lenIndexPrefix)
>> == 0 )
>> break;
>>
>> lenBuf += strlen(filebuf->text[j]);
>> lenBuf++;
>> }
>>
>> *result = malloc(lenBuf);*
>> result[0] = 0;
>> strcat(result, filebuf->text[i]);
>> strcat(result, "\n");
>> for ( j = i+1 ; j < filebuf->total ; j++ ) {
>> if ( memcmp (filebuf->text[j], &indexPrefix, lenIndexPrefix)
>> == 0 )
>> break;
>>
>> strcat(result, filebuf->text[j]);
>> strcat(result, "\n");
>> }
>>
>> *//__android_log_print(ANDROID_LOG_DEBUG,"TAG", "JNI : %d!!! ->
>> %s", i, filebuf->text[i]);*
>> *return result;*
>> }
>>
>> return NULL;
>>
>> #undef _INDEX_PREFIX_
>> }
>>
>> inline void readyFileInFile (FileInFile *fif, char *path)
>> {
>> jstring jstrFpath;
>> jobject finfo;
>> jobject descriptor;
>>
>> jstrFpath = (*gEnv)->NewStringUTF(gEnv, path);
>> finfo = (*gEnv)->CallStaticObjectMethod(gEnv, clsUtility,
>> midOpenA

[android-developers] [bionic-c-lib] SIGSEGV on free()

2011-02-23 Thread Dewr
Hello, I am porting a C program.

The problem I've met is SIGSEGV on free(). I can't see what's the root cause
of it.
it doesn't occur sometimes, but very often.

I am testing it on NexusOne 2.2.1
I am using Android NDK r5b and Android SDK and Eclipse ADT and Cygwin.

I am using *android.content.res.AssetFileDescriptor* to read assets in C
modules.

Here is the messages in ndk-gdb when the problem appears.

> (gdb) c
> Continuing.
>
> Breakpoint 2, Java_kr_co_pkbio_Unse_DangSaJuShinSal (env=0xaa50,
> obj=0x4495b970)
> at
> C:/DEWR/Product/Software-Engineering/Eclipse-Workspace/Unse/jni/unse.c:1
> 83
> *1083free(strBuf);*
> (gdb) next
>
> *Program received signal SIGSEGV, Segmentation fault.*
> *0xafd11c80 in __libc_android_abort ()*
>from
> C:/DEWR/Product/Software-Engineering/Eclipse-Workspace/Unse/obj/local/a
> meabi/libc.so
> (gdb) bt
> #0  0xafd11c80 in __libc_android_abort ()
>from
> C:/DEWR/Product/Software-Engineering/Eclipse-Workspace/Unse/obj/local/a
> meabi/libc.so
> #1  0xbec233bc in ?? ()
> Cannot access memory at address 0xc
> (gdb) quit
>

Here is the Java source code...

> public static FileInfoForNativeCode openAssets(String fname) {
> if (Constants.VERBOSE_LOGS)
> Log.d(TAG, "openAssets("+fname+")");
>
> *AssetFileDescriptor myDescriptor = null;*
> try {
> myDescriptor = context.getAssets().openFd(fname+".jet");
> } catch (IOException e) {
> e.printStackTrace();
> return null;
> }
> FileDescriptor fd = myDescriptor.getFileDescriptor();
> long off = myDescriptor.getStartOffset();
> long len = myDescriptor.getLength();
>
> if (Constants.VERBOSE_LOGS)
> Log.d(TAG, "fd:"+fd+" off:"+off+" len:"+len);
>
> return new FileInfoForNativeCode(off, len, fd);
> }
>

Here is the C source code...

> char* getTextByIndex (TextFileBufType *filebuf, char *index) {
> #define _INDEX_PREFIX_'@'
> inti, j, lenBuf;
> char*result;
> charindexPrefix = _INDEX_PREFIX_;
> intlenIndexPrefix = utf8len( &indexPrefix );
> intlenIndex = strlen(index);
>
> for ( i = 0 ; i < filebuf->total ; i++ ) {
> *//__android_log_print(ANDROID_LOG_DEBUG,"TAG", "JNI : %d -> %s",
> i, filebuf->text[i]);*
>
> if ( memcmp (filebuf->text[i], &indexPrefix, lenIndexPrefix) != 0 )
> continue;
>
> if ( memcmp (filebuf->text[i]+lenIndexPrefix, index, lenIndex) != 0
> )
> continue;
>
> lenBuf = 0;
> lenBuf += strlen(filebuf->text[i]);
> lenBuf++;
> for ( j = i+1 ; j < filebuf->total ; j++ ) {
> if ( memcmp (filebuf->text[j], &indexPrefix, lenIndexPrefix) ==
> 0 )
> break;
>
> lenBuf += strlen(filebuf->text[j]);
> lenBuf++;
> }
>
> *result = malloc(lenBuf);*
> result[0] = 0;
> strcat(result, filebuf->text[i]);
> strcat(result, "\n");
> for ( j = i+1 ; j < filebuf->total ; j++ ) {
> if ( memcmp (filebuf->text[j], &indexPrefix, lenIndexPrefix) ==
> 0 )
> break;
>
> strcat(result, filebuf->text[j]);
> strcat(result, "\n");
> }
>
> *//__android_log_print(ANDROID_LOG_DEBUG,"TAG", "JNI : %d!!! ->
> %s", i, filebuf->text[i]);*
> *return result;*
> }
>
> return NULL;
>
> #undef _INDEX_PREFIX_
> }
>
> inline void readyFileInFile (FileInFile *fif, char *path)
> {
> jstring jstrFpath;
> jobject finfo;
> jobject descriptor;
>
> jstrFpath = (*gEnv)->NewStringUTF(gEnv, path);
> finfo = (*gEnv)->CallStaticObjectMethod(gEnv, clsUtility,
> midOpenAssets, jstrFpath);
> fif->offset = (*gEnv)->GetLongField(gEnv, finfo, fidOffset);
> fif->length = (*gEnv)->GetLongField(gEnv, finfo, fidLength);
> descriptor = (*gEnv)->GetObjectField(gEnv, finfo, fidDescriptor);
> fif->fd = (*gEnv)->GetIntField(gEnv, descriptor,
> fidDescriptorFileDescriptor);
> }
>
> jobjectArray Java_kr_co_pkbio_Unse_DangSaJuShinSal (JNIEnv *env, jobject
> obj) {
> *//char   *fname = "DangSaJu_ShinSal";*
> int i, fileno[4], ret_code, type;
> chartemp[256];
> char   *header[4] = { "년", "월", "일&quo

[android-developers] Re: ndk-gdb on cygwin/windowsXP won't load symbol tables.

2011-02-22 Thread Dewr
Today, I deleted this line, but ndk-gdb still does the jobs well.

> LOCAL_CFLAGS := -g #debug
>

On Wed, Feb 9, 2011 at 12:00 PM, Dewr  wrote:

> at before, I have put codes above of 'include $(CLEAR_VARS)' stupidly.
>
>
> On Wed, Feb 9, 2011 at 11:15 AM, Dewr  wrote:
>
>> I has done this job by editing Android.mk.
>> moving 'LOCAL_CFLAGS := -g #debug' line to below of 'LOCAL_MODULE:=
>> libxxx'
>>
>> here is my Android.mk
>>
>>> LOCAL_PATH := $(call my-dir)
>>>
>>> include $(CLEAR_VARS)
>>>
>>> LOCAL_MODULE:= libunse
>>>
>>> LOCAL_CFLAGS := -g #debug
>>> LOCAL_LDFLAGS := -Wl,-Map,xxx.map #create map file
>>>
>>> LOCAL_SRC_FILES := \
>>> android_helper.c \
>>> str_lib.c \
>>> io_lib.c \
>>> xxx.c \
>>> util.c
>>> LOCAL_LDLIBS := -llog #logcat
>>>
>>> include $(BUILD_SHARED_LIBRARY)
>>>
>>
>>
>> On Mon, Feb 7, 2011 at 1:39 PM, Dewr  wrote:
>>
>>> I havn't tried ndk-gdb on other OSs. but I had tried on WindowsXP. (using
>>> ndk-gdb r5b)
>>> and just seeing same message 'no symbol table is loaded!' when I type 'b
>>> io_lib.c:227'.
>>>
>>> I have tried ' set solib-search-path /cygdrive/c/.../obj/local/armeabi ',
>>> ' set solib-search-path "/cygdrive/c/.../obj/local/armeabi" ',
>>> ' set solib-search-path '/cygdrive/c/.../obj/local/armeabi' '
>>> in gdb. :q
>>>
>>> has anyone successed to put breakpoints and breaked by the points on
>>> Windows XP?
>>>
>>> # ndk-gdb
>>>> GNU gdb 6.6
>>>> Copyright (C) 2006 Free Software Foundation, Inc.
>>>> GDB is free software, covered by the GNU General Public License, and you
>>>> are
>>>> welcome to change it and/or distribute copies of it under certain
>>>> conditions.
>>>> Type "show copying" to see the conditions.
>>>> There is absolutely no warranty for GDB.  Type "show warranty" for
>>>> details.
>>>> This GDB was configured as "--host=i586-mingw32msvc
>>>> --target=arm-elf-linux".
>>>> (no debugging symbols found)
>>>> Error while mapping shared library sections:
>>>> /system/bin/linker: No such file or directory.
>>>> Error while mapping shared library sections:
>>>> libstdc++.so: No such file or directory.
>>>> Error while mapping shared library sections:
>>>> libm.so: No such file or directory.
>>>> Error while mapping shared library sections:
>>>> liblog.so: No such file or directory.
>>>> Error while mapping shared library sections:
>>>> libcutils.so: No such file or directory.
>>>> Error while mapping shared library sections:
>>>> libz.so: No such file or directory.
>>>> Error while mapping shared library sections:
>>>> libutils.so: No such file or directory.
>>>> Error while mapping shared library sections:
>>>> libbinder.so: No such file or directory.
>>>> Error while mapping shared library sections:
>>>> libexpat.so: No such file or directory.
>>>> Error while mapping shared library sections:
>>>> libcrypto.so: No such file or directory.
>>>> Error while mapping shared library sections:
>>>> libssl.so: No such file or directory.
>>>> Error while mapping shared library sections:
>>>> libicudata.so: No such file or directory.
>>>> Error while mapping shared library sections:
>>>> libicuuc.so: No such file or directory.
>>>> Error while mapping shared library sections:
>>>> libicui18n.so: No such file or directory.
>>>> Error while mapping shared library sections:
>>>> libsqlite.so: No such file or directory.
>>>> Error while mapping shared library sections:
>>>> libnativehelper.so: No such file or directory.
>>>> Error while mapping shared library sections:
>>>> libnetutils.so: No such file or directory.
>>>> Error while mapping shared library sections:
>>>> libEGL.so: No such file or directory.
>>>> Error while mapping shared library sections:
>>>> libwpa_client.so: No such file or directory.
>>>> Error while mapping shared library sections:
>>>> librpc.so: No such file or directory.
>>>> Error wh

Re: [android-developers] onItemSelectedListener causes gallery to jump, stick and pop...

2011-02-17 Thread Dewr
Hi Richard. Have you solved this problem?
I am getting pain from same problem. :(
But I have seen an app works well smoothly. the name of it is '예스24'.

On 1/13/11, Richard Schilling  wrote:
> I have a gallery on my screen.  Works great and scrolls smoothly ...
> until I set the OnItemSelectedListener.  When I do, Gallery gets
> really "jerkey".  It seems to stick.  I think I know why, but I was
> wondering if others have found a better solution they would be willing
> to share.  Here's my onItemSelectedListener:
>
>
>   myGallery.setOnItemSelectedListener(new 
> OnItemSelectedListener(){
>   @Override
>   public void onItemSelected(AdapterView parent, View 
> view,
>   int position, long id) {
>   // do nothing on purpose to see what the effect 
> is
>   if (view == null)
>   return;
>
>
>   Message msg = Message.obtain();
>   msg.obj = view.getTag();
>   _handler.sendMessage(msg);
>
>   }
>}});
>
> And here is the handler:
>
>
>   private Handler _handler = new Handler(){
>   public void handleMessage(Message msg){
>
>   if (msg.obj != null && msg.obj instanceof String){
>
>   textView1.setText(msg.toString());
>   textView2.setText(msg.toString().length();
>   }
>   }
>   };
>
>
> When the UI thread updates the controls with the data, it seems to
> interrupt the scrolling of the gallery itself and causes the gallery
> to not scroll smoothly.  Commenting out the handler code eliminates
> the problem.
>
> So, I know the problem has to do with the fact that the UI just can't
> update the text controls and keep the gallery scrolling smoothly at
> the same time.
>
> Does anyone have a work around for this problem?
>
> Thanks in advance!
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> 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 post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: ndk-gdb on cygwin/windowsXP won't load symbol tables.

2011-02-08 Thread Dewr
at before, I have put codes above of 'include $(CLEAR_VARS)' stupidly.

On Wed, Feb 9, 2011 at 11:15 AM, Dewr  wrote:

> I has done this job by editing Android.mk.
> moving 'LOCAL_CFLAGS := -g #debug' line to below of 'LOCAL_MODULE:=
> libxxx'
>
> here is my Android.mk
>
>> LOCAL_PATH := $(call my-dir)
>>
>> include $(CLEAR_VARS)
>>
>> LOCAL_MODULE:= libunse
>>
>> LOCAL_CFLAGS := -g #debug
>> LOCAL_LDFLAGS := -Wl,-Map,xxx.map #create map file
>>
>> LOCAL_SRC_FILES := \
>> android_helper.c \
>> str_lib.c \
>> io_lib.c \
>> xxx.c \
>> util.c
>> LOCAL_LDLIBS := -llog #logcat
>>
>> include $(BUILD_SHARED_LIBRARY)
>>
>
>
> On Mon, Feb 7, 2011 at 1:39 PM, Dewr  wrote:
>
>> I havn't tried ndk-gdb on other OSs. but I had tried on WindowsXP. (using
>> ndk-gdb r5b)
>> and just seeing same message 'no symbol table is loaded!' when I type 'b
>> io_lib.c:227'.
>>
>> I have tried ' set solib-search-path /cygdrive/c/.../obj/local/armeabi ',
>> ' set solib-search-path "/cygdrive/c/.../obj/local/armeabi" ',
>> ' set solib-search-path '/cygdrive/c/.../obj/local/armeabi' '
>> in gdb. :q
>>
>> has anyone successed to put breakpoints and breaked by the points on
>> Windows XP?
>>
>> # ndk-gdb
>>> GNU gdb 6.6
>>> Copyright (C) 2006 Free Software Foundation, Inc.
>>> GDB is free software, covered by the GNU General Public License, and you
>>> are
>>> welcome to change it and/or distribute copies of it under certain
>>> conditions.
>>> Type "show copying" to see the conditions.
>>> There is absolutely no warranty for GDB.  Type "show warranty" for
>>> details.
>>> This GDB was configured as "--host=i586-mingw32msvc
>>> --target=arm-elf-linux".
>>> (no debugging symbols found)
>>> Error while mapping shared library sections:
>>> /system/bin/linker: No such file or directory.
>>> Error while mapping shared library sections:
>>> libstdc++.so: No such file or directory.
>>> Error while mapping shared library sections:
>>> libm.so: No such file or directory.
>>> Error while mapping shared library sections:
>>> liblog.so: No such file or directory.
>>> Error while mapping shared library sections:
>>> libcutils.so: No such file or directory.
>>> Error while mapping shared library sections:
>>> libz.so: No such file or directory.
>>> Error while mapping shared library sections:
>>> libutils.so: No such file or directory.
>>> Error while mapping shared library sections:
>>> libbinder.so: No such file or directory.
>>> Error while mapping shared library sections:
>>> libexpat.so: No such file or directory.
>>> Error while mapping shared library sections:
>>> libcrypto.so: No such file or directory.
>>> Error while mapping shared library sections:
>>> libssl.so: No such file or directory.
>>> Error while mapping shared library sections:
>>> libicudata.so: No such file or directory.
>>> Error while mapping shared library sections:
>>> libicuuc.so: No such file or directory.
>>> Error while mapping shared library sections:
>>> libicui18n.so: No such file or directory.
>>> Error while mapping shared library sections:
>>> libsqlite.so: No such file or directory.
>>> Error while mapping shared library sections:
>>> libnativehelper.so: No such file or directory.
>>> Error while mapping shared library sections:
>>> libnetutils.so: No such file or directory.
>>> Error while mapping shared library sections:
>>> libEGL.so: No such file or directory.
>>> Error while mapping shared library sections:
>>> libwpa_client.so: No such file or directory.
>>> Error while mapping shared library sections:
>>> librpc.so: No such file or directory.
>>> Error while mapping shared library sections:
>>> libgps.so: No such file or directory.
>>> Error while mapping shared library sections:
>>> libhardware_legacy.so: No such file or directory.
>>> Error while mapping shared library sections:
>>> libpixelflinger.so: No such file or directory.
>>> Error while mapping shared library sections:
>>> libhardware.so: No such file or directory.
>>> Error while mapping shared library sections:
>>> libui.so: No such file or directory.
>>&

[android-developers] Re: ndk-gdb on cygwin/windowsXP won't load symbol tables.

2011-02-08 Thread Dewr
I has done this job by editing Android.mk.
moving 'LOCAL_CFLAGS := -g #debug' line to below of 'LOCAL_MODULE:=
libxxx'

here is my Android.mk

> LOCAL_PATH := $(call my-dir)
>
> include $(CLEAR_VARS)
>
> LOCAL_MODULE:= libunse
>
> LOCAL_CFLAGS := -g #debug
> LOCAL_LDFLAGS := -Wl,-Map,xxx.map #create map file
>
> LOCAL_SRC_FILES := \
> android_helper.c \
> str_lib.c \
> io_lib.c \
> xxx.c \
> util.c
> LOCAL_LDLIBS := -llog #logcat
>
> include $(BUILD_SHARED_LIBRARY)
>


On Mon, Feb 7, 2011 at 1:39 PM, Dewr  wrote:

> I havn't tried ndk-gdb on other OSs. but I had tried on WindowsXP. (using
> ndk-gdb r5b)
> and just seeing same message 'no symbol table is loaded!' when I type 'b
> io_lib.c:227'.
>
> I have tried ' set solib-search-path /cygdrive/c/.../obj/local/armeabi ',
> ' set solib-search-path "/cygdrive/c/.../obj/local/armeabi" ',
> ' set solib-search-path '/cygdrive/c/.../obj/local/armeabi' '
> in gdb. :q
>
> has anyone successed to put breakpoints and breaked by the points on
> Windows XP?
>
> # ndk-gdb
>> GNU gdb 6.6
>> Copyright (C) 2006 Free Software Foundation, Inc.
>> GDB is free software, covered by the GNU General Public License, and you
>> are
>> welcome to change it and/or distribute copies of it under certain
>> conditions.
>> Type "show copying" to see the conditions.
>> There is absolutely no warranty for GDB.  Type "show warranty" for
>> details.
>> This GDB was configured as "--host=i586-mingw32msvc
>> --target=arm-elf-linux".
>> (no debugging symbols found)
>> Error while mapping shared library sections:
>> /system/bin/linker: No such file or directory.
>> Error while mapping shared library sections:
>> libstdc++.so: No such file or directory.
>> Error while mapping shared library sections:
>> libm.so: No such file or directory.
>> Error while mapping shared library sections:
>> liblog.so: No such file or directory.
>> Error while mapping shared library sections:
>> libcutils.so: No such file or directory.
>> Error while mapping shared library sections:
>> libz.so: No such file or directory.
>> Error while mapping shared library sections:
>> libutils.so: No such file or directory.
>> Error while mapping shared library sections:
>> libbinder.so: No such file or directory.
>> Error while mapping shared library sections:
>> libexpat.so: No such file or directory.
>> Error while mapping shared library sections:
>> libcrypto.so: No such file or directory.
>> Error while mapping shared library sections:
>> libssl.so: No such file or directory.
>> Error while mapping shared library sections:
>> libicudata.so: No such file or directory.
>> Error while mapping shared library sections:
>> libicuuc.so: No such file or directory.
>> Error while mapping shared library sections:
>> libicui18n.so: No such file or directory.
>> Error while mapping shared library sections:
>> libsqlite.so: No such file or directory.
>> Error while mapping shared library sections:
>> libnativehelper.so: No such file or directory.
>> Error while mapping shared library sections:
>> libnetutils.so: No such file or directory.
>> Error while mapping shared library sections:
>> libEGL.so: No such file or directory.
>> Error while mapping shared library sections:
>> libwpa_client.so: No such file or directory.
>> Error while mapping shared library sections:
>> librpc.so: No such file or directory.
>> Error while mapping shared library sections:
>> libgps.so: No such file or directory.
>> Error while mapping shared library sections:
>> libhardware_legacy.so: No such file or directory.
>> Error while mapping shared library sections:
>> libpixelflinger.so: No such file or directory.
>> Error while mapping shared library sections:
>> libhardware.so: No such file or directory.
>> Error while mapping shared library sections:
>> libui.so: No such file or directory.
>> Error while mapping shared library sections:
>> libsurfaceflinger_client.so: No such file or directory.
>> Error while mapping shared library sections:
>> libcamera_client.so: No such file or directory.
>> Error while mapping shared library sections:
>> libemoji.so: No such file or directory.
>> Error while mapping shared library sections:
>> libjpeg.so: No such file or directory.
>> Error while mapping shared library sections:
>> libskia.so: No such file or directory.
>> Error while ma

[android-developers] ndk-gdb on cygwin/windowsXP won't load symbol tables.

2011-02-06 Thread Dewr
ary sections:
> libexif.so: No such file or directory.
> Error while mapping shared library sections:
> libdrm1.so: No such file or directory.
> Error while mapping shared library sections:
> libvorbisidec.so: No such file or directory.
> Error while mapping shared library sections:
> libopencore_common.so: No such file or directory.
> Error while mapping shared library sections:
> libopencore_net_support.so: No such file or directory.
> Error while mapping shared library sections:
> libopencore_player.so: No such file or directory.
> Error while mapping shared library sections:
> libomx_sharedlibrary.so: No such file or directory.
> Error while mapping shared library sections:
> libomx_amrenc_sharedlibrary.so: No such file or directory.
> Error while mapping shared library sections:
> libstagefright_amrnb_common.so: No such file or directory.
> Error while mapping shared library sections:
> libstagefright_avc_common.so: No such file or directory.
> Error while mapping shared library sections:
> libstagefright_color_conversion.so: No such file or directory.
> Error while mapping shared library sections:
> libstagefright.so: No such file or directory.
> Error while mapping shared library sections:
> libmedia_jni.so: No such file or directory.
> Error while mapping shared library sections:
> libstlport.so: No such file or directory.
> Error while mapping shared library sections:
> libwebcore.so: No such file or directory.
> Error while mapping shared library sections:
> gralloc.qsd8k.so: No such file or directory.
> (no debugging symbols found)
> warning: Unable to find dynamic linker breakpoint function.
> GDB will be unable to debug shared library initializers
> and track explicitly loaded dynamic code.
> 0xafd0eb68 in __futex_syscall3 ()
>from
> C:/DEWR/Product/Software-Engineering/Eclipse-Workspace/Unse/obj/local/ar
> meabi/libc.so
> (gdb) bt
> #0  0xafd0eb68 in __futex_syscall3 ()
>from
> C:/DEWR/Product/Software-Engineering/Eclipse-Workspace/Unse/obj/local/ar
> meabi/libc.so
> #1  0xafd10634 in __pthread_cond_timedwait_relative ()
>from
> C:/DEWR/Product/Software-Engineering/Eclipse-Workspace/Unse/obj/local/ar
> meabi/libc.so
> #2  0xafd10708 in __pthread_cond_timedwait ()
>from
> C:/DEWR/Product/Software-Engineering/Eclipse-Workspace/Unse/obj/local/ar
> meabi/libc.so
> #3  0xaca4742a in ?? ()
> Cannot access memory at address 0xc
> *(gdb) b io_lib.c:227
> No symbol table is loaded.  Use the "file" command.*
> (gdb) quit
> The program is running.  Exit anyway? (y or n) y
>
> Administrator@GUNWOO/cygdrive/c/DEWR/Product/Software-Engineering/Eclipse-Works
> pace/Unse
> #
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en