<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://jogamp.org/bugzilla/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.2"
          urlbase="https://jogamp.org/bugzilla/"
          
          maintainer="sgothel@jausoft.com"
>

    <bug>
          <bug_id>1180</bug_id>
          
          <creation_ts>2015-07-24 15:41:45 +0200</creation_ts>
          <short_desc>Buffers.newDirectIntBuffer(int[]) does not set limit</short_desc>
          <delta_ts>2015-09-27 01:30:11 +0200</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>3</classification_id>
          <classification>JogAmp</classification>
          <product>Gluegen</product>
          <component>core</component>
          <version>2.3.2</version>
          <rep_platform>All</rep_platform>
          <op_sys>all</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>---</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter>johan</reporter>
          <assigned_to name="Sven Gothel">sgothel</assigned_to>
          
          
          <cf_type>---</cf_type>
          <cf_scm_refs>gluegen ce9187bbbf62389fc7897a87f36952cdd23674f6
gluegen c7ecc12a3b9281360e2121f02e9985be3b680f7f
gluegen c7edf7debd03ac688fca32d91b4f98f21de2a7af
jogl 8e1f5fc43ba84d5e6373f0c29089ac32b7ce95dd</cf_scm_refs>
          <cf_workaround>---</cf_workaround>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>4801</commentid>
    <comment_count>0</comment_count>
    <who name="">johan</who>
    <bug_when>2015-07-24 15:41:45 +0200</bug_when>
    <thetext>Discussion here
http://forum.jogamp.org/Buffers-newDirectIntBuffer-int-does-not-set-limit-td4034959.html

Details reproduced from the forum here:
I noticed that Buffers.newDirectIntBuffer(int[]) does not set the limit of the buffer. This causes a driver crash on OSX. 

When using this form: 
final IntBuffer indexBuf = Buffers.newDirectIntBuffer(triIndexes);
This is the trace output when I upload the data to the driver: 
glBindBuffer(&lt;int&gt; 0x8893, &lt;int&gt; 0x3)
glBufferData(&lt;int&gt; 0x8893, &lt;long&gt; 0, &lt;java.nio.Buffer&gt; java.nio.DirectIntBufferU[pos=0 lim=0 cap=89034], &lt;int&gt; 0x88E4)

and finally the driver crashes when it is time to render: 
glDrawElements(&lt;int&gt; 0x4, &lt;int&gt; 0x15BCA, &lt;int&gt; 0x1405, &lt;long&gt; 0)#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x000000010fd4b3b0, pid=1443, tid=31031
#
# JRE version: Java(TM) SE Runtime Environment (8.0-b132) (build 1.8.0-b132)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.0-b70 mixed mode bsd-amd64 compressed oops)
# Problematic frame:
# C  [libsystem_platform.dylib+0x13b0]  _platform_memmove$VARIANT$Nehalem+0x70

But if I do this: 
final IntBuffer indexBuf = Buffers.newDirectIntBuffer(triIndexes.length);
for (int triIndex : triIndexes) {
	indexBuf.put(triIndex) ;
}

The trace for uploading the buffer is this: 
glBindBuffer(&lt;int&gt; 0x8893, &lt;int&gt; 0x3)
glBufferData(&lt;int&gt; 0x8893, &lt;long&gt; 356136, &lt;java.nio.Buffer&gt; java.nio.DirectIntBufferU[pos=0 lim=89034 cap=89034], &lt;int&gt; 0x88E4)

Notice the limit is set to the number of ints I put into the buffer and now the driver does not crash.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4802</commentid>
    <comment_count>1</comment_count>
    <who name="">johan</who>
    <bug_when>2015-07-24 15:46:08 +0200</bug_when>
    <thetext>In the forum Xerxes suggested using niobuffer#clear() instead of rewind. Maybe flip() is more appropriate in this case. Anyway, the forum has a patch from Xerxes that I currently can not test since I haven&apos;t set up to build gluegen.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4803</commentid>
    <comment_count>2</comment_count>
      <attachid>708</attachid>
    <who name="Xerxes Rånby">xerxes</who>
    <bug_when>2015-07-24 16:52:47 +0200</bug_when>
    <thetext>Created attachment 708
