{"action":"created","issue":{"url":"https://api.github.com/repos/libgdx/libgdx/issues/2763","labels_url":"https://api.github.com/repos/libgdx/libgdx/issues/2763/labels{/name}","comments_url":"https://api.github.com/repos/libgdx/libgdx/issues/2763/comments","events_url":"https://api.github.com/repos/libgdx/libgdx/issues/2763/events","html_url":"https://github.com/libgdx/libgdx/issues/2763","id":55031417,"number":2763,"title":"Crash in native code while asynchronously loading TextureAtlas","user":{"login":"justinbowes","id":35697,"avatar_url":"https://avatars.githubusercontent.com/u/35697?v=3","gravatar_id":"","url":"https://api.github.com/users/justinbowes","html_url":"https://github.com/justinbowes","followers_url":"https://api.github.com/users/justinbowes/followers","following_url":"https://api.github.com/users/justinbowes/following{/other_user}","gists_url":"https://api.github.com/users/justinbowes/gists{/gist_id}","starred_url":"https://api.github.com/users/justinbowes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justinbowes/subscriptions","organizations_url":"https://api.github.com/users/justinbowes/orgs","repos_url":"https://api.github.com/users/justinbowes/repos","events_url":"https://api.github.com/users/justinbowes/events{/privacy}","received_events_url":"https://api.github.com/users/justinbowes/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-01-21T15:15:38Z","updated_at":"2015-01-21T15:56:12Z","closed_at":"2015-01-21T15:56:12Z","body":"I'm seeing a crash when loading a TextureAtlas through the AssetManager that does not occur if I load from the main thread. (OSX 10.10, other platforms not checked yet.)\r\n\r\nThe TextureAtlas is multiple pages of PNGs, 1024x1024, generated by TexturePacker. The crash occurs on the second page it tries to load (page 8 of 9).\r\n\r\nI can add an error log, but it's huge, so here are the parts I found interesting:\r\n\r\n```\r\n#\r\n# A fatal error has been detected by the Java Runtime Environment:\r\n#\r\n#  SIGBUS (0xa) at pc=0x00007fff8973e512, pid=65013, tid=122375\r\n#\r\n# JRE version: Java(TM) SE Runtime Environment (8.0_25-b17) (build 1.8.0_25-b17)\r\n# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.25-b02 mixed mode bsd-amd64 compressed oops)\r\n# Problematic frame:\r\n# C  [libsystem_platform.dylib+0x1512]  _platform_memmove$VARIANT$Nehalem+0x1d2\r\n```\r\n\r\n```\r\nStack: [0x000000012701e000,0x000000012711e000],  sp=0x000000012710ff40,  free space=967k\r\nNative frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)\r\nC  [libsystem_platform.dylib+0x1512]  _platform_memmove$VARIANT$Nehalem+0x1d2\r\nC  [libgdx64.dylib+0x24b19]  stbi__getn+0x99\r\nC  [libgdx64.dylib+0x23e64]  stbi__parse_png_file+0x974\r\nC  [libgdx64.dylib+0x6b83]  stbi_load_main+0x203\r\nC  [libgdx64.dylib+0x14dd2]  gdx2d_load+0x72\r\nC  [libgdx64.dylib+0x14ce]  Java_com_badlogic_gdx_graphics_g2d_Gdx2DPixmap_load+0x3e\r\nj  com.badlogic.gdx.graphics.g2d.Gdx2DPixmap.load([J[BII)Ljava/nio/ByteBuffer;+0\r\nj  com.badlogic.gdx.graphics.g2d.Gdx2DPixmap.<init>([BIII)V+19\r\nj  com.badlogic.gdx.graphics.Pixmap.<init>(Lcom/badlogic/gdx/files/FileHandle;)V+24\r\n```\r\n\r\n```\r\nRegisters:\r\nRAX=0x000000012341c000, RBX=0x00000000000b8000, RCX=0x000000000000000f, RDX=0xffffffffffe46fb0\r\nRSP=0x000000012710ff40, RBP=0x000000012710ff40, RSI=0x0000000780b09c4d, RDI=0x0000000123263030\r\nR8 =0x0000000000000153, R9 =0x00000000000000cc, R10=0x0000000000000000, R11=0x000000012341bfff\r\nR12=0x00000000ffffffff, R13=0x000000012711d208, R14=0x000000012341c000, R15=0xffffffffffffffff\r\nRIP=0x00007fff8973e512, EFLAGS=0x0000000000010282, ERR=0x0000000000000006\r\n  TRAPNO=0x000000000000000e\r\n```\r\n\r\nI understand this as [stb_image trying to parse an IDAT chunk](https://github.com/nothings/stb/blob/ec2158386c877a2388038d0587f22b129a2cc03e/stb_image.h#L4282). My calling-convention-fu is weak but if RDX is supposed to be parameter 3 to stbi__getn, that is suspect. \r\n\r\nI considered a corrupt PNG (generated by TexturePacker), or a failed realloc, but the latter should have already been handled by stb_image, and if I load the TextureAtlas on the main thread, there is no error.\r\n\r\nAny ideas?"},"comment":{"url":"https://api.github.com/repos/libgdx/libgdx/issues/comments/70862615","html_url":"https://github.com/libgdx/libgdx/issues/2763#issuecomment-70862615","issue_url":"https://api.github.com/repos/libgdx/libgdx/issues/2763","id":70862615,"user":{"login":"justinbowes","id":35697,"avatar_url":"https://avatars.githubusercontent.com/u/35697?v=3","gravatar_id":"","url":"https://api.github.com/users/justinbowes","html_url":"https://github.com/justinbowes","followers_url":"https://api.github.com/users/justinbowes/followers","following_url":"https://api.github.com/users/justinbowes/following{/other_user}","gists_url":"https://api.github.com/users/justinbowes/gists{/gist_id}","starred_url":"https://api.github.com/users/justinbowes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justinbowes/subscriptions","organizations_url":"https://api.github.com/users/justinbowes/orgs","repos_url":"https://api.github.com/users/justinbowes/repos","events_url":"https://api.github.com/users/justinbowes/events{/privacy}","received_events_url":"https://api.github.com/users/justinbowes/received_events","type":"User","site_admin":false},"created_at":"2015-01-21T15:56:11Z","updated_at":"2015-01-21T15:56:11Z","body":"The TexturePacker task is running during the bootstrap of DesktopLauncher. If I disable the TexturePacker task, the crash never occurs. If I have it write fewer atlas pages, the crash rarely occurs. If this is a race related to file content flushing, I'm not sure it's worth a further look."}}