Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2011-02

Ansistrings under Android

5 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

de_jean_7777

Now that I have a working fpc crosscompiler for Android, and all the code runs ok, I encountered another problem. Namely working with ansistrings causes crashes. For example, in a simple test, calling the str() routine will cause a crash due to a run-time 216 error (general protection fault). I've also noticed that crashes can occur upon routine exit, when ansistrings are freed automatically. I thought that using the C memory manager (cmem) might help, but there is no difference.

For some reason, units are not initialized under a android shared library, so I call internal_initializeunits() myself in the JNI_OnLoad which is called automatically by the JNI, and is called before any other routine.

Andrew Haines
to de_jean_7777
Show quoted text 16 lines
Now that I have a working fpc crosscompiler for Android, and all the code runs ok, I encountered another problem. Namely working with ansistrings causes crashes. For example, in a simple test, calling the str() routine will cause a crash due to a run-time 216 error (general protection fault). I've also noticed that crashes can occur upon routine exit, when ansistrings are freed automatically. I thought that using the C memory manager (cmem) might help, but there is no difference. For some reason, units are not initialized under a android shared library, so I call internal_initializeunits() myself in the JNI_OnLoad which is called automatically by the JNI, and is called before any other routine. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Not sure if this is the case for you but I started writing a program for arm wince device and I had some trouble because of unaligned access to strings.

So "FooString := BarString" in some instances might cause a AV. But
"FooString := unaligned(BarString)" might work. Although it would
especially happen when a character alone was accessed i.e. PChar(Foo)[x].

It could be the problem.

Regards,

Andrew Haines

de_jean_7777
to Andrew Haines
Andrew Haines wrote 13 lines
Not sure if this is the case for you but I started writing a program for arm wince device and I had some trouble because of unaligned access to strings. So "FooString := BarString" in some instances might cause a AV. But "FooString := unaligned(BarString)" might work. Although it would especially happen when a character alone was accessed i.e. PChar(Foo)[x]. It could be the problem. Regards, Andrew Haines

This does not help. The problem is still the same.

Thomas Schatzl
to Andrew Haines: Not sure if this is the case for you but I started writing a program for arm wince device…

Hi,

Andrew Haines wrote 6 lines
On 02/22/11 12:06, de_jean_7777 wrote: > Now that I have a working fpc crosscompiler for Android, and all the > code runs ok, I encountered another problem. Namely working with > ansistrings causes crashes. For example, in a simple test, calling the > str() routine will cause a crash due to a run-time 216 error (general > protection fault). I've also noticed that crashes can occur upon

routine

> exit, when ansistrings are freed automatically. I thought that using

the

Show quoted text 5 lines
> C memory manager (cmem) might help, but there is no difference. > > For some reason, units are not initialized under a android shared > library, so I call internal_initializeunits() myself in the JNI_OnLoad > which is called automatically by the JNI, and is called before any

other

> routine.

The shared library startup code for ARM is broken (well, from the svn it seems that it never worked), it does not set up the environment variables and call the pascal unit initialization routine.

This is a "known" issue in so far as there are some testsuite tests (tw8730) that fail because of that.

Thomas

Dejan Boras

It's a problem I can work around, but I'm not sure how this affects the functionality of ansistrings.

Earlier message 37 lines
----- Original Message ----- From:Thomas Schatzl To:FPC-Pascal users discussions Cc: Sent:Tuesday, February 22, 2011 10:44 PM Subject:Re: [fpc-pascal] Ansistrings under Android Hi, On Tue, 22 Feb 2011 13:34:06 -0500, Andrew Haines wrote: > On 02/22/11 12:06, de_jean_7777 wrote: >> Now that I have a working fpc crosscompiler for Android, and all the >> code runs ok, I encountered another problem. Namely working with >> ansistrings causes crashes. For example, in a simple test, calling the >> str() routine will cause a crash due to a run-time 216 error (general >> protection fault). I've also noticed that crashes can occur upon routine >> exit, when ansistrings are freed automatically. I thought that using the >> C memory manager (cmem) might help, but there is no difference. >> >> For some reason, units are not initialized under a android shared >> library, so I call internal_initializeunits() myself in the JNI_OnLoad >> which is called automatically by the JNI, and is called before any other >> routine. The shared library startup code for ARM is broken (well, from the svn it seems that it never worked), it does not set up the environment variables and call the pascal unit initialization routine. This is a "known" issue in so far as there are some testsuite tests (tw8730) that fail because of that. Thomas