Segfault ast_hashtab_hash_string (obj=0x15c) at hashtab.c

Hello! I have the error:
kernel: asterisk[10251]: segfault at 15c ip 00000000004f8760 sp 00007f630a526678 error 4 in asterisk[400000+2e1000]

core dump:
Program terminated with signal 11, Segmentation fault.
#0 ast_hashtab_hash_string (obj=0x15c) at hashtab.c:158
158 for (total = 0; *str; str++) {

What does it mean? How can I solve it?
Asterisk 16.23.0

It means the machine code tried to reference memory that was not allocated to the process. This is most likely the result of faulty code, although the primary fault may have happened some time before, the crash and in a different part of the code. It could also be the result of a hardware failure.

As Asterisk 16 is no longer supported, except for security issues, the best advice is to move to Asterisk 18 or 20, although, if you are stuck with Asterisk 16, you could try Asterisk 16.29.0.

With this sort of fault, the only thing you can do to prevent it, other than updating to a fixed version, is examine what you were doing at the time that was relatively unusual, and avoid doing it.

If you can reproduce in on 18 or 20 (or if you believe there are security implications, and you can reproduce it on 16.29.0), you should follow the instructions in:

https://wiki.asterisk.org/wiki/display/AST/Getting+a+Backtrace

to get the level of debugging information that may lead to the cause being identified. However, you should note that, because the primary cause may be distant, some segmentation faults are very difficult to diagnose.

1 Like

The same:
segfault at 15c ip 000000000058e799 sp 00007f29861af520 error 4 in asterisk[400000+2f4000]

#0 ast_str_case_hash (str=0x15c <Address 0x15c out of bounds>) at /usr/src/asterisk-20.0.0/include/asterisk/strings.h:1304
1304 while (*str) {

Asterisk 20.0.0

You need to report an issue at issues.asterisk.org, but you will need the backtraces, details of what you were doing at the time (it has to be relatively unusual otherwise this would have been fixed already, and probably the fully logs leading up to the crash.

What is happening before the segfault?

every time before the fall: autoservice.c: Thread is a user interface, not removing channel Snoop/Channel from autoservice

PS. I make 50 calls per second, and make SnoopChannel to each call. This error comes out sometimes at the moment when the call ends immediately after the start.

So if you initiate a call and it hangs up before snoop is called, you end up with a segfault? Sounds like you are trying to snoop on non-exisiting channels.

right. But asterisk should not fall by segfault error.

I have solved this problem: I create a snoop channel before the call starts