You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

树莓派4(Bullseye)安装Sodium::FFI失败,求调试方案

调试树莓派4上Sodium::FFI安装测试失败的方法

问题描述

在运行Raspberry Pi OS Bullseye的树莓派4上,安装工具依赖的Sodium::FFI模块时,测试阶段持续失败。先后执行sudo cpan install Sodium::FFI和cpanm --sudo --reinstall Sodium::FFI均出现相同错误:测试用例显示子测试全部通过,但程序因ABRT(信号6)或SEGV(信号11)异常终止,且提示TAP输出无测试计划。

错误日志

cpanm (App::cpanminus) 1.7044 on perl 5.032001 built for arm-linux-gnueabihf-thread-multi-64int
Work directory is /home/pi/.cpanm/work/1717429297.5107
You have make /usr/bin/make
You have LWP 6.77
You have /bin/tar: tar (GNU tar) 1.34
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.
You have /usr/bin/unzip
Searching Sodium::FFI () on cpanmetadb ...
--> Working on Sodium::FFI
Fetching http://www.cpan.org/authors/id/C/CA/CAPOEIRAB/Sodium-FFI-0.009.tar.gz
--> OK
Unpacking Sodium-FFI-0.009.tar.gz
Entering Sodium-FFI-0.009
Checking configure dependencies from META.json
Checking if you have FFI::Build::MM 0.83 ... Yes (2.08)
Checking if you have ExtUtils::MakeMaker 6.58 ... Yes (7.70)
Checking if you have Alien::Base::Wrapper 0 ... Yes (2.80)
Checking if you have Alien::Sodium 2.00 ... Yes (2.000)
Configuring Sodium-FFI-0.009
Running Makefile.PL
Checking if your kit is complete...
Looks good
Have /usr/lib/arm-linux-gnueabihf/perl-base
Want /usr/lib/arm-linux-gnueabihf/perl/5.32
Your perl and your Config.pm seem to have different ideas about the
architecture they are running on.
Perl thinks: [perl-base]
Config says: [arm-linux-gnueabihf-thread-multi-64int]
This may or may not cause problems. Please check your installation of perl
if you have problems building this extension.
Generating a Unix-style Makefile
Writing Makefile for Sodium::FFI
Writing MYMETA.yml and MYMETA.json
--> OK
Checking dependencies from MYMETA.json ...
Checking if you have Exporter 5.57 ... Yes (5.78)
Checking if you have FFI::Platypus 1.00 ... Yes (2.08)
Checking if you have Carp 0 ... Yes (1.50)
Checking if you have Alien::Base::Wrapper 0 ... Yes (2.80)
Checking if you have File::Basename 0 ... Yes (2.85)
Checking if you have Test::More 0.88 ... Yes (1.302199)
Checking if you have File::ShareDir 0 ... Yes (1.118)
Checking if you have Ref::Util 0 ... Yes (0.204)
Checking if you have Cwd 0 ... Yes (3.78)
Checking if you have Sub::Util 0 ... Yes (1.63)
Checking if you have ExtUtils::MakeMaker 0 ... Yes (7.70)
Checking if you have strict 0 ... Yes (1.11)
Checking if you have Alien::Sodium 2.000 ... Yes (2.000)
Checking if you have Path::Tiny 0 ... Yes (0.144)
Checking if you have warnings 0 ... Yes (1.47)
Checking if you have utf8 0 ... Yes (1.22)
Checking if you have File::Spec 0 ... Yes (3.78)
Checking if you have feature 0 ... Yes (1.58)
Building and testing Sodium-FFI-0.009
cp lib/Sodium/FFI.pm blib/lib/Sodium/FFI.pm
"/usr/bin/perl" -MFFI::Build::MM=cmd -e fbx_build
CC ffi/ffi.c
LD blib/lib/auto/share/dist/Sodium-FFI/lib/libsodium.so
Manifying 1 pod document
"/usr/bin/perl" -MFFI::Build::MM=cmd -e fbx_build
"/usr/bin/perl" -MFFI::Build::MM=cmd -e fbx_test
PERL_DL_NONLAZY=1 "/usr/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t t/aead/*.t t/pub_key_crypto/*.t
#
# Versions for all modules listed in MYMETA.json (including optional ones):
#
# === Configure Requires ===
#
#     Module                Want     Have
#     -------------------- ----- --------
#     Alien::Base::Wrapper   any     2.80
#     Alien::Sodium         2.00    2.000
#     ExtUtils::MakeMaker    any     7.70
#     FFI::Build::MM        0.83     2.08
#     perl                 5.008 5.032001
#
# === Build Requires ===
#
#     Module        Want  Have
#     ------------- ---- -----
#     Alien::Sodium  any 2.000
#
# === Test Requires ===
#
#     Module               Want     Have
#     ------------------- ----- --------
#     ExtUtils::MakeMaker   any     7.70
#     File::Spec            any     3.78
#     Test::More           0.88 1.302199
#     perl                5.008 5.032001
#
# === Test Recommends ===
#
#     Module         Want     Have
#     ---------- -------- --------
#     CPAN::Meta 2.120900 2.150010
#
# === Runtime Requires ===
#
#     Module                Want     Have
#     -------------------- ----- --------
#     Alien::Base::Wrapper   any     2.80
#     Alien::Sodium        2.000    2.000
#     Carp                   any     1.50
#     Cwd                    any     3.78
#     Exporter              5.57     5.78
#     FFI::Platypus         1.00     2.08
#     File::Basename         any     2.85
#     File::ShareDir         any    1.118
#     File::Spec             any     3.78
#     Path::Tiny             any    0.144
#     Ref::Util              any    0.204
#     Sub::Util              any     1.63
#     feature                any     1.58
#     perl                 5.008 5.032001
#     strict                 any     1.11
#     utf8                   any     1.22
#     warnings               any     1.47
#
t/00-report-prereqs.t ........... ok
t/10-versions.t ................. ok
t/11-utils.t .................... ok
t/12-random.t ................... ok
t/aead/aes256gcm.t .............. skipped: AEAD_AES256 Not Available.
t/aead/chacha20poly1305.t .......
All 5 subtests passed
t/aead/chacha20poly1305_ietf.t ..
All 5 subtests passed
t/crypto_auth.t .................
All 3 subtests passed
t/pub_key_crypto/box.t ..........
All 2 subtests passed
t/pub_key_crypto/pubkey_sig.t ...
All 6 subtests passed

