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

ftruncate returns 1 #788

Open
0xfk0 opened this issue Nov 29, 2024 · 5 comments
Open

ftruncate returns 1 #788

0xfk0 opened this issue Nov 29, 2024 · 5 comments

Comments

@0xfk0
Copy link

0xfk0 commented Nov 29, 2024

AOSP build fails every time when building APEX images. The failed command is shown below.

The real root cause of the failure is what ftruncate system call returns 1 as a result. If the temporary directory which is used by build system is moved from bcashefs to tmpfs, the error disappears. I have recorded strace output for both cases and see the difference: when temporary files system are located on bcacheds, one call to ftruncate system call finished with 1 as return code. But possible return codes for ftruncate are only 0 and -1. Looks like this causes following failures in python code.

Failed command:

[78/1330] rm -rf out/soong/.intermediates/bionic/apex/com.android.runtime/android_common_hwasan_com.android.runtime_image/image.apex
&& mkdir -p out/soong/.intermediates/bionic/apex/com.android.runtime/android_common_hwasan_com.android.runtime_image/image.apex
&& (. out/soong/.intermediates/bionic/apex/com.android.runtime/android_common_hwasan_com.android.runtime_image/com.android.runtime.apex.unsigned.copy_commands)
&& APEXER_TOOL_PATH=out/host/linux-x86/bin:prebuilts/sdk/tools/linux/bin
out/host/linux-x86/bin/apexer --force --manifest
out/soong/.intermediates/bionic/apex/com.android.runtime/android_common_hwasan_com.android.runtime_image/apex_manifest.pb
--file_contexts
out/soong/.intermediates/bionic/apex/com.android.runtime/android_common_hwasan_com.android.runtime_image/file_contexts
--canned_fs_config
out/soong/.intermediates/bionic/apex/com.android.runtime/android_common_hwasan_com.android.runtime_image/canned_fs_config
--include_build_info --payload_type image --key
bionic/apex/com.android.runtime.pem --pubkey
bionic/apex/com.android.runtime.avbpubkey --target_sdk_version 34
--min_sdk_version 34 --assets_dir
out/soong/.intermediates/bionic/apex/com.android.runtime/android_common_hwasan_com.android.runtime_image/NOTICE
--payload_fs_type ext4
out/soong/.intermediates/bionic/apex/com.android.runtime/android_common_hwasan_com.android.runtime_image/image.apex
out/soong/.intermediates/bionic/apex/com.android.runtime/android_common_hwasan_com.android.runtime_image/com.android.runtime.apex.unsigned 

FAILED:
out/soong/.intermediates/bionic/apex/com.android.runtime/android_common_hwasan_com.android.runtime_image/com.android.runtime.apex.unsigned

Traceback (most recent call last):
  File "internal/stdlib/runpy.py", line 196, in _run_module_as_main
  File "internal/stdlib/runpy.py", line 86, in _run_code
  File "/home/sysop/aosp/out/host/linux-x86/bin/apexer/__main__.py", line 12, in <module>
  File "internal/stdlib/runpy.py", line 196, in _run_module_as_main
  File "internal/stdlib/runpy.py", line 86, in _run_code
  File "apexer.py", line 934, in <module>
  File "apexer.py", line 927, in main
  File "apexer.py", line 817, in CreateApex
  File "apexer.py", line 725, in CreateApexPayload
  File "apexer.py", line 704, in SignImage
  File "apexer.py", line 229, in RunCommand
AssertionError: Failed to execute: out/host/linux-x86/bin/avbtool resize_image --image /home/sysop/aosp/out/soong/.temp/tmpf1wvct3o/content/apex_payload.img --partition_size 7335936
Traceback (most recent call last):
  File "internal/stdlib/runpy.py", line 196, in _run_module_as_main
  File "internal/stdlib/runpy.py", line 86, in _run_code
  File "/home/sysop/aosp/out/host/linux-x86/bin/avbtool/__main__.py", line 12, in <module>
  File "internal/stdlib/runpy.py", line 196, in _run_module_as_main
  File "internal/stdlib/runpy.py", line 86, in _run_code
  File "avbtool.py", line 4935, in <module>
  File "avbtool.py", line 4739, in run
  File "avbtool.py", line 4862, in resize_image
  File "avbtool.py", line 2366, in resize_image
  File "avbtool.py", line 917, in append_dont_care
OSError: [Errno 0] Error

Filtered strace output:

$ grep -E '\(6, | = 6'  /tmp/y.872104
                                                                                                                                                                                     -- 2024-11-29 18:15:59 --
lseek(3, -927, SEEK_CUR)                = 608
read(5, "AVBf\0\0\0\1\0\0\0\0\0\0\0\0\0n\340\0\0\0\0\0\0o\320\0\0\0\0\0"..., 4096) = 64
openat(AT_FDCWD, "/home/sysop/aosp/out/soong/.temp/tmp9cp4_0sx/content/apex_payload.img", O_RDWR|O_CLOEXEC) = 6
fstat(6, {st_mode=S_IFREG|0664, st_size=7331840, ...}) = 0
ioctl(6, TCGETS, 0x7fff93393610)        = -1 ENOTTY (Inappropriate ioctl for device)
lseek(6, 0, SEEK_CUR)                   = 0
lseek(6, 0, SEEK_CUR)                   = 0
lseek(6, 0, SEEK_END)                   = 7331840
lseek(6, 0, SEEK_CUR)                   = 7331840
lseek(6, 0, SEEK_SET)                   = 0
lseek(6, 0, SEEK_CUR)                   = 0
read(6, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 4096) = 4096
lseek(6, 0, SEEK_END)                   = 7331840
lseek(6, 0, SEEK_CUR)                   = 7331840
lseek(6, 0, SEEK_CUR)                   = 7331840
ftruncate(6, 7331840)                   = 1
write(2, "  File \"internal/stdlib/runpy.py"..., 68) = 68
@0xfk0
Copy link
Author

0xfk0 commented Nov 29, 2024

File system superblock:
superblock.txt

No any error messages seen in dmesg.

@0xfk0
Copy link
Author

0xfk0 commented Nov 29, 2024

sysop@jupiter:~/aosp$ mount | grep bcache
--
/dev/sdb:/dev/nvme0n1p3 on / type bcachefs (rw,relatime,foreground_target=ssd,background_target=hdd,promote_target=ssd,verbose)
/dev/sdb:/dev/nvme0n1p3 on /.bcachefs type bcachefs (rw,relatime,foreground_target=ssd,background_target=hdd,promote_target=ssd,verbose)
sysop@jupiter:~/aosp$ df -h .
--
Filesystem               Size  Used Avail Use% Mounted on
/dev/sdb:/dev/nvme0n1p3  2.5T  1.8T  775G  70% /

@0xfk0
Copy link
Author

0xfk0 commented Nov 29, 2024

Full strace output
trace.ZIP

Due to github limitations you need to rename it to .tgz and unpack.

@0xfk0
Copy link
Author

0xfk0 commented Nov 29, 2024

Looks like reproduction scenario is complicated, I cannot reproduce the issue by simple C-program.

@wangling12
Copy link

I have the same problem when compiling lineage.

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

No branches or pull requests

2 participants