Skip to content

Conversation

dkimitsa
Copy link
Contributor

@dkimitsa dkimitsa commented Aug 5, 2022

introduced in #639

root case

struct member alignment was wrongly calculated for jlong and double: was calculated as aligned by member size (8 bytes) but has to be 4 byte boundary.

code to reproduce

import java.lang.annotation.*;

@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@interface SampleAnnotation {
    long first();
    String last();
}

public class Test {
    @SampleAnnotation(first = 33, last = "last")
    private String myField;

    public void test() {
        try {
            Annotation[] anns = this.getClass().getDeclaredField("myField").getDeclaredAnnotations();
            for (Annotation a : anns) {
                System.out.println(((SampleAnnotation) a).first());
                System.out.println(((SampleAnnotation) a).last());
            }
        } catch (NoSuchFieldException e) {
            throw new RuntimeException(e);
        }
    }
}

fix

use offsetof to get data layout offsets

introduced by MobiVM#639
root case: struct member alignment was wrongly calculated for jlong and double: was calculated as aligned by member size (8 bytes) but has to be 4 byte boundary.
fix: use `offsetof` to get data layout offsets
@Tom-Ski Tom-Ski merged commit 4ce5c4b into MobiVM:master Aug 6, 2022
@dkimitsa
Copy link
Contributor Author

confirmed on ios7 32 bit

@guillerodriguez
Copy link

Does this impact the standard robovm library? Or is it only relevant if the app itself uses annotations ?

@dkimitsa
Copy link
Contributor Author

@guillerodriguez there is some amount of annotations in cocoatouch -- these might be affected. in general you would already see lot of crashes in analytics

@guillerodriguez
Copy link

@guillerodriguez there is some amount of annotations in cocoatouch -- these might be affected. in general you would already see lot of crashes in analytics

So the latest usable official release is 2.3.16, right ? (since 2.3.17 is broken according to the changelog)

@dkimitsa
Copy link
Contributor Author

if you need to support ios10 and bellow on 32 bit devices -- then yes

@dkimitsa dkimitsa deleted the fix/32bit-alignments branch March 29, 2023 19:03
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

Successfully merging this pull request may close these issues.

3 participants