Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mkstemp() is broken on Android #14636

Open
p5pRT opened this issue Apr 4, 2015 · 5 comments
Open

mkstemp() is broken on Android #14636

p5pRT opened this issue Apr 4, 2015 · 5 comments

Comments

@p5pRT
Copy link

p5pRT commented Apr 4, 2015

Migrated from rt.perl.org#124240 (status was 'open')

Searchable as RT124240$

@p5pRT
Copy link
Author

p5pRT commented Apr 4, 2015

From @Corion

Hi all,

according to opinions on Google [1a][1b] and my testing [3], mkstemp()
exists on Android but never succeeds.

My Easter egg hunt so far has led me to the conclusion that there is no
natively-accessible way to get at something resembling a tempdir [2]
unless you manage to do JNI from a native app into Java without being
launched from Java yourself. So far, I've found only this suggestion
that this is possible at all, and I did not yet dive deep enough into
Android to find out whether a "plain Unix program" ever gets access to
the application structure referred to with "android_app".

This is just a bug report to note this. Maybe this should go into the
errata section for 5.22, even though it looks more to be the fault of
(older?) Android versions. I'm testing this on a Cyanogenmod 4.4.4 build.

-max

[1a] https://code.google.com/p/android/issues/detail?id=66815
[1b]
http​://stackoverflow.com/questions/10331648/how-to-get-path-to-the-temp-folder-from-native-code-on-android
[2]
http​://stackoverflow.com/questions/7595324/creating-temporary-files-in-android-with-ndk
[3] See the below run of the IO​::File tests, which call ->new_tempfile,
which maps to PerlIO_tempfile(). The tests fail with and without
$ENV{TMPDIR} set.

./perl -w dist/IO/t/io_xs.t
1..5
not ok 1 - new_tmpfile
# Failed test 'new_tmpfile'
# at dist/IO/t/io_xs.t line 19.
Can't use an undefined value as a symbol reference at dist/IO/t/io_xs.t
line 20.
# Looks like you planned 5 tests but ran 1.
# Looks like you failed 1 test of 1 run.
# Looks like your test exited with 2 just after 1.

./perl -V
Summary of my perl5 (revision 5 version 21 subversion 10) configuration​:

  Platform​:
  osname=android, osvers=4.4.4, archname=armv7l-linux-android
  uname='linux localhost 3.4.0-perf-v1.0-ga4e4477 #1 smp preempt sun
oct 12 01​:16​:46 cst 2014 armv7l gnulinux '
  config_args='-des -Dusedevel
-Dprefix=/storage/sdcard0/perl-5.21.10/ -Uuserelocateableinc
-Dsysroot=/data/data/com.pdaxrom.cctools/root/cctools
-Alibpth=/system/lib /vendor/lib -Dman1dir=none -Dman3dir=none
-Dsite1man=none -Dsite3man=none -Dvendorman1=none -Dvendorman3=none'
  hint=recommended, useposix=true, d_sigaction=define
  useithreads=undef, usemultiplicity=undef
  use64bitint=undef, use64bitall=undef, uselongdouble=undef
  usemymalloc=n, bincompat5005=undef
  Compiler​:
  cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2',
  optimize='-O2',
  cppflags='-fno-strict-aliasing -pipe -fstack-protector'
  ccversion='', gccversion='4.8', gccosandvers=''
  intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234,
doublekind=3
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8,
longdblkind=0
  ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=4
  alignbytes=8, prototype=define
  Linker and Libraries​:
  ld='cc', ldflags =' -L/system/lib -fstack-protector'
  libpth=/system/lib /vendor/lib
/data/data/com.pdaxrom.cctools/root/cctools/bin/../lib/gcc/arm-linux-androideabi/4.8/include-fixed
/data/data/com.pdaxrom.cctools/root/cctools/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/lib
/data/data/com.pdaxrom.cctools/root/cctools/lib /system/lib /vendor/lib
  libs=-ldl -lm -lc
  perllibs=-ldl -lm -lc
  libc=/system/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
  gnulibc_version=''
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
  cccdlflags='-fPIC
--sysroot=/data/data/com.pdaxrom.cctools/root/cctools',
lddlflags='-shared -O2 --sysroot
/data/data/com.pdaxrom.cctools/root/cctools -L/system/lib -fstack-protector'

