<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>16326</bug_id>
          
          <creation_ts>2026-06-18 16:31:47 +0000</creation_ts>
          <short_desc>[scarthgap] x86_64 qemu-arm fails to emulate F_SETLK64 (EINVAL), breaking SQLite and file-locking on 32‑bit ARM userlands</short_desc>
          <delta_ts>2026-10-12 16:08:50 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>OE-Core</product>
          <component>oe-core other</component>
          <version>unspecified</version>
          <rep_platform>x86</rep_platform>
          <op_sys>arm</op_sys>
          <bug_status>IN PROGRESS REVIEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>major</bug_severity>
          <target_milestone>5.0.22</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Daniel R. Slater">daniel.slater</reporter>
          <assigned_to name="Babanpreet Singh">bbnpreetsingh</assigned_to>
          <cc>daniel.slater</cc>
    
    <cc>randy.macleod</cc>
    
    <cc>ross.burton</cc>
    
    <cc>tim.orling</cc>
    
    <cc>yoann.congal</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Don&apos;t know</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>105949</commentid>
    <comment_count>0</comment_count>
      <attachid>5231</attachid>
    <who name="Daniel R. Slater">daniel.slater</who>
    <bug_when>2026-06-18 16:31:47 +0000</bug_when>
    <thetext>Created attachment 5231
locktest.c is a simple test program to demonstrate the issue.

Problem:
The x86_64 build of qemu-arm incorrectly returns EINVAL for the syscall fcntl64(F_SETLK64). This causes SQLite and any ARM binaries that rely on POSIX advisory file locking to fail with a &quot;disk I/O error&quot;. The same binaries run correctly under the i386 build of qemu-arm and on real ARM hardware. This appears to be a syscall translation issue in QEMU’s 64-bit user-mode implementation of struct flock64.

Expected behavior:
The fcntl64(F_SETLK64) call should succeed, matching the behavior of real ARM hardware, the i386 qemu-arm build, and the Linux kernel’s expected handling of 32-bit file locks.

Actual behavior:
When running under x86_64 qemu-arm, the following output is observed:

fcntl64(F_SETLK64) failed: errno=22 (Invalid argument)

When running the same binary under i386 qemu-arm, the call succeeds.
When running on actual ARM hardware, the call also succeeds.

Minimal reproducer:
The attached ARM test program demonstrates the issue. It opens a file and attempts to acquire a write lock using F_SETLK64. When run under x86_64 qemu-arm, the lock attempt fails with EINVAL. When run under i386 qemu-arm or on real ARM hardware, the lock succeeds.

How to reproduce:

Build the test program using the Yocto SDK compiler.

Run the resulting ARM binary under x86_64 qemu-arm. The lock attempt fails with EINVAL.

Run the same binary under i386 qemu-arm. The lock attempt succeeds.

Run the same binary on actual ARM hardware. The lock attempt succeeds.

Impact:
This issue prevents many ARM binaries from running correctly under the Yocto SDK’s qemu-arm, including SQLite, LMDB, Berkeley DB, and any application that relies on POSIX file locking. This makes the x86_64 qemu-arm unsuitable for testing or running 32-bit ARM userlands that depend on file locking.

Suggested fix:
Provide a 32-bit (i386) build of qemu-arm in addition to the x86_64 build, or document that the i386 build is required for correct emulation of 32-bit ARM file-locking behavior.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106008</commentid>
    <comment_count>1</comment_count>
    <who name="Tim Orling">tim.orling</who>
    <bug_when>2026-06-25 14:38:47 +0000</bug_when>
    <thetext>This is probably worth filing a bug upstream with qemu. Can you do that?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106025</commentid>
    <comment_count>2</comment_count>
    <who name="Daniel R. Slater">daniel.slater</who>
    <bug_when>2026-06-25 18:47:04 +0000</bug_when>
    <thetext>Before filing an upstream bug with qemu, I downloaded and built the latest qemu release (11.0.1). 

