On Mon, 4 Jul 2011 12:41:33 -0700 Dave Ray <cl...@jonive.com> said:

try replace your evas_xlib_buffer.c file with the attached one. it has some
debugging in it to printf some info. it'll being to let me know whats going on
with shm segments. i really suspect this has something to do with shm segments.

> Here is the gdb bt of expedite crashing when run in twm. This is the same
> evas bug that's crashing e17 on OSX.
> 
> Expedite throws this before it finishes drawing the window.
> 
> 
> (gdb) r -e xlib -f
> Starting program: /usr/local/bin/expedite -e xlib -f
> Reading symbols for shared libraries .++++++++............ done
> Reading symbols for shared libraries . done
> Reading symbols for shared libraries . done
> Reading symbols for shared libraries .. done
> 
> Program received signal EXC_BAD_ACCESS, Could not access memory.
> Reason: KERN_INVALID_ADDRESS at address: 0x00000000000001ff
> 0x000000010025c7d4 in _op_copy_c_dp_mmx (s=0x0, m=0x0, c=4294967295, d=0x1ff,
> l=128) at op_copy_color_i386.c:12 12        movq_r2m(mm1, d[0]);
> (gdb) bt
> #0  0x000000010025c7d4 in _op_copy_c_dp_mmx (s=0x0, m=0x0, c=4294967295,
> #d=0x1ff, l=128) at op_copy_color_i386.c:12 1  0x000000010028b3f4 in
> #rectangle_draw_internal () 2  0x000000010028b0d3 in
> #evas_common_rectangle_draw () 3  0x0000000100544562 in eng_rectangle_draw
> #(data=0x100613880, context=0x100613c90, surface=0x10062cd00, x=-592, y=0,
> #w=720, h=420) at evas_engine.c:181 4  0x0000000100217ac1 in
> #evas_object_rectangle_render () 5  0x0000000100247f4a in evas_render_mapped
> #() 6  0x000000010024968b in evas_render_updates_internal () 7
> #0x0000000100249d43 in evas_render () 8  0x0000000100001ab4 in main (argc=4,
> #argv=0x7fff5fbff1f8) at main.c:1373
> (gdb) fr 1 
> #1  0x000000010028b3f4 in rectangle_draw_internal ()
> (gdb) l
> 7        movd_m2r(c, mm1);
> 8        movq_r2r(mm1, mm2);
> 9        psllq_i2r(32, mm1);
> 10       por_r2r(mm2, mm1);
> 11       for (; d < e; d+=2) {
> 12          movq_r2m(mm1, d[0]);
> 13       }
> 14       e+=1;
> 15       for (; d < e; d++) {
> 16          *d = c;
> (gdb) p c
> No symbol "c" in current context.
> (gdb) p mm1
> No symbol "mm1" in current context.
> (gdb) p mm2
> No symbol "mm2" in current context.
> (gdb) p d
> No symbol "d" in current context.
> (gdb) p e
> No symbol "e" in current context.
> (gdb) p *d
> No symbol "d" in current context.
> (gdb) fr 2
> #2  0x000000010028b0d3 in evas_common_rectangle_draw ()
> (gdb) l
> 17       }
> 18    }
> 19    
> 20    #define _op_copy_cn_dp_mmx _op_copy_c_dp_mmx
> 21    #define _op_copy_can_dp_mmx _op_copy_c_dp_mmx
> 22    #define _op_copy_caa_dp_mmx _op_copy_c_dp_mmx
> 23    
> 24    #define _op_copy_cn_dpan_mmx _op_copy_c_dp_mmx
> 25    #define _op_copy_c_dpan_mmx _op_copy_c_dp_mmx
> 26    #define _op_copy_can_dpan_mmx _op_copy_c_dp_mmx
> (gdb) p _op_copy_c_dp_mmx
> $1 = {void (DATA32 *, DATA8 *, DATA32, DATA32 *, int)} 0x10025c794
> <_op_copy_c_dp_mmx> (gdb) p _op_copy_cn_dp_mmx
> No symbol "_op_copy_cn_dp_mmx" in current context.
> (gdb) p _op_copy_can_dp_mmx
> No symbol "_op_copy_can_dp_mmx" in current context.
> (gdb) p _op_copy_caa_dp_mmx
> No symbol "_op_copy_caa_dp_mmx" in current context.
> (gdb) p _op_copy_cn_dpan_mmx
> No symbol "_op_copy_cn_dpan_mmx" in current context.
> (gdb) fr 0
> #0  0x000000010025c7d4 in _op_copy_c_dp_mmx (s=0x0, m=0x0, c=4294967295,
> #d=0x1ff, l=128) at op_copy_color_i386.c:12
> 12          movq_r2m(mm1, d[0]);
> (gdb) l
> 7        movd_m2r(c, mm1);
> 8        movq_r2r(mm1, mm2);
> 9        psllq_i2r(32, mm1);
> 10       por_r2r(mm2, mm1);
> 11       for (; d < e; d+=2) {
> 12          movq_r2m(mm1, d[0]);
> 13       }
> 14       e+=1;
> 15       for (; d < e; d++) {
> 16          *d = c;
> (gdb) fr 3
> #3  0x0000000100544562 in eng_rectangle_draw (data=0x100613880,
> #context=0x100613c90, surface=0x10062cd00, x=-592, y=0, w=720, h=420) at
> #evas_engine.c:181
> 181           evas_common_rectangle_draw(surface, context, x, y, w, h);
> (gdb) l
> 176           )
> 177        evas_common_pipe_rectangle_draw(surface, context, x, y, w, h);
> 178      else
> 179   #endif
> 180        {
> 181           evas_common_rectangle_draw(surface, context, x, y, w, h);
> 182           evas_common_cpu_end_opt();
> 183        }
> 184   }
> 185   
> (gdb) p surface
> $2 = (void *) 0x10062cd00
> (gdb) p context
> $3 = (void *) 0x100613c90
> (gdb) p x
> $4 = -592
> (gdb) p y
> $5 = 0
> (gdb) p w
> $6 = 720
> (gdb) p h
> $7 = 420
> (gdb) fr 4
> #4  0x0000000100217ac1 in evas_object_rectangle_render ()
> (gdb) l
> 186   static void
> 187   eng_line_draw(void *data __UNUSED__, void *context, void *surface,
> int x1, int y1, int x2, int y2) 188   {
> 189   #ifdef BUILD_PIPE_RENDER
> 190      if ((cpunum > 1)
> 191    #ifdef EVAS_FRAME_QUEUING
> 192           && evas_common_frameq_enabled()
> 193   #endif
> 194           )
> 195       evas_common_pipe_line_draw(surface, context, x1, y1, x2, y2);
> (gdb) p cpunum
> $8 = 2
> (gdb) p surface
> No symbol "surface" in current context.
> (gdb) p context
> No symbol "context" in current context.
> (gdb) p x1
> No symbol "x1" in current context.
> (gdb) p y1
> $9 = {<text variable, no debug info>} 0x7fff85a57b60 <y1>
> (gdb) p x2
> No symbol "x2" in current context.
> (gdb) p y2
> No symbol "y2" in current context.
> (gdb) 
> 
> 
> ------------------------------------------------------------------------------
> All of the data generated in your IT infrastructure is seriously valuable.
> Why? It contains a definitive record of application performance, security 
> threats, fraudulent activity, and more. Splunk takes this data and makes 
> sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-d2d-c2
> _______________________________________________
> enlightenment-devel mailing list
> enlightenment-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
> 


-- 
------------- Codito, ergo sum - "I code, therefore I am" --------------
The Rasterman (Carsten Haitzler)    ras...@rasterman.com

#include "evas_common.h"

#include "evas_xlib_buffer.h"

static int _x_err = 0;

void
evas_software_xlib_x_write_mask_line(Outbuf *buf, X_Output_Buffer *xob, DATA32 *src, int w, int y)
{
   int x;
   DATA32 *src_ptr;
   DATA8 *dst_ptr;
   int bpl = 0;

   src_ptr = src;
   dst_ptr = evas_software_xlib_x_output_buffer_data(xob, &bpl);
   dst_ptr = dst_ptr + (bpl * y);
   w -= 7;
   if (buf->priv.x11.xlib.bit_swap)
     {
	for (x = 0; x < w; x += 8)
	  {
	     *dst_ptr =
	       ((A_VAL(&(src_ptr[0])) >> 7) << 7) |
	       ((A_VAL(&(src_ptr[1])) >> 7) << 6) |
	       ((A_VAL(&(src_ptr[2])) >> 7) << 5) |
	       ((A_VAL(&(src_ptr[3])) >> 7) << 4) |
	       ((A_VAL(&(src_ptr[4])) >> 7) << 3) |
	       ((A_VAL(&(src_ptr[5])) >> 7) << 2) |
	       ((A_VAL(&(src_ptr[6])) >> 7) << 1) |
	       ((A_VAL(&(src_ptr[7])) >> 7) << 0);
	     src_ptr += 8;
	     dst_ptr++;
	  }
     }
   else
     {
	for (x = 0; x < w; x += 8)
	  {
	     *dst_ptr =
	       ((A_VAL(&(src_ptr[0])) >> 7) << 0) |
	       ((A_VAL(&(src_ptr[1])) >> 7) << 1) |
	       ((A_VAL(&(src_ptr[2])) >> 7) << 2) |
	       ((A_VAL(&(src_ptr[3])) >> 7) << 3) |
	       ((A_VAL(&(src_ptr[4])) >> 7) << 4) |
	       ((A_VAL(&(src_ptr[5])) >> 7) << 5) |
	       ((A_VAL(&(src_ptr[6])) >> 7) << 6) |
	       ((A_VAL(&(src_ptr[7])) >> 7) << 7);
	     src_ptr += 8;
	     dst_ptr++;
	  }
     }
   w += 7;
   for (; x < w; x ++)
     {
	XPutPixel(xob->xim, x, y, A_VAL(src_ptr) >> 7);
	src_ptr++;
     }
}

void
evas_software_xlib_x_write_mask_line_rev(Outbuf *buf, X_Output_Buffer *xob, DATA32 *src, int w, int y)
{
   int x;
   DATA32 *src_ptr;
   DATA8 *dst_ptr;
   int bpl = 0;

   src_ptr = src + w - 1;
   dst_ptr = evas_software_xlib_x_output_buffer_data(xob, &bpl);
   dst_ptr = dst_ptr + (bpl * y);
   w -= 7;
   if (buf->priv.x11.xlib.bit_swap)
     {
	for (x = 0; x < w; x += 8)
	  {
	     *dst_ptr =
	       ((A_VAL(&(src_ptr[ 0])) >> 7) << 7) |
	       ((A_VAL(&(src_ptr[-1])) >> 7) << 6) |
	       ((A_VAL(&(src_ptr[-2])) >> 7) << 5) |
	       ((A_VAL(&(src_ptr[-3])) >> 7) << 4) |
	       ((A_VAL(&(src_ptr[-4])) >> 7) << 3) |
	       ((A_VAL(&(src_ptr[-5])) >> 7) << 2) |
	       ((A_VAL(&(src_ptr[-6])) >> 7) << 1) |
	       ((A_VAL(&(src_ptr[-7])) >> 7) << 0);
	     src_ptr -= 8;
	     dst_ptr++;
	  }
     }
   else
     {
	for (x = 0; x < w; x += 8)
	  {
	     *dst_ptr =
	       ((A_VAL(&(src_ptr[ 0])) >> 7) << 0) |
	       ((A_VAL(&(src_ptr[-1])) >> 7) << 1) |
	       ((A_VAL(&(src_ptr[-2])) >> 7) << 2) |
	       ((A_VAL(&(src_ptr[-3])) >> 7) << 3) |
	       ((A_VAL(&(src_ptr[-4])) >> 7) << 4) |
	       ((A_VAL(&(src_ptr[-5])) >> 7) << 5) |
	       ((A_VAL(&(src_ptr[-6])) >> 7) << 6) |
	       ((A_VAL(&(src_ptr[-7])) >> 7) << 7);
	     src_ptr -= 8;
	     dst_ptr++;
	  }
     }
   w += 7;
   for (; x < w; x ++)
     {
	XPutPixel(xob->xim, x, y, A_VAL(src_ptr) >> 7);
	src_ptr--;
     }
}

void
evas_software_xlib_x_write_mask_line_vert(Outbuf *buf, X_Output_Buffer *xob, 
                                          DATA32 *src, 
                                          int h, int ym, int w)
{
   int y;
   DATA32 *src_ptr;
   DATA8 *dst_ptr;
   int bpl = 0;

   src_ptr = src;
   dst_ptr = evas_software_xlib_x_output_buffer_data(xob, &bpl);
   dst_ptr = dst_ptr + (bpl * ym);
   h -= 7;
   if (buf->priv.x11.xlib.bit_swap)
     {
	for (y = 0; y < h; y += 8)
	  {
	     *dst_ptr =
	       ((A_VAL(&(src_ptr[0 * w])) >> 7) << 7) |
	       ((A_VAL(&(src_ptr[1 * w])) >> 7) << 6) |
	       ((A_VAL(&(src_ptr[2 * w])) >> 7) << 5) |
	       ((A_VAL(&(src_ptr[3 * w])) >> 7) << 4) |
	       ((A_VAL(&(src_ptr[4 * w])) >> 7) << 3) |
	       ((A_VAL(&(src_ptr[5 * w])) >> 7) << 2) |
	       ((A_VAL(&(src_ptr[6 * w])) >> 7) << 1) |
	       ((A_VAL(&(src_ptr[7 * w])) >> 7) << 0);
	     src_ptr += 8 * w;
	     dst_ptr++;
	  }
     }
   else
     {
	for (y = 0; y < h; y += 8)
	  {
	     *dst_ptr =
	       ((A_VAL(&(src_ptr[0 * w])) >> 7) << 0) |
	       ((A_VAL(&(src_ptr[1 * w])) >> 7) << 1) |
	       ((A_VAL(&(src_ptr[2 * w])) >> 7) << 2) |
	       ((A_VAL(&(src_ptr[3 * w])) >> 7) << 3) |
	       ((A_VAL(&(src_ptr[4 * w])) >> 7) << 4) |
	       ((A_VAL(&(src_ptr[5 * w])) >> 7) << 5) |
	       ((A_VAL(&(src_ptr[6 * w])) >> 7) << 6) |
	       ((A_VAL(&(src_ptr[7 * w])) >> 7) << 7);
	     src_ptr += 8 * w;
	     dst_ptr++;
	  }
     }
   h += 7;
   for (; y < h; y ++)
     {
	XPutPixel(xob->xim, y, ym, A_VAL(src_ptr) >> 7);
	src_ptr += w;
     }
}

void
evas_software_xlib_x_write_mask_line_vert_rev(Outbuf *buf, X_Output_Buffer *xob, 
                                              DATA32 *src, 
                                              int h, int ym, int w)
{
   int y;
   DATA32 *src_ptr;
   DATA8 *dst_ptr;
   int bpl = 0;

   src_ptr = src + ((h - 1) * w);
   dst_ptr = evas_software_xlib_x_output_buffer_data(xob, &bpl);
   dst_ptr = dst_ptr + (bpl * ym);
   h -= 7;
   if (buf->priv.x11.xlib.bit_swap)
     {
	for (y = 0; y < h; y += 8)
	  {
	     *dst_ptr =
	       ((A_VAL(&(src_ptr[ 0 * w])) >> 7) << 7) |
	       ((A_VAL(&(src_ptr[-1 * w])) >> 7) << 6) |
	       ((A_VAL(&(src_ptr[-2 * w])) >> 7) << 5) |
	       ((A_VAL(&(src_ptr[-3 * w])) >> 7) << 4) |
	       ((A_VAL(&(src_ptr[-4 * w])) >> 7) << 3) |
	       ((A_VAL(&(src_ptr[-5 * w])) >> 7) << 2) |
	       ((A_VAL(&(src_ptr[-6 * w])) >> 7) << 1) |
	       ((A_VAL(&(src_ptr[-7 * w])) >> 7) << 0);
	     src_ptr -= 8 * w;
	     dst_ptr++;
	  }
     }
   else
     {
	for (y = 0; y < h; y += 8)
	  {
	     *dst_ptr =
	       ((A_VAL(&(src_ptr[ 0 * w])) >> 7) << 0) |
	       ((A_VAL(&(src_ptr[-1 * w])) >> 7) << 1) |
	       ((A_VAL(&(src_ptr[-2 * w])) >> 7) << 2) |
	       ((A_VAL(&(src_ptr[-3 * w])) >> 7) << 3) |
	       ((A_VAL(&(src_ptr[-4 * w])) >> 7) << 4) |
	       ((A_VAL(&(src_ptr[-5 * w])) >> 7) << 5) |
	       ((A_VAL(&(src_ptr[-6 * w])) >> 7) << 6) |
	       ((A_VAL(&(src_ptr[-7 * w])) >> 7) << 7);
	     src_ptr -= 8 * w;
	     dst_ptr++;
	  }
     }
   h += 7;
   for (; y < h; y ++)
     {
	XPutPixel(xob->xim, y, ym, A_VAL(src_ptr) >> 7);
	src_ptr -= w;
     }
}

int
evas_software_xlib_x_can_do_shm(Display *d)
{
   static Display *cached_d = NULL;
   static int cached_result = 0;
   
   if (d == cached_d) return cached_result;
   cached_d = d;
   if (XShmQueryExtension(d))
     {
	X_Output_Buffer *xob;

	xob = evas_software_xlib_x_output_buffer_new
	  (d, DefaultVisual(d, DefaultScreen(d)),
	   DefaultDepth(d, DefaultScreen(d)), 16, 16, 2, NULL);
	if (!xob)
	  {
	     cached_result = 0;
	     return 0;
	  }
	evas_software_xlib_x_output_buffer_free(xob, 1);
	cached_result = 1;
	return 1;
     }
   cached_result = 0;
   return 0;
}

static void
x_output_tmp_x_err(Display *d __UNUSED__, XErrorEvent *ev __UNUSED__)
{
   _x_err = 1;
   return;
}

//static int creates = 0;

X_Output_Buffer *
evas_software_xlib_x_output_buffer_new(Display *d, Visual *v, int depth, int w, int h, int try_shm, void *data)
{
   X_Output_Buffer *xob;

   xob = calloc(1, sizeof(X_Output_Buffer));
   if (!xob) return NULL;

   xob->display = d;
   xob->visual = v;
   xob->xim = NULL;
   xob->shm_info = NULL;
   xob->w = w;
   xob->h = h;

   if (try_shm > 0)
     {
	xob->shm_info = malloc(sizeof(XShmSegmentInfo));
	if (xob->shm_info)
	  {
	     xob->xim = XShmCreateImage(d, v, depth, ZPixmap, NULL,
					xob->shm_info, w, h);
	     if (xob->xim)
	       {
		  xob->shm_info->shmid = shmget(IPC_PRIVATE,
						xob->xim->bytes_per_line *
						xob->xim->height,
						IPC_CREAT | 0777);
                  printf("SHM: %i bytes x %i lines ID = %i\n",
                         xob->xim->bytes_per_line, xob->xim->height,
                         xob->shm_info->shmid);
		  if (xob->shm_info->shmid >= 0)
		    {
		       xob->shm_info->readOnly = False;
		       xob->shm_info->shmaddr = xob->xim->data =
			 shmat(xob->shm_info->shmid, 0, 0);
                       printf("SHM ADDR: ID = %i, address = %p\n",
                              xob->shm_info->shmid,
                              xob->shm_info->shmaddr);
		       if (xob->shm_info->shmaddr != ((void *)-1))
			 {
			    XErrorHandler ph;
                            
                            if (try_shm == 2) // only needed during testing
                              {
                                 XSync(d, False);
                                 _x_err = 0;
                                 ph = XSetErrorHandler((XErrorHandler)
                                                       x_output_tmp_x_err);
                              }
#if defined(EVAS_FRAME_QUEUING) && defined(LIBXEXT_VERSION_LOW)
                    /* workaround for libXext of lower then 1.1.1 */
                    if (evas_common_frameq_enabled())
                       XLockDisplay(d);
#endif
			    XShmAttach(d, xob->shm_info);
#if defined(EVAS_FRAME_QUEUING) && defined(LIBXEXT_VERSION_LOW)
                    /* workaround for libXext of lower then 1.1.1 */
                    if (evas_common_frameq_enabled())
                       XUnlockDisplay(d);
#endif

                            if (try_shm == 2) // only needed during testing
                              {
                                 XSync(d, False); 
                                 XSetErrorHandler((XErrorHandler)ph);
                              }
                            if (!_x_err)
                              {
				 xob->bpl = xob->xim->bytes_per_line;
				 xob->psize = xob->bpl * xob->h;
				 return xob;
			      }
			 }
		       shmdt(xob->shm_info->shmaddr);
		       shmctl(xob->shm_info->shmid, IPC_RMID, 0);
		    }
		  if (xob->xim) XDestroyImage(xob->xim);
		  xob->xim = NULL;
	       }
	     if (xob->shm_info) free(xob->shm_info);
	     xob->shm_info = NULL;
	  }
     }

   if (try_shm > 1) return NULL;

   xob->xim = XCreateImage(d, v, depth, ZPixmap, 0, data, w, h, 32, 0);
   if (!xob->xim)
     {
	free(xob);
	return NULL;
     }

   xob->data = data;

   if (!xob->xim->data)
     {
	xob->xim->data = malloc(xob->xim->bytes_per_line * xob->xim->height);
	if (!xob->xim->data)
	  {
	     XDestroyImage(xob->xim);
	     free(xob);
	     return NULL;
	  }
     }
   xob->bpl = xob->xim->bytes_per_line;
   xob->psize = xob->bpl * xob->h;
   return xob;
}

void
evas_software_xlib_x_output_buffer_free(X_Output_Buffer *xob, int psync)
{
   if (xob->shm_info)
     {
	if (psync) XSync(xob->display, False);
	XShmDetach(xob->display, xob->shm_info);
	XDestroyImage(xob->xim);
	shmdt(xob->shm_info->shmaddr);
	shmctl(xob->shm_info->shmid, IPC_RMID, 0);
	free(xob->shm_info);
     }
   else
     {
	if (xob->data) xob->xim->data = NULL;
	XDestroyImage(xob->xim);
     }
   free(xob);
}

void
evas_software_xlib_x_output_buffer_paste(X_Output_Buffer *xob, Drawable d, GC gc, int x, int y, int psync)
{
   if (xob->shm_info)
     {
	XShmPutImage(xob->display, d, gc, xob->xim, 0, 0, x, y,
		     xob->w, xob->h, False);
	if (psync) XSync(xob->display, False);
     }
   else
     {
	XPutImage(xob->display, d, gc, xob->xim, 0, 0, x, y,
		  xob->w, xob->h);
     }
}

DATA8 *
evas_software_xlib_x_output_buffer_data(X_Output_Buffer *xob, int *bytes_per_line_ret)
{
   if (bytes_per_line_ret) *bytes_per_line_ret = xob->xim->bytes_per_line;
   return (DATA8 *)xob->xim->data;
}

int
evas_software_xlib_x_output_buffer_depth(X_Output_Buffer *xob)
{
   return xob->xim->bits_per_pixel;
}

int
evas_software_xlib_x_output_buffer_byte_order(X_Output_Buffer *xob)
{
   return xob->xim->byte_order;
}

int
evas_software_xlib_x_output_buffer_bit_order(X_Output_Buffer *xob)
{
   return xob->xim->bitmap_bit_order;
}
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to