Characteristics of this binary (from libperl)​:
  Compile-time options​: HAS_TIMES PERLIO_LAYERS PERL_DONT_CREATE_GVSV
  PERL_HASH_FUNC_ONE_AT_A_TIME_HARD PERL_MALLOC_WRAP
  PERL_NEW_COPY_ON_WRITE PERL_PRESERVE_IVUV
  PERL_USE_DEVEL USE_LARGE_FILES USE_PERLIO
  USE_PERL_ATOF
  Built under android
  Compiled at Mar 31 2015 09​:55​:46
  %ENV​:

PERL5INC="/storage/sdcard0/perl-5.21.10/lib/site_lib​:/storage/sdcard0/perl-5.21.10/lib/5.21.10/"
  PERL5LIB="/storage/sdcard0/perl-5.21.10/lib​:"
  @​INC​:
  /storage/sdcard0/perl-5.21.10/lib/5.21.10/armv7l-linux-android
  /storage/sdcard0/perl-5.21.10/lib/5.21.10
  /storage/sdcard0/perl-5.21.10/lib
  ./../lib/site_perl/5.21.10/armv7l-linux-android
  ./../lib/site_perl/5.21.10
  ./../lib/5.21.10/armv7l-linux-android
  ./../lib/5.21.10
  .

@p5pRT
Copy link
Author

p5pRT commented May 1, 2016

From @dk

Looking at the source it seems that the directory in question is basically

  $ENV{EXTERNAL_STORAGE} // '/mnt/sdcard'

But I don't have an Android VM at hand to test this.

http​://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.0.1_r1/android/content/Context.java#Context.getCacheDir%28%29

http​://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.0.1_r1/android/os/Environment.java#Environment.0EXTERNAL_STORAGE_DIRECTORY

@p5pRT
Copy link
Author

p5pRT commented May 1, 2016

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented May 2, 2016

From @iabyn

On Sun, May 01, 2016 at 04​:22​:37AM -0700, Dmitry Karasik via RT wrote​:

Subject​: Re​: [perl #124240] mkstemp() is broken on Android

Do you mean the mkstemp() in File​::Temp?

In what way is it broken?

Looking at the source

What source?

it seems that the directory in question

What directory?

is basically

$ENV{EXTERNAL_STORAGE} // '/mnt/sdcard'

The current perl source doesn't contain either of the strings
'EXTERNAL_STORAGE' or 'sdcard' (apart from in docs).

But I don't have an Android VM at hand to test this.

http​://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.0.1_r1/android/content/Context.java#Context.getCacheDir%28%29

http​://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.0.1_r1/android/os/Environment.java#Environment.0EXTERNAL_STORAGE_DIRECTORY

What is the relevance of those Java API calls to a perl issue?

Sorry, but your ticket is very unclear to me.

--
Music lesson​: a symbiotic relationship whereby a pupil's embellishments
concerning the amount of practice performed since the last lesson are
rewarded with embellishments from the teacher concerning the pupil's
progress over the corresponding period.

@p5pRT
Copy link
Author

p5pRT commented May 2, 2016

From @Corion

Hello Dave,

Am 02.05.2016 um 17​:47 schrieb Dave Mitchell via RT​:

On Sun, May 01, 2016 at 04​:22​:37AM -0700, Dmitry Karasik via RT wrote​:

Subject​: Re​: [perl #124240] mkstemp() is broken on Android

Do you mean the mkstemp() in File​::Temp?

In what way is it broken?
No, the bug is about the mkstemp() system call on (various versions of)
Android. This is more an OS bug than a File​::Temp bug, but it affects
File​::Temp.

Looking at the source

What source?

it seems that the directory in question

What directory?
The directory usually used for storage of tempfiles, traditionally known
as /tmp, except that /tmp does not exist under Android.

is basically

$ENV{EXTERNAL_STORAGE} // '/mnt/sdcard'

The current perl source doesn't contain either of the strings
'EXTERNAL_STORAGE' or 'sdcard' (apart from in docs).

But I don't have an Android VM at hand to test this.

http​://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.0.1_r1/android/content/Context.java#Context.getCacheDir%28%29

http​://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.0.1_r1/android/os/Environment.java#Environment.0EXTERNAL_STORAGE_DIRECTORY

What is the relevance of those Java API calls to a perl issue?

Sorry, but your ticket is very unclear to me.

On Android much of even the OS functionality only lives in Java-land, so
the "right" way to get at this inforamtion would be to write a Java
program, launch it and have it return the results of the appropriate
system call. Which is not how Perl works on Android, because Perl
bypasses the JVM completely and thus also does not get the benefit of
access to the system services that live only in Java-land.

-max

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants