dcarp / protobuf-d

Protocol Buffers Compiler Plugin and Support Library for D
Boost Software License 1.0
37 stars 9 forks source link

AssertError #45

Open prabhu opened 7 months ago

prabhu commented 7 months ago

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
dcarp commented 6 months ago

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

cyrusmsk commented 5 months ago

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

cyrusmsk commented 4 months ago

@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 commented 4 months ago

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

from https://forum.dlang.org/post/p2ccql$qnf$1@digitalmars.com