Test Summary Report
-------------------
t/aead/chacha20poly1305.t     (Wstat: 6 (Signal: ABRT) Tests: 5 Failed: 0)
  Non-zero wait status: 6
  Parse errors: No plan found in TAP output
t/aead/chacha20poly1305_ietf.t (Wstat: 6 (Signal: ABRT) Tests: 5 Failed: 0)
  Non-zero wait status: 6
  Parse errors: No plan found in TAP output
t/crypto_auth.t               (Wstat: 11 (Signal: SEGV) Tests: 3 Failed: 0)
  Non-zero wait status: 11
  Parse errors: No plan found in TAP output
t/pub_key_crypto/box.t        (Wstat: 6 (Signal: ABRT) Tests: 2 Failed: 0)
  Non-zero wait status: 6
  Parse errors: No plan found in TAP output
t/pub_key_crypto/pubkey_sig.t (Wstat: 11 (Signal: SEGV) Tests: 6 Failed: 0)
  Non-zero wait status: 11
  Parse errors: No plan found in TAP output
Files=10, Tests=101,  5 wallclock secs ( 0.10 usr  0.04 sys +  4.10 cusr  0.44 csys =  4.68 CPU)
Result: FAIL
Failed 5/10 test programs. 0/101 subtests failed.
make: *** [Makefile:890: test_dynamic] Error 255
--> FAIL Installing Sodium::FFI failed. See /home/pi/.cpanm/work/1717429297.5107/build.log for details. Retry with --force to force install it.

调试步骤

1. 修复Perl架构不匹配问题

日志中提示Perl与Config.pm的架构信息不一致,这可能导致FFI绑定异常。重新安装系统Perl包解决:

sudo apt purge perl-base perl -y
sudo apt install perl perl-base build-essential -y

重启设备后再次尝试安装。

2. 单独运行失败测试,定位崩溃点

进入cpanm的工作目录,单独运行崩溃的测试用例,用调试工具获取详细错误:

cd /home/pi/.cpanm/work/1717429297.5107/Sodium-FFI-0.009
# 用Perl调试器运行测试
perl -d t/aead/chacha20poly1305.t
# 用valgrind检测内存错误
valgrind perl t/crypto_auth.t

valgrind会输出内存访问违规的具体位置,帮助判断是libsodium库还是Perl绑定的问题。

3. 验证Alien::Sodium的有效性

Sodium::FFI依赖Alien::Sodium提供libsodium库,先确认Alien::Sodium能正确找到库:

perl -MAlien::Sodium -e 'print Alien::Sodium->dynamic_libs, "\n"'

如果输出异常,重新安装Alien::Sodium;或者直接用系统包安装libsodium,强制Alien::Sodium使用系统库:

sudo apt install libsodium-dev
PERL_ALIEN_SODIUM_SYSTEM=1 cpanm --sudo Sodium::FFI

4. 尝试安装旧版本模块

当前0.009版本可能存在ARM架构兼容性问题,尝试安装0.008版本:

cpanm --sudo CAPOEIRAB/Sodium-FFI-0.008.tar.gz

5. 强制安装后验证核心功能

如果测试崩溃但实际功能可能正常,可强制安装后验证:

cpanm --sudo --force Sodium::FFI

编写简单测试脚本验证基础功能(如随机数生成):

use Sodium::FFI;
my $random_bytes = Sodium::FFI::randombytes_buf(16);
print unpack('H*', $random_bytes), "\n";

运行脚本,若正常输出则说明核心功能可用,测试用例的崩溃可能是测试本身的问题。

内容的提问来源于stack exchange,提问作者hanjo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 20:04:54