From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 424C112B72 for ; Fri, 29 Dec 2023 17:21:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20230601.gappssmtp.com header.i=@networkplumber-org.20230601.gappssmtp.com header.b="oF9sd+cO" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-1d3e84fded7so35269325ad.1 for ; Fri, 29 Dec 2023 09:21:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1703870491; x=1704475291; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=xKoiaN5Ptx5nvAEn7znQLv6cCCZe9EwH3qBzMCtP9vs=; b=oF9sd+cOWhWgo/1AyNvSFN0IstkRRWK6CfG3tx6IDMYboN1/FtisJfSvjg5xc7yIAl UKge4w9wPr6wU4noa0KTC00O2UebsFqyN8TbtcVPlpCYevlH1N0c2cW1QKinN8QSt+X1 t9CeD+2R2noED0oQ8/dQGb/otV3ure9+G5mRqK0/DMlhC6tk7rQoYKLlj83FhdryKhHG MynJ7WqZEbWC8UiDV91urQjJkvJvQPikMDlkd/Iq5rMz2/wZKc66wfDSNRbiEhg+9irO lF9kwzlNPKMTSoc9exRozWyS4bOc43A/WUaWt4E2wXLf3aOTGb6YAkRE8ONRM83X1+Dp 6d6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703870491; x=1704475291; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xKoiaN5Ptx5nvAEn7znQLv6cCCZe9EwH3qBzMCtP9vs=; b=V7eInSFDgIHg06TPsEhkt8ET26JE3U0m2qLThHQz2vAY7qEbXghbtabBGGy1NqEyAb 0kpFWyP618j4Q6ZopK2mCTe2djou21XzdU457dRlWGZ7a6aWfcsGSs5w25a0QjOAl94B lMP/r3Sg0TeotyNYoBNWrnRWqJBwwWdBDDrWqpKaeTxPGfuk9HXZlP7zgRUruDBc0sqs 3ef/Tga381LvOSs/w693qPU0OvJqMHf4oJEo6Xm6j7jdh9rAZSERTiYZKhonEX/DbtJJ r2q2ofrxJj7ALg8CPfeU5StFIPKWe/ykZrh5Bh4UCJzVbxnoGZQmKSneBTHLvhWFqGq9 0nlQ== X-Gm-Message-State: AOJu0YzsMGTM1Sea9eFqoBkktxwN3GhLP+QVR3hxvk8BLtV50laW3aVP XDtGb6wt4pam36Fway7llY+MR0cRnHamEQ== X-Google-Smtp-Source: AGHT+IFuPWC15y3Fys9+ve8/S52v3w4SMiq4MkFREGDbWNkns27R/AxG8CAHo6O41LZvW9O9A3IlZg== X-Received: by 2002:a17:903:2c9:b0:1d4:61da:1384 with SMTP id s9-20020a17090302c900b001d461da1384mr5475666plk.106.1703870491534; Fri, 29 Dec 2023 09:21:31 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id j17-20020a170902c3d100b001d400970b6csm15877720plj.110.2023.12.29.09.21.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Dec 2023 09:21:31 -0800 (PST) Date: Fri, 29 Dec 2023 09:21:29 -0800 From: Stephen Hemminger To: Junxian Huang Cc: , , , , , , Subject: Re: [PATCH iproute2-rc 1/2] rdma: Fix core dump when pretty is used Message-ID: <20231229092129.25a526c4@hermes.local> In-Reply-To: <20231229065241.554726-2-huangjunxian6@hisilicon.com> References: <20231229065241.554726-1-huangjunxian6@hisilicon.com> <20231229065241.554726-2-huangjunxian6@hisilicon.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 29 Dec 2023 14:52:40 +0800 Junxian Huang wrote: > From: Chengchang Tang > > There will be a core dump when pretty is used as the JSON object > hasn't been opened and closed properly. > > Before: > $ rdma res show qp -jp -dd > [ { > "ifindex": 1, > "ifname": "hns_1", > "port": 1, > "lqpn": 1, > "type": "GSI", > "state": "RTS", > "sq-psn": 0, > "comm": "ib_core" > }, > "drv_sq_wqe_cnt": 128, > "drv_sq_max_gs": 2, > "drv_rq_wqe_cnt": 512, > "drv_rq_max_gs": 1, > rdma: json_writer.c:130: jsonw_end: Assertion `self->depth > 0' failed. > Aborted (core dumped) > > After: > $ rdma res show qp -jp -dd > [ { > "ifindex": 2, > "ifname": "hns_2", > "port": 1, > "lqpn": 1, > "type": "GSI", > "state": "RTS", > "sq-psn": 0, > "comm": "ib_core",{ > "drv_sq_wqe_cnt": 128, > "drv_sq_max_gs": 2, > "drv_rq_wqe_cnt": 512, > "drv_rq_max_gs": 1, > "drv_ext_sge_sge_cnt": 256 > } > } ] > > Fixes: 331152752a97 ("rdma: print driver resource attributes") > Signed-off-by: Chengchang Tang > Signed-off-by: Junxian Huang This code in rdma seems to be miking json and newline functionality which creates bug traps. Also the json should have same effective output in pretty and non-pretty mode. It looks like since pretty mode add extra object layer, the nesting of {} would be different. The conversion to json_print() was done but it isn't using same conventions as ip or tc. The correct fix needs to go deeper and hit other things.