Hello helour,
Houston, I think we have a problem. First off — eliminate memory exhaustion. I’ve run the command on a 64 GB machine, the maximum process size was 9.8 GB, but the same error message
prevailed. Interestingly, while monitoring the process memory size, it dropped dramatically to a mere 2.2 GB immediately after the execution of the store
command, but before input
posted to the shell log.
I ran a more extensive pipeline with a few -display
commands to print image list statistics, and an eval
command to run a trivial bit of diagnostics in the math evaluator. Two trials, one with a much smaller trial image; the pipeline ran as expected. The pipeline failed with the 30289 × 6511 → 197,211,679 pixel image. The error message differs, and, I think furnishes some insights as to how the internals are running off the rails. Gory debug
mode details follow for the two trials.
Trial 1: 3028 × 651 → 1,971,228 pixels. Works as expected.
gosgood@bertha ~ $ gmic -debug input 0 name. Dummy input 3028,651,1,3,255*u -name. foo vlen='{wh}' -d , store[foo] bar eval "{ref(get('bar',"\$vlen"),noise);print(size(noise))}" -d[Dummy] , input \$bar
[gmic]-0./ Start G'MIC interpreter (in debug mode).<gmic>-0./ Initial command line: 'cli_start , -debug input 0 name. Dummy input 3028,651,1,3,255*u -name. foo vlen={wh} -d , store[foo] bar eval {ref(get('bar',$vlen),noise);print(size(noise))} -d[Dummy] , input $bar'.
<gmic>./ Decompose command line into 22 items:
<gmic>./ item[0] = 'cli_start'
<gmic>./ item[1] = ','
<gmic>./ item[2] = '-debug'
<gmic>./ item[3] = 'input'
<gmic>./ item[4] = '0'
<gmic>./ item[5] = 'name.'
<gmic>./ item[6] = 'Dummy'
<gmic>./ item[7] = 'input'
<gmic>./ item[8] = '3028,651,1,3,255*u'
<gmic>./ item[9] = '-name.'
<gmic>./ item[10] = 'foo'
<gmic>./ item[11] = 'vlen={wh}'
<gmic>./ item[12] = '-d'
<gmic>./ item[13] = ','
<gmic>./ item[14] = 'store[foo]'
<gmic>./ item[15] = 'bar'
<gmic>./ item[16] = 'eval'
<gmic>./ item[17] = '{ref(get('bar',$vlen),noise);print(size(noise))}'
<gmic>./ item[18] = '-d[Dummy]'
<gmic>./ item[19] = ','
<gmic>./ item[20] = 'input'
<gmic>./ item[21] = '$bar'
<gmic>-0./ Enter scope './'.
<gmic>-0./ Item[0]: 'cli_start', selection [].
<gmic>-0./ Found custom command 'cli_start: ' (takes no arguments).
<gmic>-0./ Expand command line for command 'cli_start' to: ''.
<gmic>-0./cli_start/ Return from empty command 'cli_start/'.
<gmic>-0./ Item[2]: '-debug' -> 'debug', selection [].
<gmic>-0./ Item[3]: 'input', selection [].
<gmic>-0./ Command 'input': arguments = '0'.
[gmic]-0./ Input empty image at position 0 (1 image 0x0x0x0).
<gmic>-1./ Item[5]: 'name.', selection [0].
<gmic>-1./ Command 'name': arguments = 'Dummy'.
[gmic]-1./ Set name of image [0] to 'Dummy'.
<gmic>-1./ Item[7]: 'input', selection [0].
<gmic>-1./ Command 'input': arguments = '3028,651,1,3,255*u'.
[gmic]-1./ Input image at position 1, with values '255*u' (1 image 3028x651x1x3).
<gmic>-2./ Item[9]: '-name.' -> 'name.', selection [1].
<gmic>-2./ Command 'name': arguments = 'foo'.
[gmic]-2./ Set name of image [1] to 'foo'.
<gmic>-2./ Item[11]: 'vlen={wh}' -> 'vlen=1971228', selection [].
[gmic]-2./ Set local variable 'vlen=1971228'.
<gmic>-2./ Item[12]: '-d' -> 'd', selections [0,1].
<gmic>-2./ Command 'display': arguments = ','.
[gmic]-2./ Display images [0,1] = 'Dummy, foo', from point (0,0,0).
[0] = 'Dummy':
size = (0,0,0,0) [0 b of floats].
data = (nil) = () [float].
[1] = 'foo':
size = (3028,651,1,3) [22 Mio of floats].
data = 0x7f9e01e22010 = (35.5049,168.419,252.065,193.653,59.9958,168.669,142.534,56.1951,196.325,66.4267,14.5031,78.2318,(...),4.21824,113.592,175.492,224.546,207.438,136.655,190.332,38.8058,149.642,240.614,38.8795,122.476).
min = 2.98047e-05, max = 255, mean = 127.552, std = 73.6039, coords_min = (2527,501,0,0), coords_max = (1593,524,0,1).
<gmic>-2./ Item[14]: 'store[foo]', selection [1].
<gmic>-2./ Command 'store': arguments = 'bar'.
[gmic]-2./ Store image [1] as variable 'bar'
<gmic>-1./ Item[16]: 'eval', selection [0].
[gmic_math_parser] size(noise) = 1971228 (compiled as 'const scalar', memslot = 38)
[gmic_math_parser] size(noise) = 1971228
<gmic>-1./ Command 'eval': arguments = '{ref(get('bar',$vlen),noise);print(size(noise))}' -> '1971228'.
[gmic]-1./ Evaluate expression '1971228' and assign it to status.
<gmic>-1./ Item[18]: '-d[Dummy]' -> 'd[Dummy]', selection [0].
<gmic>-1./ Command 'display': arguments = ','.
[gmic]-1./ Display image [0] = 'Dummy', from point (0,0,0).
[0] = 'Dummy':
size = (0,0,0,0) [0 b of floats].
data = (nil) = () [float].
<gmic>-1./ Item[20]: 'input', selection [0].
<gmic>-1./ Command 'input': arguments = '$bar' -> '*store/bar'.
[gmic]-1./ Input image from variable 'bar', at position 1 (1 image 3028x651x1x3).
[gmic]-2./ Display images [0,1] = 'Dummy, foo'.
[0] = 'Dummy':
size = (0,0,0,0) [0 b of floats].
data = (nil) = () [float].
[1] = 'foo':
size = (3028,651,1,3) [22 Mio of floats].
data = 0x56139defd6a0 = (35.5049,168.419,252.065,193.653,59.9958,168.669,142.534,56.1951,196.325,66.4267,14.5031,78.2318,(...),4.21824,113.592,175.492,224.546,207.438,136.655,190.332,38.8058,149.642,240.614,38.8795,122.476).
min = 2.98047e-05, max = 255, mean = 127.552, std = 73.6039, coords_min = (2527,501,0,0), coords_max = (1593,524,0,1).
<gmic>-2./ Exit scope './'.
[gmic]-2./ End G'MIC interpreter.
Trial 2: 30289 × 6511 → 197,211,679 pixels. Fails with error.
gosgood@bertha ~ $ gmic -debug input 0 name. Dummy input 30289,6511,1,3,255*u -name. foo vlen='{wh}' -d , store[foo] bar eval "{ref(get('bar',"\$vlen"),noise);print(size(noise))}" -d[Dummy] , input \$bar
[gmic]-0./ Start G'MIC interpreter (in debug mode).<gmic>-0./ Initial command line: 'cli_start , -debug input 0 name. Dummy input 30289,6511,1,3,255*u -name. foo vlen={wh} -d , store[foo] bar eval {ref(get('bar',$vlen),noise);print(size(noise))} -d[Dummy] , input $bar'.
<gmic>./ Decompose command line into 22 items:
<gmic>./ item[0] = 'cli_start'
<gmic>./ item[1] = ','
<gmic>./ item[2] = '-debug'
<gmic>./ item[3] = 'input'
<gmic>./ item[4] = '0'
<gmic>./ item[5] = 'name.'
<gmic>./ item[6] = 'Dummy'
<gmic>./ item[7] = 'input'
<gmic>./ item[8] = '30289,6511,1,3,255*u'
<gmic>./ item[9] = '-name.'
<gmic>./ item[10] = 'foo'
<gmic>./ item[11] = 'vlen={wh}'
<gmic>./ item[12] = '-d'
<gmic>./ item[13] = ','
<gmic>./ item[14] = 'store[foo]'
<gmic>./ item[15] = 'bar'
<gmic>./ item[16] = 'eval'
<gmic>./ item[17] = '{ref(get('bar',$vlen),noise);print(size(noise))}'
<gmic>./ item[18] = '-d[Dummy]'
<gmic>./ item[19] = ','
<gmic>./ item[20] = 'input'
<gmic>./ item[21] = '$bar'
<gmic>-0./ Enter scope './'.
<gmic>-0./ Item[0]: 'cli_start', selection [].
<gmic>-0./ Found custom command 'cli_start: ' (takes no arguments).
<gmic>-0./ Expand command line for command 'cli_start' to: ''.
<gmic>-0./cli_start/ Return from empty command 'cli_start/'.
<gmic>-0./ Item[2]: '-debug' -> 'debug', selection [].
<gmic>-0./ Item[3]: 'input', selection [].
<gmic>-0./ Command 'input': arguments = '0'.
[gmic]-0./ Input empty image at position 0 (1 image 0x0x0x0).
<gmic>-1./ Item[5]: 'name.', selection [0].
<gmic>-1./ Command 'name': arguments = 'Dummy'.
[gmic]-1./ Set name of image [0] to 'Dummy'.
<gmic>-1./ Item[7]: 'input', selection [0].
<gmic>-1./ Command 'input': arguments = '30289,6511,1,3,255*u'.
[gmic]-1./ Input image at position 1, with values '255*u' (1 image 30289x6511x1x3).
<gmic>-2./ Item[9]: '-name.' -> 'name.', selection [1].
<gmic>-2./ Command 'name': arguments = 'foo'.
[gmic]-2./ Set name of image [1] to 'foo'.
<gmic>-2./ Item[11]: 'vlen={wh}' -> 'vlen=197211679', selection [].
[gmic]-2./ Set local variable 'vlen=197211679'.
<gmic>-2./ Item[12]: '-d' -> 'd', selections [0,1].
<gmic>-2./ Command 'display': arguments = ','.
[gmic]-2./ Display images [0,1] = 'Dummy, foo', from point (0,0,0).
[0] = 'Dummy':
size = (0,0,0,0) [0 b of floats].
data = (nil) = () [float].
[1] = 'foo':
size = (30289,6511,1,3) [2256 Mio of floats].
data = 0x7fb121656010 = (80.4135,221.374,73.2544,194.962,48.5448,66.2645,135.319,242.799,142.155,90.4665,150.762,254.957,(...),61.3581,135.49,94.5716,43.9799,105.917,38.6727,88.7924,7.80504,112.064,88.717,196.653,210.172).
min = 7.12462e-07, max = 255, mean = 127.499, std = 73.6133, coords_min = (26309,819,0,2), coords_max = (13980,987,0,0).
<gmic>-2./ Item[14]: 'store[foo]', selection [1].
<gmic>-2./ Command 'store': arguments = 'bar'.
[gmic]-2./ Store image [1] as variable 'bar'
<gmic>-1./ Item[16]: 'eval', selection [0].
[gmic_math_parser] size(noise) = 197211679 (compiled as 'const scalar', memslot = 38)
[gmic]-1./ *** Error *** Item substitution '{ref(get('bar',197211679),noise);print(size(noise))}': CImg header not found in serialized buffer.
gosgood@bertha ~ $
There was also a dramatic drop in process memory consumption during, or immediately after the store
command executed, again to about 2.2 GB. Interestingly, the math evaluator did report on the size of the data set as it appeared in the math evaluator. The error message suggests, along with process size dropping, that the buffer was de-allocated prematurely.
This, I think, may be a two-pipe problem…