#jogamp @ irc.freenode.net - 20160501 05:06:20 (UTC)
20160501 05:06:20 -jogamp- Previous @ http://jogamp.org/log/irc/jogamp_20160430050620.html
20160501 05:06:20 -jogamp- This channel is logged @ http://jogamp.org/log/irc/jogamp_20160501050620.html
20160501 08:38:27 * monsieur_max (~maxime@anon) has joined #jogamp
20160501 08:41:14 * hija (~hija@anon) has joined #jogamp
20160501 09:03:02 * hija (~hija@anon) Quit (Quit: hija)
20160501 09:31:56 * philjord (599cc172@anon) Quit (Quit: http://www.kiwiirc.com/ - A hand crafted IRC client)
20160501 09:48:47 * philjord (599cc172@anon) has joined #jogamp
20160501 09:59:38 <bruce-> zubzub: do you have hints on what to do when doing JNA things that sporadically cause the Java VM to quit on SIGBUS?
20160501 09:59:40 * bigpet (uid25664@anon) has joined #jogamp
20160501 10:01:22 <bruce-> I am wrapping a closed source library (Canon EDSDK), most of it seems to actually work, as in I get the right values from the library calls
20160501 10:01:37 <bruce-> I can even decode and show frames from the camera
20160501 10:01:57 <bruce-> but after some seconds the JVM is killed
20160501 11:23:25 <zubzub> bruce-: it's most likely a gc issue
20160501 11:23:36 <zubzub> you're letting go of a reference that's still being used
20160501 11:24:03 <zubzub> (on the native side)
20160501 11:24:10 <zubzub> so when it tries to use it, it segfaults
20160501 11:24:11 * Eclesia (~eclesia@anon) has joined #jogamp
20160501 11:24:32 <bruce-> hm, I also noticed that JNAerator is using NativeLong (64 bit on OSX) where the arguments and return values should be 32 bit
20160501 11:24:50 <Eclesia> o/
20160501 11:24:50 <zubzub> native long should be used when you have plain 'long' on the native side
20160501 11:24:56 <zubzub> o/
20160501 11:25:16 <bruce-> yeah, I have learned that, but that was not the case here
20160501 11:25:35 <zubzub> yeah you have to manually fix it I guess
20160501 11:25:59 <zubzub> jnaerator is a good starting point but as I said, dont trust the code it outputs too much ;)
20160501 11:26:12 <bruce-> I learned that, the hard way
20160501 11:27:40 <bruce-> I fixed most type mapping problems and things run stable until I read some 128kb from a byte buffer that I have directAllocate()d
20160501 11:28:19 <bruce-> if I read smaller amounts of data it does not cause SIGBUS errors
20160501 11:30:08 <bruce-> I am assuming you can just throw a ByteBuffer at C functions that have a writeToHere(void*) signature
20160501 11:30:20 <zubzub> you can
20160501 11:30:26 <zubzub> just make sure you allocated enough memory
20160501 11:30:36 <zubzub> and that you don't free it while the C side still expects it to be there
20160501 11:30:48 <bruce-> it is allocated once and reused
20160501 11:31:02 <zubzub> what sometimes also happens is that you write more data to the buffer than what was allocated
20160501 11:31:17 <zubzub> and as a result you overwrite another buffers memory
20160501 11:31:36 <zubzub> that is, the bookkeeping part of the buffer so your OS does not know anymore how to free that other memory
20160501 11:31:42 <zubzub> so you get a segfault when freeing
20160501 11:31:51 <zubzub> even though the memory is being used just fine
20160501 11:31:58 <zubzub> (but got corrupte by other memory)
20160501 11:32:21 <bruce-> the library reports writing data with sizes of 128kB-280kB, the buffer is 4MB
20160501 11:33:40 <bruce-> what is strange, is that everything is fine until I read from that bytebuffer
20160501 11:34:16 <zubzub> ok, are you sure the memory is not freed by the native library (or by Java?) somewhere?
20160501 11:34:48 <bruce-> and I am pretty sure that everything is synchronous, as in, the library function writes to the bytebuffer then returns and then I read
20160501 11:34:54 <zubzub> usueally a read should not result in a crash, unless you're trying to access protected memory or something
20160501 11:36:28 <bruce-> I try not to free anything once it is allocated, but it could be that the native library just decides to free stuff it does not own
20160501 11:36:40 <zubzub> could be (bad bad library!)
20160501 11:36:54 <zubzub> you free, you mean Java's GC?
20160501 11:37:03 <zubzub> jna does not really allow you to explicitly free
20160501 11:38:54 <bruce-> means, I create objects using the native library, I keep references to them in Java and nothing is explicitely destroyed
20160501 11:41:54 <zubzub> all I can say is check for double or incorrect free's and for buffer overflows
20160501 11:43:28 <zubzub> this is another reason why I wrote my own library instead of using JNA (bridj too), as they try to force Java way of working on a C library
20160501 11:43:37 <zubzub> in regards to memory management
20160501 11:44:05 <zubzub> you can not use java way of working on a C library as that requires reference counting/analysing on the C level which is impossible
20160501 11:44:38 <zubzub> hence you get segfauls unless the user knows exactly how the C library works, at which point you might as well ask the user to free it manually
20160501 11:44:46 <zubzub> which is exactly what my lib does!
20160501 11:44:53 <zubzub> (more shameless promotion :p)
20160501 12:20:19 <bruce-> strange. I added System.gc() in hopes to trigger my problem a bit faster
20160501 12:20:44 <bruce-> instead I can run the program for minutes
20160501 12:21:16 <bruce-> (usually can run it for < 3 seconds)
20160501 14:03:38 <bruce-> zubzub: -Xcheck:jni gives me some hints
20160501 14:04:09 <bruce-> Warning: SIGSEGV handler expected:libjvm.dylib+0x4831d0 found:DppMath+0x4bc24
20160501 14:04:12 <bruce-> what the.
20160501 14:08:17 <bruce-> ok, removing that DppMath library from the .framework file fixes everything
20160501 14:08:24 <bruce-> hm
20160501 14:56:19 <Eclesia> it's JVM crash day : \o/ *** Error in `/home/eclesia/Programs/jdk1.8.0_60/bin/java': corrupted double-linked list: 0x00007f5540046a80 ***
20160501 14:59:33 <Eclesia> funny, vm crash, but newt frames are still here
20160501 17:07:15 * Eclesia (~eclesia@anon) Quit (Quit: Leaving.)
20160501 17:26:51 * guillaum1 (~gl@anon) Quit (Ping timeout: 264 seconds)
20160501 17:41:48 * guillaum1 (~gl@anon) has joined #jogamp
20160501 20:15:24 * monsieur_max (~maxime@anon) Quit (Quit: Leaving.)
20160501 23:02:46 * bigpet (uid25664@anon) Quit (Quit: Connection closed for inactivity)
20160501 23:21:24 * philjord (599cc172@anon) Quit (Quit: http://www.kiwiirc.com/ - A hand crafted IRC client)
20160502 00:04:33 * rmk0 (~rmk0@anon) Quit (Ping timeout: 240 seconds)
20160502 00:26:28 * rmk0 (~rmk0@anon) has joined #jogamp
20160502 04:55:17 * philjord (599cc172@anon) has joined #jogamp
20160502 05:06:20 -jogamp- Continue @ http://jogamp.org/log/irc/jogamp_20160502050620.html