protobuf-d icon indicating copy to clipboard operation
protobuf-d copied to clipboard

AssertError

Open prabhu opened this issue 2 years ago • 4 comments

Facing the below error when trying to generate bindings with the master.

core.exception.AssertError@src/google/protobuf/internal.d(47): Assertion failure
----------------
??:? _d_assertp [0x4e3df0]
src/google/protobuf/internal.d:47 const ubyte google.protobuf.internal.Varint.opIndex(ulong) [0x4d9cdf]
src/google/protobuf/internal.d:43 const @property ubyte google.protobuf.internal.Varint.front() [0x4d9c8e]
/home/prabhu/dlang/dmd-2.106.0/linux/bin64/../../src/phobos/std/range/package.d:1094 @property ubyte std.range.chain!(google.protobuf.internal.Varint, std.range.chain!(google.protobuf.internal.Varint, ubyte[]).chain(google.protobuf.internal.Varint, ubyte[]).Result).chain(google.protobuf.internal.Varint, std.range.chain!(google.protobuf.internal.Varint, ubyte[]).chain(google.protobuf.internal.Varint, ubyte[]).Result).Result.front() [0x4bbfc7]
/home/prabhu/dlang/dmd-2.106.0/linux/bin64/../../src/phobos/std/range/package.d:1094 @property ubyte std.range.chain!(std.range.chain!(google.protobuf.internal.Varint, std.range.chain!(google.protobuf.internal.Varint, ubyte[]).chain(google.protobuf.internal.Varint, ubyte[]).Result).chain(google.protobuf.internal.Varint, std.range.chain!(google.protobuf.internal.Varint, ubyte[]).chain(google.protobuf.internal.Varint, ubyte[]).Result).Result, google.protobuf.internal.sizedJoiner!(std.algorithm.iteration.MapResult!(google.protobuf.encoding.toProtobufByProto!(google.protobuf.common.Proto(15, 0, 0), google.protobuf.compiler.plugin.CodeGeneratorResponse.File[]).toProtobufByProto(google.protobuf.compiler.plugin.CodeGeneratorResponse.File[]).__lambda3, google.protobuf.compiler.plugin.CodeGeneratorResponse.File[]).MapResult).sizedJoiner(std.algorithm.iteration.MapResult!(google.protobuf.encoding.toProtobufByProto!(google.protobuf.common.Proto(15, 0, 0), google.protobuf.compiler.plugin.CodeGeneratorResponse.File[]).toProtobufByProto(google.protobuf.compiler.plugin.CodeGeneratorResponse.File[]).__lambda3, google.protobuf.compiler.plugin.CodeGeneratorResponse.File[]).MapResult).Result).chain(std.range.chain!(google.protobuf.internal.Varint, std.range.chain!(google.protobuf.internal.Varint, ubyte[]).chain(google.protobuf.internal.Varint, ubyte[]).Result).chain(google.protobuf.internal.Varint, std.range.chain!(google.protobuf.internal.Varint, ubyte[]).chain(google.protobuf.internal.Varint, ubyte[]).Result).Result, google....
/home/prabhu/dlang/dmd-2.106.0/linux/bin64/../../src/phobos/std/array.d:132 ubyte[] std.array.array!(std.range.chain!(std.range.chain!(google.protobuf.internal.Varint, std.range.chain!(google.protobuf.internal.Varint, ubyte[]).chain(google.protobuf.internal.Varint, ubyte[]).Result).chain(google.protobuf.internal.Varint, std.range.chain!(google.protobuf.internal.Varint, ubyte[]).chain(google.protobuf.internal.Varint, ubyte[]).Result).Result, google.protobuf.internal.sizedJoiner!(std.algorithm.iteration.MapResult!(google.protobuf.encoding.toProtobufByProto!(google.protobuf.common.Proto(15, 0, 0), google.protobuf.compiler.plugin.CodeGeneratorResponse.File[]).toProtobufByProto(google.protobuf.compiler.plugin.CodeGeneratorResponse.File[]).__lambda3, google.protobuf.compiler.plugin.CodeGeneratorResponse.File[]).MapResult).sizedJoiner(std.algorithm.iteration.MapResult!(google.protobuf.encoding.toProtobufByProto!(google.protobuf.common.Proto(15, 0, 0), google.protobuf.compiler.plugin.CodeGeneratorResponse.File[]).toProtobufByProto(google.protobuf.compiler.plugin.CodeGeneratorResponse.File[]).__lambda3, google.protobuf.compiler.plugin.CodeGeneratorResponse.File[]).MapResult).Result).chain(std.range.chain!(google.protobuf.internal.Varint, std.range.chain!(google.protobuf.internal.Varint, ubyte[]).chain(google.protobuf.internal.Varint, ubyte[]).Result).chain(google.protobuf.internal.Varint, std.range.chain!(google.protobuf.internal.Varint, ubyte[]).chain(google.protobuf.internal.Varint, ubyte[]).Result).Result, google....
protoc_gen_d/protoc-gen-d.d:20 _Dmain [0x4d274f]
--d_out: protoc-gen-d: Plugin failed with status code 1.

Proto file: https://github.com/AppThreat/atom/blob/main/specification/atom.proto

protoc -I . --d_out=bindings/d atom.proto

prabhu avatar Dec 13 '23 18:12 prabhu

Looks similar to this https://github.com/dcarp/protobuf-d/issues/43#issuecomment-1767278229 Could you try it with v2.103.1?

dcarp avatar Jan 19 '24 14:01 dcarp

I can confirm that my .proto file generated with ldc1.33, and didn't work with ldc 1.36

cyrusmsk avatar Feb 05 '24 22:02 cyrusmsk

@dcarp Will it be possible to rewrite part of the code, that using chain(...).init.empty behavior? based on comments from the bugzilla that this is "undefined behavior" in the range API currently...

cyrusmsk avatar Mar 03 '24 12:03 cyrusmsk

Maybe use? import std.traits : isArray; static if (isArray!(typeof(res)))

from https://forum.dlang.org/post/[email protected]

cyrusmsk avatar Mar 03 '24 22:03 cyrusmsk