[Mesa-dev] [BUG]: calloc (nmemb=1, size=0)

Johann Klammer klammerj at a1.net
Thu Aug 2 22:57:08 PDT 2012


Hello,

I tried to replace the memory allocator for a program
linked against mesa. With the libc allocators the app shows some 
textured and shaded triangles, but with the custom allocators, it's all 
black triangles. Sorry, I cannot post the program source as it is rather 
large, but will try to come up with a minimal test if this is necessary.

The custom allocator returns NULL for zero-sized requests.
The problem goes away if I change the allocator to return some memory.

Mesa Version: 8.0.3

Symptoms:
all black triangles.

The relevant snippet seems to be:

4674  t->immediates = (struct ureg_src *)CALLOC(program->num_immediates 
* sizeof(struct ureg_src));
4675  if (t->immediates == NULL) {
4676  ret = PIPE_ERROR_OUT_OF_MEMORY;
4677  goto out;
4678  }

see:
http://fossies.org/dox/MesaLib-8.0.3/st__glsl__to__tgsi_8cpp_source.html

hardware:
[   33.950374] [drm] nouveau 0000:01:00.0: Detected an NV30 generation 
card (0x034200b1)

driver:
nouveau

gdb backtrace:
#0  0xb7cc5647 in raise (sig=2) at 
../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  0xb7fd8f70 in calloc (nmemb=1, size=0) at alc.c:634
#2  0xb6a717f8 in st_translate_program (ctx=0xb6666000, procType=0,
     ureg=0xb52e3000, program=0xb52ff000, proginfo=0xb52e8000, numInputs=3,
     inputMapping=0xbff75780, inputSemanticName=0xbff756d4 "\001\001\005",
     inputSemanticIndex=0xbff756f4 "", interpMode=0xbff75800, numOutputs=1,
     outputMapping=0xbff75754,
     outputSemanticName=0xbff75714 "\001\200\375\267\234\222\067\265 
\362\375\267\020", outputSemanticIndex=0xbff75734 "", 
passthrough_edgeflags=0 '\000')
     at state_tracker/st_glsl_to_tgsi.cpp:4674
#3  0xb6a3e4c3 in st_translate_fragment_program (st=0xb661e430,
     stfp=0xb52e8000, key=0xbff758e8) at state_tracker/st_program.c:706
#4  0xb6a3ef06 in st_get_fp_variant (st=0xb661e430, stfp=0xb52e8000,
     key=0xbff758e8) at state_tracker/st_program.c:781
#5  0xb6b07d07 in update_fp (st=0xb661e430)
     at state_tracker/st_atom_shader.c:86
#6  0xb6b05316 in st_validate_state (st=0xb661e430)
     at state_tracker/st_atom.c:197
#7  0xb6b0bc78 in st_Clear (ctx=0xb6666000, mask=18)
     at state_tracker/st_cb_clear.c:508
#8  0xb6acce60 in _mesa_Clear (mask=16640) at main/clear.c:242
#9  0x080501cb in event_loop (dpy=0xb77b12e0, win=20971522, glxw=20971523,
     sd=0xbff75d84) at main.c:2671
#10 0x0805193e in main (argc=1, argv=0xbffff514) at main.c:3330


for more context see:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=682812

bye


More information about the mesa-dev mailing list