¿Qué es strtol_l_internal?

I'm getting this in my program, C++

Program received signal SIGSEGV, Segmentation Fault. 0xb7d62153 in __strtol_l_internal () from /lib/libc.so.6

I got that by using GDB. CC compiled it fine along with G++

    sockf = openSocket(domainname, portc);
    if(sockf > 0){
        log("ZONTRECK","COMPLETED SOCKET!");
        int newsockfd;
        newsockfd = openListen(sockf,portc);
        log("ZONTRECK","Starting console!");

preguntado el 27 de agosto de 11 a las 18:08

It may well mean you've failed to terminate a string and/or overflowed, but without seeing some code it's impossible to say. -

I was about to edit to add code, I have to grab it -

If you can keep the code as small as possible (but complete still) to show the problem you're having it might help you spot the problem and even if it doesn't it'll make it easier for us to spot it. -

The code above doesn't compile -- there's no main -- so its impossible to see what is going wrong. Try looking at the stack trace to see how its getting to where the fault is (where command in gdb). If the stack trace makes no sense, you're probably smashing the stack somewhere. Try using valgrind to see if that can help. -

openListen and openSocket are in different files -

4 Respuestas

It's an internal function within libc, related to strtol() -- if I had to hazard a guess, I'd say you're trying to read in a number, and something is blowing up.

Respondido 27 ago 11, 22:08

no, I'm trying to open a socket and listen on a port. I don't know where this strtol is coming from. - Tyler McMaster

Chances are it is coming from one the functions called in your example: log(), openSocket(), or openListen(). If portc is a string I'd bet on the two latter ones. - uesp

Utiliza backtrace command in gdb to see how the program got to that point from your code - that will help find what parameter is being passed that's causing the problem (probably a NULL or otherwise invalid pointer).

Respondido 27 ago 11, 22:08

i see strtol as the first function in backtrace. - Tyler McMaster

@Tyler - that makes perfect sense - now break at that call to strtol() and take a look at the parameters. The problem is most likely the first one (since the second is allowed to be NULL), but it's possible that you're passing in a non-NULL but invalid pointer for wither or both. Are you using casts on the parameters? If so, the cast may be hiding an error or warning that's trying to tell you what the problem is. - Michael Burr

Maby you are trying here to read memory corrupted by some code ran before this. If this is the case than the best way is to debug it by Valgrind.

Respondido 27 ago 11, 23:08

I had to edit a file i didn't post on this site. Its my file that contains openSocket,openListen.

The atoi function requires const char, not char.

I was passing a char to it instead of a const char.

I fixed this issue by changing the char in int main() to const char.

Respondido 29 ago 11, 04:08

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.