Skip to content

Java2Swift crashes on aarch64 Linux #51

Closed
@segabor

Description

@segabor

Hey folks,

I am running a Ubuntu 24.04.1 on my Turing RK1 SoC. The build process aborts with failed Java2Swift execution.

[711/711] Linking Java2Swift
Build complete! (125.83s)
mkdir -p Sources/JavaKit/generated
.build/aarch64-unknown-linux-gnu/debug/Java2Swift --module-name JavaKit -o Sources/JavaKit/generated java.lang.Object=JavaObject java.util.Enumeration java.lang.Throwable java.lang.Exception java.lang.RuntimeException java.lang.Error=JavaError

💣 Program crashed: Bad pointer dereference at 0x00616c434c525530

Thread 0 "Java2Swift" crashed:

 0 0x0000ffffb181c16c swift_release + 36 in libswiftCore.so
 1 closure #1 in methodMangling<each A>(parameterTypes:resultType:) + 1171 in Java2Swift at /home/segabor/src/swift-java/Sources/JavaKit/JavaObject+MethodCalls.swift:27:32

    25│     initializedCount in
    26│     for parameterType in repeat each parameterTypes {
    27│       buffer[initializedCount] = parameterType.javaType                                                                 
      │                                ▲
    28│       initializedCount += 1
    29│     }

 2 methodMangling<each A>(parameterTypes:resultType:) + 1371 in Java2Swift at /home/segabor/src/swift-java/Sources/JavaKit/JavaObject+MethodCalls.swift:23:40

    21│   resultType: JavaType
    22│ ) -> String {
    23│   let parameterTypesArray = [JavaType].init(unsafeUninitializedCapacity: countArgs(repeat each parameterTypes)) {       
      │                                        ▲
    24│     buffer,
    25│     initializedCount in

 3 static AnyJavaObject.javaMethodLookup<A>(thisClass:methodName:parameterTypes:resultType:in:) + 979 in Java2Swift at /home/segabor/src/swift-java/Sources/JavaKit/JavaObject+MethodCalls.swift:69:27

    67│   ) throws -> jmethodID {
    68│     // Compute the method signature.
    69│     let methodSignature = methodMangling(                                                                               
      │                           ▲
    70│       parameterTypes: repeat (each Param).self,
    71│       resultType: resultType

 4 static AnyJavaObject.dynamicJavaNewObject<A>(in:arguments:) + 1599 in Java2Swift at /home/segabor/src/swift-java/Sources/JavaKit/JavaObject+MethodCalls.swift:254:29

   252│     // Compute the method signature so we can find the right method, then look up the
   253│     // method within the class.
   254│     let methodID = try Self.javaMethodLookup(                                                                           
      │                             ▲
   255│       thisClass: thisClass,
   256│       methodName: javaConstructorName,

 5 JavaToSwift.run(environment:) + 1827 in Java2Swift at /home/segabor/src/swift-java/Sources/Java2Swift/JavaToSwift.swift:115:23

   113│ 
   114│     // Load all of the requested classes.
   115│     let classLoader = URLClassLoader(                                                                                   
      │                       ▲
   116│       try classPathWithJarFile.map { try URL("file://\($0)", environment: environment) },
   117│       environment: environment

 6 JavaToSwift.run() + 527 in Java2Swift at /home/segabor/src/swift-java/Sources/Java2Swift/JavaToSwift.swift:74:9

    72│     javaVirtualMachine = jvm
    73│ 
    74│     try run(environment: jvm.environment)                                                                               
      │         ▲
    75│   }
    76│

 7 static ParsableCommand.main(_:) + 487 in Java2Swift at /home/segabor/src/swift-java/.build/checkouts/swift-argument-parser/Sources/ArgumentParser/Parsable Types/ParsableCommand.swift:158:19

   156│     do {
   157│       var command = try parseAsRoot(arguments)
   158│       try command.run()                                                                                                 
      │                   ▲
   159│     } catch {
   160│       exit(withError: error)

 8 static ParsableCommand.main() + 51 in Java2Swift at /home/segabor/src/swift-java/.build/checkouts/swift-argument-parser/Sources/ArgumentParser/Parsable Types/ParsableCommand.swift:175:10

   173│   /// if necessary.
   174│   public static func main() {
   175│     self.main(nil)                                                                                                      
      │          ▲
   176│   }
   177│ }

 9 Java2Swift_main + 11 in Java2Swift at /home/segabor/src/swift-java/Sources/Java2Swift/JavaToSwift.swift:30:8

    28│ /// Command-line utility to drive the export of Java classes into Swift types.
    29│ @main
    30│ struct JavaToSwift: ParsableCommand {                                                                                   
      │        ▲
    31│   static var _commandName: String { "Java2Swift" }
    32│

10 0x0000ffffaf3f84c4 <unknown> in libc.so.6
11 0x0000ffffaf3f8598 <unknown> in libc.so.6

Backtrace took 3.46s

make: *** [Makefile:56: generate-JavaKit] Segmentation fault (core dumped)

Environment

OS: Linux alfa 6.1.0-1025-rockchip #25-Ubuntu SMP Mon Aug 26 23:01:14 UTC 2024 aarch64 aarch64 aarch64 GNU/Linux
Swift:

Swift version 6.0.1 (swift-6.0.1-RELEASE)
Target: aarch64-unknown-linux-gnu

Java:

openjdk version "23" 2024-09-17
OpenJDK Runtime Environment Temurin-23+37 (build 23+37)
OpenJDK 64-Bit Server VM Temurin-23+37 (build 23+37, mixed mode, sharing)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions