MCP import_style crashes ("Connection closed") on a handcrafted 4-module .dtstyle
MCP import_style crashes (segfault, "Connection closed") on a handcrafted 4-module .dtstyle
Reproduced on: darktable 5.7.0+768~g13f3af42c9 (nightly build 20260907), MCP server.
Hi — you mentioned on #22178 that you
couldn't reproduce the import_style crash. I bisected it and it's reproducible, but only on a
specific handcrafted style file, which is probably why it didn't trigger with system-generated
styles. Details below.
Repro
Call import_style with the attached .dtstyle (or the content below). The MCP server process
exits (client sees MCP error -32000: Connection closed), and the style is not imported.
{"path": "/path/to/test-import-768.dtstyle"}
The style contains 4 modules, each with an op_params + blendop_params (blendop_version 14):
| # | operation | op_params len | mix enabled |
|---|---|---|---|
| 0 | temperature |
40 | yes |
| 1 | exposure |
56 | yes |
| 2 | sigmoid |
112 | yes |
| 3 | colorbalancergb |
264 | yes |
Bisection (each import is a separate import_style call)
| File | Result |
|---|---|
only temperature |
{"ok":true} |
temperature + exposure |
{"ok":true} |
temperature + exposure + sigmoid |
{"ok":true} |
only colorbalancergb |
{"ok":true} |
| all 4 modules | crash → "Connection closed" |
So it is not a single module and not a simple param-size/version mismatch: the
colorbalancergb op_params (132 bytes; params_size:132, params_version:5) decodes correctly
via decode_params (shadows_Y:0.1, saturation_global:0.1, brilliance_global:0.12, …). The crash
only happens when all 4 modules with their blendop_params are present together — looks like a
code-path/interaction issue in style import (possibly the blendop parsing combined with several
modules, or a specific ordering).
Context
import_styleon a system-generated.dtstyle(e.g. the bundledexamples/colors/autumn) works fine ({"ok":true}, no crash, server stays alive). So the crash is specific to this multi-module handcrafted file.- Same crash reproduced on 5.7.0+758~gd63f1023a3 (nightly 20260906), and it still occurs on 768.
- Workaround used meanwhile: insert the rows directly into
data.db(styles+style_items).
Attached: test-import-768.dtstyle (the full 4-module repro). Happy to add logs / a gdb backtrace
if useful to narrow it down.
(full repro)
<?xml version="1.0" encoding="UTF-8"?>
<darktable_style version="1.0">
<info>
<name>test-import-768</name>
<description>[test nightly 768] WB 1.9/1.0/2.25 + exp +1.15 + sigmoid(mgc 1.4, dbt 0.35) + colorbalancergb(sat .1, brill .12, shadows_Y .1). Applicare su history resettata; ricalibrare WB su altre sessioni.</description>
<iop_list></iop_list>
</info>
<style>
<plugin>
<num>0</num>
<module>4</module>
<operation>temperature</operation>
<op_params>3333f33f0000803f000010400000000000000000</op_params>
<enabled>1</enabled>
<blendop_params>000000000000000018000000000000000000C84200000000000000000000000000000000050000000000000000000000000000000000000001000000000000000000000000000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FFFFFFFF00000000</blendop_params>
<blendop_version>14</blendop_version>
<multi_priority>0</multi_priority>
<multi_name></multi_name>
<multi_name_hand_edited>0</multi_name_hand_edited>
</plugin>
<plugin>
<num>1</num>
<module>7</module>
<operation>exposure</operation>
<op_params>00000000000000003333933f00004842000080c00000000001000000</op_params>
<enabled>1</enabled>
<blendop_params>000000000400000018000000000000000000C84200000000000000000000000000000000050000000000000000000000000000000000000001000000000000000000000000000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F0000000000000000000000000000000000000000000000000000000000000000789AD4C0789AD4C00000000000000000789AD4C0789AD4C00000000000000000000000000000000000000000000000000000000000000000FFFFFFFF00000000</blendop_params>
<blendop_version>14</blendop_version>
<multi_priority>0</multi_priority>
<multi_name></multi_name>
<multi_name_hand_edited>0</multi_name_hand_edited>
</plugin>
<plugin>
<num>2</num>
<module>3</module>
<operation>sigmoid</operation>
<op_params>3333b33f000000000000c8423333b33e000000000000c8420000000000000000000000000000000000000000000000000000000000000000</op_params>
<enabled>1</enabled>
<blendop_params>000000000400000018000000000000000000C84200000000000000000000000000000000050000000000000000000000000000000000000001000000000000000000000000000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F0000000000000000000000000000000000000000000000000000000000000000789AD4C0789AD4C00000000000000000789AD4C0789AD4C00000000000000000000000000000000000000000000000000000000000000000FFFFFFFF00000000</blendop_params>
<blendop_version>14</blendop_version>
<multi_priority>0</multi_priority>
<multi_name></multi_name>
<multi_name_hand_edited>0</multi_name_hand_edited>
</plugin>
<plugin>
<num>3</num>
<module>0</module>
<operation>colorbalancergb</operation>
<op_params>cdcccc3d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000803f000000000000803f00000000000000000000000000000000cdcccc3d000000000000000000000000000000008fc2f53d00000000000000000000000091ed3c3e0000000091ed3c3e0000000001000000</op_params>
<enabled>1</enabled>
<blendop_params>000000000400000018000000000000000000C84200000000000000000000000000000000050000000000000000000000000000000000000001000000000000000000000000000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F00000000000000000000803F0000803F0000000000000000000000000000000000000000000000000000000000000000789AD4C0789AD4C00000000000000000789AD4C0789AD4C00000000000000000000000000000000000000000000000000000000000000000FFFFFFFF00000000</blendop_params>
<blendop_version>14</blendop_version>
<multi_priority>0</multi_priority>
<multi_name></multi_name>
<multi_name_hand_edited>0</multi_name_hand_edited>
</plugin>
</style>
</darktable_style>
@andreagosto: Thank you for the report – the crash is reproducible.
The trigger is the empty <iop_list></iop_list> in your file, not the four modules. A style containing zero plugins and nothing but that element crashes the same way, and your four modules import fine once it is removed. That element is optional: it names the style's full pipeline order, and darktable omits it entirely when a style keeps the default one. It never writes an empty one, so a style exported from darktable, or shipped with it, never runs into this – only a hand-written file can.
It is not MCP-specific either: your file crashes the GUI import too, at the same place. dt_ioppr_deserialize_text_iop_order_list("") returns an empty list and _ioppr_sanity_check_iop_order() dereferences it (iop_order.c:2674).
On your side, removing the empty <iop_list></iop_list> is the fix. On ours, a malformed module order should not be fatal: darktable should ignore it, and import the style with the default order – so your file would import as it stands, minus the ordering it never specified. A fix along those lines is on the way.