qemu-arm 11.0.1 successfully runs the attached test program.

qemu-arm that ships with my version of Yocto (Scarthgap) is version 8.2.1 and it fails to successfully run the test program.

It looks like qemu has addressed this issue sometime between version 8 and 11.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106079</commentid>
    <comment_count>3</comment_count>
    <who name="Tim Orling">tim.orling</who>
    <bug_when>2026-07-02 15:25:56 +0000</bug_when>
    <thetext>Could you see if you can figure out a patch for qemu 8 that we could apply for Scarthgap?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106333</commentid>
    <comment_count>4</comment_count>
    <who name="Daniel R. Slater">daniel.slater</who>
    <bug_when>2026-07-24 17:39:38 +0000</bug_when>
    <thetext>I am not familiar with qemu source code at all. I&apos;m not able to create a patch to backport the fix.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>106389</commentid>
    <comment_count>5</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2026-07-30 15:17:00 +0000</bug_when>
    <thetext>Thanks Daniel.
We don&apos;t have anyone to work on this issue unfortunately.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107046</commentid>
    <comment_count>6</comment_count>
    <who name="Yoann Congal">yoann.congal</who>
    <bug_when>2026-10-12 09:23:39 +0000</bug_when>
    <thetext>Patch sent on ML:
https://patchwork.yoctoproject.org/project/oe-core/patch/20261001233250.7-1-bbnpreetsingh@gmail.com/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107047</commentid>
    <comment_count>7</comment_count>
    <who name="Yoann Congal">yoann.congal</who>
    <bug_when>2026-10-12 09:26:14 +0000</bug_when>
    <thetext>(In reply to Yoann Congal from comment #6)
&gt; Patch sent on ML:
&gt; https://patchwork.yoctoproject.org/project/oe-core/patch/20261001233250.7-1-
&gt; bbnpreetsingh@gmail.com/

@Daniel, can you help test/review it?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107053</commentid>
    <comment_count>8</comment_count>
    <who name="Daniel R. Slater">daniel.slater</who>
    <bug_when>2026-10-12 15:47:53 +0000</bug_when>
    <thetext>(In reply to Yoann Congal from comment #7)
&gt; (In reply to Yoann Congal from comment #6)
&gt; &gt; Patch sent on ML:
&gt; &gt; https://patchwork.yoctoproject.org/project/oe-core/patch/20261001233250.7-1-
&gt; &gt; bbnpreetsingh@gmail.com/
&gt; 
&gt; @Daniel, can you help test/review it?

I applied the patch to my Scarthgap build, rebuilt the toolchain, and now qemu-arm successfully runs the locktest test program:

The original version:
```
[dslat@feynman-wsl:~]
Σ /opt/thermo-imx-fb/5.0/sysroots/x86_64-pokysdk-linux/usr/bin/qemu-arm -L /opt/thermo-imx-fb/5.0/sysroots/cortexa7t2hf-neon-poky-linux-gnueabi ./locktest
fcntl64(F_SETLK64) failed: errno=22 (Invalid argument)
```

and the patched version:
```
[dslat@feynman-wsl:~]
Σ /opt/thermo-imx-fb/5.0-qemu-patched/sysroots/x86_64-pokysdk-linux/usr/bin/qemu-arm -L /opt/thermo-imx-fb/5.0-qemu-patched/sysroots/cortexa7t2hf-neon-poky-linux-gnueabi ./locktest
fcntl64(F_SETLK64) succeeded
```</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107054</commentid>
    <comment_count>9</comment_count>
    <who name="Yoann Congal">yoann.congal</who>
    <bug_when>2026-10-12 15:55:35 +0000</bug_when>
    <thetext>(In reply to Daniel R. Slater from comment #8)
&gt; (In reply to Yoann Congal from comment #7)
&gt; &gt; (In reply to Yoann Congal from comment #6)
&gt; &gt; &gt; Patch sent on ML:
&gt; &gt; &gt; https://patchwork.yoctoproject.org/project/oe-core/patch/20261001233250.7-1-
&gt; &gt; &gt; bbnpreetsingh@gmail.com/
&gt; &gt; 
&gt; &gt; @Daniel, can you help test/review it?
&gt; 
&gt; I applied the patch to my Scarthgap build, rebuilt the toolchain, and now
&gt; qemu-arm successfully runs the locktest test program:

Excellent, thanks!

If you want to be credited for this work you can reply on list with (either/both):
Reviewed-by: ...
Tested-by: ...
... and I&apos;ll add this to the merged commit.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>107055</commentid>
    <comment_count>10</comment_count>
    <who name="Daniel R. Slater">daniel.slater</who>
    <bug_when>2026-10-12 16:08:50 +0000</bug_when>
    <thetext>Reviewed-by: Daniel R. Slater &lt;daniel.slater@thermofisher.com&gt;
Tested-by: Daniel R. Slater &lt;daniel.slater@thermofisher.com&gt;

Reviewed the patch, applied it to my Scarthgap build, and verified the fix.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>5231</attachid>
            <date>2026-06-18 16:31:47 +0000</date>
            <delta_ts>2026-06-18 16:31:47 +0000</delta_ts>
            <desc>locktest.c is a simple test program to demonstrate the issue.</desc>
            <filename>locktest.c</filename>
            <type>text/plain</type>
            <size>733</size>
            <attacher name="Daniel R. Slater">daniel.slater</attacher>
            
              <data encoding="base64">I2RlZmluZSBfR05VX1NPVVJDRQojZGVmaW5lIF9MQVJHRUZJTEU2NF9TT1VSQ0UKCiNpbmNsdWRl
IDxzdGRpby5oPgojaW5jbHVkZSA8dW5pc3RkLmg+CiNpbmNsdWRlIDxmY250bC5oPgojaW5jbHVk
ZSA8c3RyaW5nLmg+CiNpbmNsdWRlIDxlcnJuby5oPgoKaW50IG1haW4odm9pZCkgewogICAgY29u
c3QgY2hhciAqcGF0aCA9ICJsb2NrdGVzdC5kYiI7CiAgICBpbnQgZmQgPSBvcGVuKHBhdGgsIE9f
UkRXUiB8IE9fQ1JFQVQsIDA2NDQpOwogICAgaWYgKGZkIDwgMCkgewogICAgICAgIHBlcnJvcigi
b3BlbiIpOwogICAgICAgIHJldHVybiAxOwogICAgfQoKICAgIHN0cnVjdCBmbG9jazY0IGZsOwog
ICAgbWVtc2V0KCZmbCwgMCwgc2l6ZW9mKGZsKSk7CiAgICBmbC5sX3R5cGUgPSBGX1dSTENLOwog
ICAgZmwubF93aGVuY2UgPSBTRUVLX1NFVDsKICAgIGZsLmxfc3RhcnQgPSAwOwogICAgZmwubF9s
ZW4gPSAwOyAgIC8vIGxvY2sgZW50aXJlIGZpbGUKCiAgICBpbnQgcmMgPSBmY250bChmZCwgRl9T
RVRMSzY0LCAmZmwpOwogICAgaWYgKHJjIDwgMCkgewogICAgICAgIHByaW50ZigiZmNudGw2NChG
X1NFVExLNjQpIGZhaWxlZDogZXJybm89JWQgKCVzKVxuIiwKICAgICAgICAgICAgICAgZXJybm8s
IHN0cmVycm9yKGVycm5vKSk7CiAgICAgICAgcmV0dXJuIDE7CiAgICB9CgogICAgcHJpbnRmKCJm
Y250bDY0KEZfU0VUTEs2NCkgc3VjY2VlZGVkXG4iKTsKICAgIHJldHVybiAwOwp9Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>