Citra: issue Latest commit wont launch any game on MacOsx 10.12

Created on 28 Nov 2016  路  16Comments  路  Source: citra-emu/citra

Since there is no public release for mac in a while i build my own and came to the conclusion that the latest commit wont launch any game it just stays at a black screen no errors nothing even in the terminal it does nothing.

Commit id: 3174bfd

Log from citra when launching pokemon sun/moon demo:
http://hastebin.com/vilerapaxe.log

my specs are Mac Specs

Issue only appears when CPU JIT is enabled in Release, in Debug CPU JIT enables works

A-cpu jit T-bug

All 16 comments

I will try it on windows now to double check.
Can you please add exactly which commit are you using and your specs?

Update: No problem on windows, release, msvc build.

error exists only on mac, release version + CPU JIT enabled. On Debug works ok

Pinging @Subv

@HyperGainZ Can you check in which version it still worked please?

@freiro just tested a build from commit 8a73eb8 in release and it worked il try now a build of the next commit and report back

just did some testing and mac Release build (CPU JIT) enabled works until commit 593ec7f after that CPU JIT breaks in the Release Version

It seems harmless but I believe it is #2215

After doing my self a bisect it gave me the same result as @pippo2931 so i reverted the change and did a rebuild and tested Zelda OoT to see if it launched with CPU JIT enabled and it worked after that i readded the test and added printf("ticks: %u / %D \n", ticks_executed, num_instructions); to see what ticks_executed is returning and this is the result ticks: 3565821930 / 1000

full console log : http://hastebin.com/fezohukidu.log

Code Snippet:

unsigned ticks_executed = jit->Run(static_cast<unsigned>(num_instructions));
//jit->Run(static_cast<unsigned>(num_instructions));

printf("ticks: %u / %d \n", ticks_executed, num_instructions);

AddTicks(ticks_executed);
//AddTicks(num_instructions);

To compare with @NicolaiVdS, with the same log command, running Pokemon Sun / Zelda OoT on Linux it gives

ticks: 1000 / 1000 
ticks: 1002 / 1000 
ticks: 1002 / 1000 
...

(continues with the same number for several lines, then changes. But I think the first three lines is enough)

I am expecting that there is some undefined-behaviour code in Dynarmic and macOS wrongly optimized it.

When debugging in Xcode with a breakpoint on that line, I got 1000 ticks too.
It looks time sensitive.

@pippo2931 if i'm not mistaken when you run citra from xcode directly its running as Debug and not as Release and there is where the problem is when building a debug version CPU JIT works but not in Release

https://github.com/MerryMage/dynarmic/blob/master/src/backend_x64/block_of_code.cpp#L39

Could someone replace:

    jit_state->cycles_remaining = cycles_to_run;
    run_code(jit_state, basic_block);
    return cycles_to_run - jit_state->cycles_remaining; // Return number of cycles actually run.

with something like:

    jit_state->cycles_remaining = cycles_to_run;
    printf("before: %zu %lld\n", cycles_to_run, jit_state->cycles_remaining);
    run_code(jit_state, basic_block);
    printf("after: %zu %lld\n", cycles_to_run, jit_state->cycles_remaining);
    return cycles_to_run - jit_state->cycles_remaining; // Return number of cycles actually run.

and share the output?

Adding the prints, it doesn't get stuck anymore.

A sample:
before: 1000 1000
after: 1000 999
before: 999 999
after: 999 995
before: 995 995
after: 995 993
before: 993 993
after: 993 0
before: 1000 1000
after: 1000 -2
............................
before: 185 185
after: 185 170
before: 170 170
after: 170 159
before: 159 159
after: 159 24
before: 24 24
after: 24 -1
before: 1000 1000
after: 1000 989
before: 989 989
after: 989 974
before: 974 974
after: 974 963
before: 963 963
after: 963 828
before: 828 828
after: 828 792
before: 792 792
after: 792 777
before: 777 777
after: 777 766
before: 766 766
after: 766 631

same result here game just starts fine now
output: https://nvds.be/citra_CPU_JIT_ERROR.log (55,5MB size)

It was an ABI issue.


Emitted code:

JIT prologue

  push   %rbx
  push   %rbp
  push   %r12
  push   %r13
  push   %r14
  mov    %rdi,%r15
  stmxcsr 0x34c(%r15)
  ldmxcsr 0x348(%r15)
  jmpq   *%rsi

JIT epilogue

  stmxcsr 0x348(%r15)
  ldmxcsr 0x34c(%r15)
  pop    %r14
  pop    %r13
  pop    %r12
  pop    %rbp
  pop    %rbx
  retq

Register %r15 was not being saved, despite being a callee-saved register in the ABI.


Here is where that code is emitted:

https://github.com/MerryMage/dynarmic/blob/57169ec0932248f703526f65095029992372a4e3/src/backend_x64/abi.cpp#L68

And HostLocIsGPR doesn't consider r15 a GPR:

https://github.com/MerryMage/dynarmic/blob/6520c7537e460f5e45dea837503b89814d1fb187/src/backend_x64/hostloc.h#L28-L30

Fixed in MerryMage/dynarmic@5f11b4f5.

@MerryMage Just tested PR #2243 on mac and CPU JIT works again on citra & citra-qt in Release builds

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kdex picture kdex  路  4Comments

RicardoMVA picture RicardoMVA  路  3Comments

GF-Huang picture GF-Huang  路  4Comments

animekai picture animekai  路  3Comments

KillzXGaming picture KillzXGaming  路  3Comments