Error in create DrawTarget with Skia on OS X (signal: 11)
extern crate azure;
extern crate euclid;
use azure::azure_hl::DrawTarget;
use azure::azure_hl::BackendType;
use azure::azure_hl::SurfaceFormat;
use euclid::Size2D;
fn main() {
let target = DrawTarget::new(BackendType::Skia, Size2D::new(100, 100), SurfaceFormat::R8G8B8A8);
println!("can't print");
}
Running `target/debug/test`
Process didn't exit successfully: `target/debug/test` (signal: 11)
@tioover Thank you for reporting this! If you run lldb target/debug/test and get a backtrace from the crash, could you paste it here?
@jdm
RUST_BACKTRACE=1 target/debug/test
[1] 90624 segmentation fault RUST_BACKTRACE=1 target/debug/test
(lldb) run
Process 90640 launched: '/Users/tioover/Project/test/target/debug/test' (x86_64)
Process 90640 stopped
* thread #1: tid = 0xd614f0, 0x00000001000031b8 test`AzCreateDrawTarget + 40, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x8)
frame #0: 0x00000001000031b8 test`AzCreateDrawTarget + 40
test`AzCreateDrawTarget:
-> 0x1000031b8 <+40>: movq 0x8(%rbx), %rax
0x1000031bc <+44>: leaq 0x1(%rax), %rcx
0x1000031c0 <+48>: movq %rcx, 0x8(%rbx)
0x1000031c4 <+52>: testq %rbx, %rbx
(lldb) bt
* thread #1: tid = 0xd614f0, 0x00000001000031b8 test`AzCreateDrawTarget + 40, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x8)
* frame #0: 0x00000001000031b8 test`AzCreateDrawTarget + 40
frame #1: 0x00000001000030ad test`azure::azure_hl::DrawTarget::new(backend=Skia, size=(width = 100, height = 100), format=R8G8B8A8) + 189 at azure_hl.rs:451
frame #2: 0x000000010000175b test`test::main + 155 at main.rs:10
frame #3: 0x00000001001a0423 test`sys_common::unwind::try::try_fn::h5537656665160807786 + 35
frame #4: 0x000000010019ee49 test`__rust_try + 9
frame #5: 0x00000001001a02c6 test`rt::lang_start::h7030a3d2148a5eb0f4x + 566
frame #6: 0x0000000100002cfa test`main + 42
frame #7: 0x00007fff908435ad libdyld.dylib`start + 1
Use SurfaceFormat::B8R8G8A8 can correct running.
BTW: How to read data in SourceSurface? I not found relate method or function.
For the SourceSurface question, I think you're looking for get_data_surface then with_data.
And huh, that's weird that changing the surface format avoids a segfault :<
Oh, I bet CreateDrawTarget returns NULL, so the subsequent AddRef segfaults. AzCreateDrawTargetForData avoids that by checking for null; we should make the same change here.