flat assembler
Message board for the users of flat assembler.

Index > Linux > segmentation fault when calling mysql (in both fasm and c)

Author
Thread Post new topic Reply to topic
skingston



Joined: 11 Dec 2004
Posts: 19
skingston 30 Mar 2005, 04:30
Hi,
Has anyone here tried using mysql with either mysql or c in linux?

I created a simple program that prints out a couple of messages and tries to call the function mysql_init(). I eventually worked out how to compile and link them, but when I run the program, the mysql_init function causes a segmentation fault. Does any one know what mite be causing this?

This is the asm code with the problem:
mov eax,4
mov ebx,1
mov ecx,msg
mov edx,msg_size
int 0x80

mycall mysql_init ; (this is the same as call mysql_init)

mov eax,4
mov ebx,1
mov ecx,msg
mov edx,msg_size
int 0x80
....

I compiled the program like this:
fasm mysql.asm mysql.o
CFG=/usr/lib/mysql/mysql_config
sh -c "gcc -o mysql mysql.o `$CFG --libs`"

I get this output:
Hello World!
Segmentation fault

The c program does the same thing. Can anyone help?
Post 30 Mar 2005, 04:30
View user's profile Send private message Reply with quote
Endre



Joined: 29 Dec 2003
Posts: 215
Location: Budapest, Hungary
Endre 30 Mar 2005, 09:56
Could we see the entire source if it's not confidental? Or check out the examples delivered with fasm (I mean elfexe, elfobj, libcdemo) - they may help.
Post 30 Mar 2005, 09:56
View user's profile Send private message Reply with quote
skingston



Joined: 11 Dec 2004
Posts: 19
skingston 30 Mar 2005, 22:47
I can show you the entire source if you wish.

However, I have discovered the problem. The mysql_init function takes a null parameter.

It is now working without any problems.
Post 30 Mar 2005, 22:47
View user's profile Send private message Reply with quote
Endre



Joined: 29 Dec 2003
Posts: 215
Location: Budapest, Hungary
Endre 31 Mar 2005, 08:41
skingston wrote:
I have discovered the problem. The mysql_init function takes a null parameter.

It is now working without any problems.

Excellent. Next if you had any problem just throw a post on the forum, you see how it solved your problem. We all already know that this is a magic forum. You've now experienced it, too Smile.
Post 31 Mar 2005, 08:41
View user's profile Send private message Reply with quote
skingston



Joined: 11 Dec 2004
Posts: 19
skingston 31 Mar 2005, 10:00
Yes it is.
I think i'll have to write all of my programs into the forum from now on so I don't make any more stupid mistakes Smile
Post 31 Mar 2005, 10:00
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.