gluegen-rewind-to-clear.patch

I took a quick look and wrote a proposed &quot;fix&quot;. By replacing the use of NIO Buffer rewind with clear.
gluegen-rewind-to-clear.patch
Please test!

All gluegen junit.run tests pass on my machine with the patch applied.

Using clear sounds counter intuitive but the java doc confirm that it is the right thing to do.

http://docs.oracle.com/javase/7/docs/api/java/nio/Buffer.html#clear%28%29
&quot;public final Buffer clear()

Clears this buffer. The position is set to zero, the limit is set to the capacity, and the mark is discarded.

Invoke this method before using a sequence of channel-read or put operations to fill this buffer. For example:

         buf.clear();     // Prepare buffer for reading
         in.read(buf);    // Read data

This method does not actually erase the data in the buffer, but it is named as if it did because it will most often be used in situations in which that might as well be the case.&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4804</commentid>
    <comment_count>3</comment_count>
      <attachid>709</attachid>
    <who name="Xerxes Rånby">xerxes</who>
    <bug_when>2015-07-24 18:56:12 +0200</bug_when>
    <thetext>Created attachment 709
junit-Test-Buffers-positionLimitCapacityAfterArrayAllocation.patch

junit test to check that position limit and capacity is set as intended after Buffers.newDirect*Buffer(*[]) allocation.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4805</commentid>
    <comment_count>4</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2015-07-24 19:02:01 +0200</bug_when>
    <thetext>(In reply to comment #2)
&gt; Created attachment 708 [details]
&gt; gluegen-rewind-to-clear.patch
&gt; 
&gt; I took a quick look and wrote a proposed &quot;fix&quot;. By replacing the use of NIO
&gt; Buffer rewind with clear.

ByteBuffer.asIntBuffer():
The new buffer&apos;s position will be zero, its capacity and its limit
will be the number of bytes remaining in this buffer divided by
four, and its mark will be undefined.

For all the array NIO Buffer create method in Buffers, we do as:
  &apos;ByteBuffer&apos; -&gt; as&lt;Type&gt;() -&gt; nativeOrder -&gt; &apos;fill data&apos; -&gt; rewind()

The limit/capacity shall be handled by &apos;as&lt;Type&gt;()&apos;, see above.

Hence the patch shall not be required.

+++

Further, we need to see how the &apos;limit&apos; gets broken 
and why (and how) it is used in our glBufferData(..) ?

Quite weird ..</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4806</commentid>
    <comment_count>5</comment_count>
    <who name="">johan</who>
    <bug_when>2015-07-24 19:43:09 +0200</bug_when>
    <thetext>I am pressed for time so can not make a test case for several days. However I strongly suspect the reason for the driver crash is my code. I do this:


gl.glBindBuffer(GL4.GL_ELEMENT_ARRAY_BUFFER, this.vbos[bufferIndex]);
final int bufferSizeInBytes = values.remaining() * Buffers.SIZEOF_INT;
gl.glBufferData(GL4.GL_ELEMENT_ARRAY_BUFFER, bufferSizeInBytes, values, GL4.GL_STATIC_DRAW);


Notice that I use &apos;remaining()&apos; to see how much data is in the buffer. Remaining is the difference between limit-position. So my code assumes that the buffer is at position 0 and limit is set to the number of elements in the buffer. When limit is 0 that is probably the reason for breaking the driver. 

However, I would assume (maybe falsely) that:
Buffers.newDirectIntBuffer(int[]) would be equivalent to allocating a buffer and then &apos;put&apos; all the data from the array i.e. limit should be the number of elements in the array. So that I can flip() the buffer and be ready to read from it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4807</commentid>
    <comment_count>6</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2015-07-24 22:02:42 +0200</bug_when>
    <thetext>(In reply to comment #3)
&gt; Created attachment 709 [details]
&gt; junit-Test-Buffers-positionLimitCapacityAfterArrayAllocation.patch
&gt; 
&gt; junit test to check that position limit and capacity is set as intended
&gt; after Buffers.newDirect*Buffer(*[]) allocation.

Your git patch has been merged.

Minor nagging:

Please use &apos;Bug 1180&apos; instead of any other notation
in you git commit message and elsewhere, 
otherwise we have a hard time to find related pieces of code.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4808</commentid>
    <comment_count>7</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2015-07-24 22:04:54 +0200</bug_when>
    <thetext>(In reply to comment #5)
&gt; I am pressed for time so can not make a test case for several days. However
&gt; I strongly suspect the reason for the driver crash is my code. I do this:
&gt; 
&gt; 
&gt; gl.glBindBuffer(GL4.GL_ELEMENT_ARRAY_BUFFER, this.vbos[bufferIndex]);
&gt; final int bufferSizeInBytes = values.remaining() * Buffers.SIZEOF_INT;
&gt; gl.glBufferData(GL4.GL_ELEMENT_ARRAY_BUFFER, bufferSizeInBytes, values,
&gt; GL4.GL_STATIC_DRAW);
&gt; 
&gt; 
&gt; Notice that I use &apos;remaining()&apos; to see how much data is in the buffer.
&gt; Remaining is the difference between limit-position. So my code assumes that
&gt; the buffer is at position 0 and limit is set to the number of elements in
&gt; the buffer. When limit is 0 that is probably the reason for breaking the
&gt; driver. 

Thank you  ... I will attempt to make a unit test.

&gt; 
&gt; However, I would assume (maybe falsely) that:
&gt; Buffers.newDirectIntBuffer(int[]) would be equivalent to allocating a buffer
&gt; and then &apos;put&apos; all the data from the array i.e. limit should be the number
&gt; of elements in the array. So that I can flip() the buffer and be ready to
&gt; read from it.

Yes .. limit shall be equal to capacity.

A unit test for Buffers in this regard has been added to GlueGen:
ce9187bbbf62389fc7897a87f36952cdd23674f6
c7ecc12a3b9281360e2121f02e9985be3b680f7f</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4809</commentid>
    <comment_count>8</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2015-07-24 22:53:06 +0200</bug_when>
    <thetext>gluegen c7edf7debd03ac688fca32d91b4f98f21de2a7af:
  Add test for remaining()

jogl 8e1f5fc43ba84d5e6373f0c29089ac32b7ce95dd:
  Refine TestMapBufferRead01NEWT, add TestMapBufferRead02NEWT: 
    Add assertion checks and latter test uses FloatBuffer


.. so far, everything passes</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4812</commentid>
    <comment_count>9</comment_count>
    <who name="">johan</who>
    <bug_when>2015-07-25 09:29:33 +0200</bug_when>
    <thetext>The problem was that I assumed position to be set so that the buffer should be flipped before reading from it. This is not the case:

public class BuffersTest {
	@Test
	public void testFlipReadOnExplicitlyPutBuffer() {
		IntBuffer explicit = Buffers.newDirectIntBuffer(3);
		explicit.put(1) ;
		explicit.put(2) ;
		explicit.put(3) ;
		explicit.flip() ;
		
		assertTrue(explicit.get() == 1) ;
		assertTrue(explicit.get() == 2) ;
		assertTrue(explicit.get() == 3) ;
	}
	
	@Test
	public void testFlipReadOnArrayCreatedBuffer() {
		IntBuffer implicit = Buffers.newDirectIntBuffer(new int[] {1,2,3});
		implicit.flip() ;
		
		assertTrue(implicit.get() == 1) ;
		assertTrue(implicit.get() == 2) ;
		assertTrue(implicit.get() == 3) ;
	}
}

I don&apos;t think this is a bug, more like I made the wrong assumption about how the Buffers class worked. Will close this issue if I can.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>4815</commentid>
    <comment_count>10</comment_count>
    <who name="Sven Gothel">sgothel</who>
    <bug_when>2015-07-25 14:38:42 +0200</bug_when>
    <thetext>Indeed, the Buffers method acts as if flip() has already being called,
i.e. pos=0 and limit=capacity=array.lenght.

Hence this bug report is invalid, not &apos;fixed&apos;.

Thank you.

We may want to consider to add API documentation 
about the state of created buffers, i.e. pos, limit and capacity.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>708</attachid>
            <date>2015-07-24 16:52:47 +0200</date>
            <delta_ts>2015-07-24 16:52:47 +0200</delta_ts>
            <desc>gluegen-rewind-to-clear.patch</desc>
            <filename>gluegen-rewind-to-clear.patch</filename>
            <type>text/plain</type>
            <size>3397</size>
            <attacher name="Xerxes Rånby">xerxes</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL3NyYy9qYXZhL2NvbS9qb2dhbXAvY29tbW9uL25pby9CdWZmZXJzLmphdmEg
Yi9zcmMvamF2YS9jb20vam9nYW1wL2NvbW1vbi9uaW8vQnVmZmVycy5qYX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WVzLCBvZmZzZXQsIGxlbmd0aCkuY2xlYXIoKTsKICAgICB9CiAK
ICAgICBwdWJsaWMgc3RhdGljIENoYXJCdWZmZXIgbmV3RGlyZWN0Q2hhckJ1ZmZlcihmaW5hbCBj
aGFyW10gdmFsdWVzLCBmaW5hbCBpbnQgb2Zmc2V0KSB7Cg==
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>709</attachid>
            <date>2015-07-24 18:56:12 +0200</date>
            <delta_ts>2015-07-24 18:56:12 +0200</delta_ts>
            <desc>junit-Test-Buffers-positionLimitCapacityAfterArrayAllocation.patch</desc>
            <filename>junit-Test-Buffers-positionLimitCapacityAfterArrayAllocation.patch</filename>
            <type>text/plain</type>
            <size>3048</size>
            <attacher name="Xerxes Rånby">xerxes</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL3NyYy9qdW5pdC9jb20vam9nYW1wL2NvbW1vbi9uaW8vQnVmZmVyc1Rlc3Qu
amF2YSBiL3NyYy9qdW5pdC9jb20vam9nYW1wL2NvbW1vbi9uaW8vQnVmZmVyc1Rlc3QuamF2YQpp
bmRleCBjNmE4OWYxLi43MTc0MDE1IDEwMDY0NAotLS0gYS9zcmMvanVuaXQvY29tL2pvZ2FtcC9j
b21tb24vbmlvL0J1ZmZlcnNUZXN0LmphdmEKKysrIGIvc3JjL2p1bml0L2NvbS9qb2dhbXAvY29t
bW9uL25pby9CdWZmZXJzVGVzdC5qYXZhCkBAIC0zMSw3ICszMSwxNCBAQAogICovCiBwYWNrYWdl
IGNvbS5qb2dhbXAuY29tbW9uLm5pbzsKIAoraW1wb3J0IGphdmEubmlvLkJ5dGVCdWZmZXI7Citp
bXBvcnQgamF2YS5uaW8uQ2hhckJ1ZmZlcjsKK2ltcG9ydCBqYXZhLm5pby5Eb3VibGVCdWZmZXI7
CitpbXBvcnQgamF2YS5uaW8uRmxvYXRCdWZmZXI7CiBpbXBvcnQgamF2YS5uaW8uSW50QnVm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MoNywgY2hhckJ1ZmZlci5jYXBhY2l0eSgpKTsKKyAgICAgICAgYXNzZXJ0RXF1
YWxzKDYsIGNoYXJCdWZmZXIuZ2V0KDUpKTsKKyAgICB9CisKKyAgICBAVGVzdAogICAgIHB1Ymxp
YyB2b2lkIHNsaWNlKCkgewogCiAgICAgICAgIGZpbmFsIEludEJ1ZmZlciBidWZmZXIgPSBCdWZm
ZXJzLm5ld0RpcmVjdEludEJ1ZmZlcig2KTsK
</data>

          </attachment>
      

    </bug>

</bugzilla>