Panicked during a panic / variable globale

hello,
I tested my program with:

	const childTerm = std.ChildProcess.spawnAndWait(&CallModule) catch |err| {
		@panic(std.fmt.allocPrint(allocChild, "{}", .{err}) catch unreachable);
	};

	// Error handling is provided to the calling procedure.
	switch (childTerm) {
		.Exited => |code| {
			if (code != 0) return ErrChild.Module_Invalid;
		},
		else => unreachable,
	}

Everything works fine with:
-Doptimize=Debug
-Doptimize=ReleaseFast
-Doptimize=ReleaseSmall

but it causes an error with:
-Doptimize=ReleaseSafe

thread {} panic: {s}
Panicked during a panic

Is allocChild an allocator?
Try to remove your @panic, might be unrelated.

With this code there is no double panic with various modes,
e.g. zig test test.zig -O ReleaseSafe

const std = @import("std");

test "panic" {
    const err = error.Child;
    @panic(std.fmt.allocPrint(std.testing.allocator, "{}", .{err}) catch unreachable);
}
1 Like

Another idea for a double panic is:
When the root module export a function named panic it replaces the panic handler.
If you have a function named panic and it is not a panic handler, just rename it.

1 Like

I only see overflow when “Release Safe”

no safe =

 LDA.user  soleil
 LDA.Init  ./Pcall
 LDA.Echo  ./Ecursed
 LDA.query false
 LDA.reply true
 LDA.abrod false
 UDS.zua1  j'ai biean reçu votre message
 UDS.zua2  Nom
 UDS.zua3  Jean-Pierre
 UDS.zua4  
 UDS.zua5  
 UDS.zun1  
 UDS.zun2  
 UDS.zun3  
 UDS.zun4  
 UDS.zun5  0
 UDS.zu8   50
 UDS.zbool truestop 3/3 fin

Safe

 LDA.user  soleil
 LDA.Init  ./Pcall
 LDA.Echo  ./Ecursed
 LDA.query false
 LDA.reply true
 LDA.abrod false
 UDS.zua1  j'ai biean reçu votre message
 UDS.zua2  Nom
 UDS.zua3  Jean-Pierre
 UDS.zua4  
 UDS.zua5  
 UDS.zun1  
 UDS.zun2  
 UDS.zun3  
 UDS.zun4  
 UDS.zun5  0
 UDS.zu8   50
 UDS.zbool true      ??????
 UDS.zua4  {s}
 UDS.zua5  {s}
 UDS.zun1  {s}
 UDS.zun2  {s}
 UDS.zun3  {s}
 UDS.zun4  {s}
	if (LDA.reply == true) {
		print("\n LDA.user  {s}", .{LDA.user});
		print("\n LDA.Init  {s}", .{LDA.init});
		print("\n LDA.Echo  {s}", .{LDA.echo});
		print("\n LDA.query {}",  .{LDA.query});
		print("\n LDA.reply {}",  .{LDA.reply});
		print("\n LDA.abrod {}",  .{LDA.abord});
		
		print("\n UDS.zua1  {s}", .{UDS.zua1});
		print("\n UDS.zua2  {s}", .{UDS.zua2});
		print("\n UDS.zua3  {s}", .{UDS.zua3});
		print("\n UDS.zua4  {s}", .{UDS.zua4});
		print("\n UDS.zua5  {s}", .{UDS.zua5});
		
		print("\n UDS.zun1  {s}", .{UDS.zun1});
		print("\n UDS.zun2  {s}", .{UDS.zun2});
		print("\n UDS.zun3  {s}", .{UDS.zun3});
		print("\n UDS.zun4  {s}", .{UDS.zun4});
		print("\n UDS.zun5  {s}", .{UDS.zun5});
		
		print("\n UDS.zu8   {d}", .{UDS.zu8});
		print("\n UDS.zbool {}",  .{UDS.zbool});
	} else print("\n\n\nLDA.reply : {} not found request ", .{LDA.reply});

Could you send your whole program for further debugging?

how to test an undefined const
my problem comes from there

undefined is a special value that means “this value is garbage”. Trying to do anything to it other than set it to something else will yield garbage, and using it in an if or similar is illegal.

If you want a value that indicates “there’s nothing here yet”, consider using ?T and null.

1 Like

I found a poorly informed structure zone,

thank you to everyone who informed me, it helped me to detach myself,
I was looking where it shouldn’t be, I was convinced that it was in “std.ChildProcess.spawnAndWait”
lol the message MADE me wrong lolll.

A global variable (def structure) can lead to good compilation, but can cause an error, a leak… difficult to detect, its use should be occasional.

it’s a protocol that I rebuilt with zig,
I did the same operation as *LDA of the AS400 OS

The compiler uses the local data area in the following situations:

A free-form definition has the DTAARA keyword without a parameter for an unnamed data structure.

This allows you to converse between two separate jobs, for example in the client program, just called the client visualization program,
ditto program delivery etc, especially suitable for doing modular programming

I was in my last functional tests.

use: file mmap and crypto nothing but pure zig

fortunately the compiler is hard on us