Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Segmentation fault when in shared object

Reply
Thread Tools

Segmentation fault when in shared object

 
 
Ben Bacarisse
Guest
Posts: n/a
 
      09-18-2012
Kaz Kylheku <(E-Mail Removed)> writes:

> On 2012-09-17, http://www.velocityreviews.com/forums/(E-Mail Removed) <(E-Mail Removed)> wrote:

<snip>
>> Because the code is working as executable I think it has something to do with
>> the rights the application has to write to the settings.

>
> This is incorrect reasoning. Because the code works without dynamic shared
> library loading, I would think that it has absolutely nothing to do with
> permissions on the tty.
>
> When X works, but X* doesn't, usually the fault is attributable to whatever
> has changed between X and X*, not whatever is common.


That's a good point to make but I don't think you follow it through.

> The difference is either directly responsible for the problem, or
> somehow reveals a latent problem. In this case, the difference is in the
> dynamic linking. Whether or not you're using dynamic linking isn't going
> to have an effect on the tty accessibility.

<snip>
> What's causing the problem in your code is that you named a global variable
> "error". This is the name of a function in the GNU C library. (You might even
> have a man page on this: man error).


That can't be the whole cause because it doesn't depend on "whatever
has changed between X and X*". The OP has that same variable in the
statically linked case and both of the dynamically linked cases, but
only one of those three fails.

> This is like if you had an "int printf;" or "int fcntl;" variable.


Which is perfectly fine, this being comp.lang.c. The question for
comp.unix.programmer is why it becomes a problem when using dlopen.

> Try putting the statement "error = 0" as the first statement of your
> OpenComport and see where the segfault is now.


--
Ben.
 
Reply With Quote
 
 
 
 
micro.q@gmail.com
Guest
Posts: n/a
 
      09-19-2012
Op maandag 17 september 2012 16:29:36 UTC+2 schreef (E-Mail Removed) het volgende:
> Hello,
>
>
>
> I have a piece of code what handles a serial device. I made a test program which get a number of the serial port. When I use these same code in a shared object I get a segmentation fault on the serial functions tcgetattr oftcsetattr. I've verified that with gdb. The shared object is used by net-snmp.
>
>
>
> My serial code is almost similar to http://code.google.com/p/as3-arduino...ws-x86/rs232.c
>
> I've only changed to get it working with parity.
>
>
>
> Because the code is working as executable I think it has something to do with the rights the application has to write to the settings.
>
>
>
> Joram


Thank you all for helping!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Segmentation fault using Firefox 15.0.2 Keith Lee Firefox 3 04-29-2006 05:45 PM
I'm losing the address of an object... segmentation fault! ChristophK C++ 8 02-24-2006 04:50 PM
segmentation fault on delete object (which belongs to some class under a hierarchy) Joel C++ 4 10-11-2004 05:07 AM
Intel Xeon + Linux + IBM sdk 1.3.1 - getting Segmentation fault Alex Hunsley Java 17 11-06-2003 12:12 AM
built with --enable-shared but get error: libpython2.3.so.1.0: can't open shared object file Douglass Turner Python 2 09-04-2003 01:56 PM



Advertisments