Sponsored Content
Operating Systems Linux Red Hat Memmove fail on 4 Gb+ raster under RHEL 64 bit Post 302914363 by imagtek on Monday 25th of August 2014 10:01:24 AM
Old 08-25-2014
Reply memmove fail

Many sincere thanks. Very useful info. I admit that I have been rather cavalier slinging gigabytes of image memory around on a 64 bit machine with 8 Gb RAM, simply because I've been getting away with it, not due to deep understanding.

I've been assuming that (longu)(a * b * c) would cast every int32 in the expression to 64 bit long BEFORE the calculation. If that is the problem, how embarrassing...I thought I knew how to code.

I will pursue these leads and get back with the resolution. I think one of you probably nailed it. I want to be able to rotate an image of ANY size, machine capable of course.
Thanks again guys.
imagtek

---------- Post updated at 10:01 AM ---------- Previous update was at 08:52 AM ----------

OK. The problem is fixed. I was overflowing the expression used to determine the reallocated raster size.

The array dimensions Rcols, Rrows were int32. Plenty big for
any realistic raster dimension, but computationally vulnerable.

I assumed that casting a C/C++ expression such as
(long)(a * b * c)
had the effect of
( (long)a * (long)b * (long)c )
it does NOT.

I misunderstood the language spec. In 32 bit environment this hid in the grass. In 64 bit, it is a very big deal. I read the language spec over and over but somehow missed this subtlety.

The variables inside the expression are promoted to the largest type INSIDE the expression before computation. Any cast outside the expression effects only the expression result.

Images are getting big enough now that it finally bit me. Simple fix in about a dozen routines vulnerable to this.

Now my 4 Gb image rotates nicely to a 5 Gb image. Just takes awhile... Need to revisit some vulnerable code. Now I don't understand why some things did NOT blow up, but not an issue for here.

You're never to old to learn something you should have known a long time ago.

Thanks Guys! Bugs based upon misconceptions are the worst.

imagtek
 

7 More Discussions You Might Find Interesting

1. Programming

copying or concatinating string from 1st bit, leaving 0th bit

Hello, If i have 2 strings str1 and str2, i would like to copy/concatenate str2 to str1, from 1st bit leaving the 0th bit. How do i do it? (2 Replies)
Discussion started by: jazz
2 Replies

2. Programming

q on memmove()

Besides syntax-related issues, is there anything else I should be aware of when using memmove() ? If misued, can it create runtime errors ? (3 Replies)
Discussion started by: JamesGoh
3 Replies

3. Shell Programming and Scripting

Learning - Why does this bit of code fail

In bash: for i in 1 2 3 4 5 do tmp_${i}=$i echo $i done It gives error on executing tmp_1=1, and so on... Why? If I executed this in prompt, not from script, it shouldn't make a subshell should it? please use "code" tags! thanks... (2 Replies)
Discussion started by: StuartH
2 Replies

4. Red Hat

Wrong ELFCLASS64 in RHEL 5 64 bit

Hi, I am using DB2 9.7 , configured odbc.ini file and exported environment variables but I am getting the following error. error while loading shared libraries: libodbc.so.1: wrong ELF class: ELFCLASS64 Kindly help. (4 Replies)
Discussion started by: roopalidalvi231
4 Replies

5. Shell Programming and Scripting

How to handle 64 bit arithmetic operation at 32 bit compiled perl interpreter?H

Hi, Here is the issue. From the program snippet I have Base: 0x1800000000, Size: 0x3FFE7FFFFFFFF which are of 40 and 56 bits. SO I used use bignum to do the math but summing them up I always failed having correct result. perl interpreter info, perl, v5.8.8 built for... (0 Replies)
Discussion started by: rrd1986
0 Replies

6. Red Hat

DNS Service not Start in RHEL 6.4 64 bit

Hi All, I am new to linux and i am configuring DNS server but while i restart service it shows below given error. Please help to solve this error. # /etc/init.d/named restart Stopping named: Generating /etc/rndc.key: ... (2 Replies)
Discussion started by: Chintanghanti
2 Replies

7. Windows & DOS: Issues & Discussions

Which version of Windows Vista to install with a product key? 32-bit or 64-bit?

Hello everyone. I bought a dell laptop (XPS M1330) online which came without a hard drive. There is a Windows Vista Ultimate OEMAct sticker with product key at the bottom case. I checked dell website (here) for this model and it says this model supports both 32 and 64-bit version of Windows... (4 Replies)
Discussion started by: milhan
4 Replies
GLBITMAP(3G)															      GLBITMAP(3G)

NAME
glBitmap - draw a bitmap C SPECIFICATION
void glBitmap( GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap ) PARAMETERS
width, height Specify the pixel width and height of the bitmap image. xorig, yorig Specify the location of the origin in the bitmap image. The origin is measured from the lower left corner of the bitmap, with right and up being the positive axes. xmove, ymove Specify the x and y offsets to be added to the current raster position after the bitmap is drawn. bitmap Specifies the address of the bitmap image. DESCRIPTION
A bitmap is a binary image. When drawn, the bitmap is positioned relative to the current raster position, and frame buffer pixels corre- sponding to 1's in the bitmap are written using the current raster color or index. Frame buffer pixels corresponding to 0's in the bitmap are not modified. glBitmap takes seven arguments. The first pair specifies the width and height of the bitmap image. The second pair specifies the location of the bitmap origin relative to the lower left corner of the bitmap image. The third pair of arguments specifies x and y offsets to be added to the current raster position after the bitmap has been drawn. The final argument is a pointer to the bitmap image itself. The bitmap image is interpreted like image data for the glDrawPixels command, with width and height corresponding to the width and height arguments of that command, and with type set to GL_BITMAP and format set to GL_COLOR_INDEX. Modes specified using glPixelStore affect the interpretation of bitmap image data; modes specified using glPixelTransfer do not. If the current raster position is invalid, glBitmap is ignored. Otherwise, the lower left corner of the bitmap image is positioned at the window coordinates xw=|_xr-xo_| yw=|_yr-yo_| where (xr,yr) is the raster position and (xo,yo) is the bitmap origin. Fragments are then generated for each pixel corresponding to a 1 (one) in the bitmap image. These fragments are generated using the current raster z coordinate, color or color index, and current raster texture coordinates. They are then treated just as if they had been generated by a point, line, or polygon, including texture mapping, fogging, and all per-fragment operations such as alpha and depth testing. After the bitmap has been drawn, the x and y coordinates of the current raster position are offset by xmove and ymove. No change is made to the z coordinate of the current raster position, or to the current raster color, texture coordinates, or index. NOTES
To set a valid raster position outside the viewport, first set a valid raster position inside the viewport, then call glBitmap with NULL as the bitmap parameter and with xmove and ymove set to the offsets of the new raster position. This technique is useful when panning an image around the viewport. ERRORS
GL_INVALID_VALUE is generated if width or height is negative. GL_INVALID_OPERATION is generated if glBitmap is executed between the execution of glBegin and the corresponding execution of glEnd. ASSOCIATED GETS
glGet with argument GL_CURRENT_RASTER_POSITION glGet with argument GL_CURRENT_RASTER_COLOR glGet with argument GL_CURRENT_RASTER_DISTANCE glGet with argument GL_CURRENT_RASTER_INDEX glGet with argument GL_CURRENT_RASTER_TEXTURE_COORDS glGet with argument GL_CURRENT_RASTER_POSITION_VALID SEE ALSO
glDrawPixels(3G), glPixelStore(3G), glPixelTransfer(3G), glRasterPos(3G) GLBITMAP(3G)
All times are GMT -4. The time now is 03:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy